Skip to content

Commit d00e2a6

Browse files
committed
Add comment on symbol searching
Add comment describing why we need to check for the availability of strlcat/strlcpy and issetguid. Also removed setting the _GNU_SOURCES compile-definition and -fblocks flag as it's already added through one of the global variables.
1 parent bd3e56d commit d00e2a6

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

CMakeLists.txt

+6-6
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,12 @@ include(CheckSymbolExists)
8181

8282
check_linker_flag(C "LINKER:--build-id=sha1" LINKER_SUPPORTS_BUILD_ID)
8383

84+
# Detect if the system libc defines symbols for these functions.
85+
# If it is not availble, swift-corelibs-foundation has its own implementations
86+
# that will be used. If it is available, it should not redefine them.
87+
# Note: SwiftPM does not have the ability to introspect the contents of the SDK
88+
# and therefore will always include these functions in the build and will
89+
# cause build failures on platforms that define these functions.
8490
check_symbol_exists("strlcat" "string.h" HAVE_STRLCAT)
8591
check_symbol_exists("strlcpy" "string.h" HAVE_STRLCPY)
8692
check_symbol_exists("issetugid" "unistd.h" HAVE_ISSETUGID)
@@ -89,17 +95,11 @@ add_compile_definitions(
8995
$<$<AND:$<COMPILE_LANGUAGE:C>,$<BOOL:${HAVE_STRLCPY}>>:HAVE_STRLCPY>
9096
$<$<AND:$<COMPILE_LANGUAGE:C>,$<BOOL:${HAVE_ISSETUGID}>>:HAVE_ISSETUGID>)
9197

92-
if(CMAKE_SYSTEM_NAME STREQUAL Linux OR ANDROID)
93-
add_compile_definitions($<$<COMPILE_LANGUAGE:C>:_GNU_SOURCE>)
94-
endif()
95-
9698
if(CMAKE_SYSTEM_NAME STREQUAL Linux)
9799
check_symbol_exists(sched_getaffinity "sched.h" HAVE_SCHED_GETAFFINITY)
98100
add_compile_definitions($<$<COMPILE_LANGUAGE:C>:HAVE_SCHED_GETAFFINITY>)
99101
endif()
100102

101-
add_compile_options($<$<COMPILE_LANGUAGE:C>:-fblocks>)
102-
103103
# Precompute module triple for installation
104104
if(NOT SwiftFoundation_MODULE_TRIPLE)
105105
set(module_triple_command "${CMAKE_Swift_COMPILER}" -print-target-info)

0 commit comments

Comments
 (0)