Skip to content

Commit b22db59

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 16071df commit b22db59

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
@@ -99,6 +99,12 @@ include(CheckSymbolExists)
9999

100100
check_linker_flag(C "LINKER:--build-id=sha1" LINKER_SUPPORTS_BUILD_ID)
101101

102+
# Detect if the system libc defines symbols for these functions.
103+
# If it is not availble, swift-corelibs-foundation has its own implementations
104+
# that will be used. If it is available, it should not redefine them.
105+
# Note: SwiftPM does not have the ability to introspect the contents of the SDK
106+
# and therefore will always include these functions in the build and will
107+
# cause build failures on platforms that define these functions.
102108
check_symbol_exists("strlcat" "string.h" HAVE_STRLCAT)
103109
check_symbol_exists("strlcpy" "string.h" HAVE_STRLCPY)
104110
check_symbol_exists("issetugid" "unistd.h" HAVE_ISSETUGID)
@@ -107,17 +113,11 @@ add_compile_definitions(
107113
$<$<AND:$<COMPILE_LANGUAGE:C>,$<BOOL:${HAVE_STRLCPY}>>:HAVE_STRLCPY>
108114
$<$<AND:$<COMPILE_LANGUAGE:C>,$<BOOL:${HAVE_ISSETUGID}>>:HAVE_ISSETUGID>)
109115

110-
if(CMAKE_SYSTEM_NAME STREQUAL Linux OR ANDROID)
111-
add_compile_definitions($<$<COMPILE_LANGUAGE:C>:_GNU_SOURCE>)
112-
endif()
113-
114116
if(CMAKE_SYSTEM_NAME STREQUAL Linux)
115117
check_symbol_exists(sched_getaffinity "sched.h" HAVE_SCHED_GETAFFINITY)
116118
add_compile_definitions($<$<COMPILE_LANGUAGE:C>:HAVE_SCHED_GETAFFINITY>)
117119
endif()
118120

119-
add_compile_options($<$<COMPILE_LANGUAGE:C>:-fblocks>)
120-
121121
# Precompute module triple for installation
122122
if(NOT SwiftFoundation_MODULE_TRIPLE)
123123
set(module_triple_command "${CMAKE_Swift_COMPILER}" -print-target-info)

0 commit comments

Comments
 (0)