Skip to content

Commit

Permalink
Only define _XOPEN_SOURCE in configurecompiler.cmake (for consistency) (
Browse files Browse the repository at this point in the history
#110092)

* Only define _XOPEN_SOURCE in configurecompiler.cmake (for consistency)

* Apply _DARWIN_C_SOURCE universally for all Apple platforms
  • Loading branch information
filipnavara authored Nov 30, 2024
1 parent 150d314 commit 979d711
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 12 deletions.
19 changes: 12 additions & 7 deletions eng/native/configurecompiler.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -301,14 +301,19 @@ elseif(CLR_CMAKE_HOST_SUNOS)
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fstack-protector")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fstack-protector")
add_definitions(-D__EXTENSIONS__ -D_XPG4_2 -D_POSIX_PTHREAD_SEMANTICS -D_REENTRANT)
elseif(CLR_CMAKE_HOST_OSX AND NOT CLR_CMAKE_HOST_MACCATALYST AND NOT CLR_CMAKE_HOST_IOS AND NOT CLR_CMAKE_HOST_TVOS)
elseif(CLR_CMAKE_HOST_APPLE)
# enable support for X/Open and POSIX APIs, like the <ucontext.h> header file
add_definitions(-D_XOPEN_SOURCE)

# the new linker in Xcode 15 (ld_new/ld_prime) deprecated the -bind_at_load flag for macOS which causes a warning
# that fails the build since we build with -Werror. Only pass the flag if we need it, i.e. older linkers.
check_linker_flag(C "-Wl,-bind_at_load,-fatal_warnings" LINKER_SUPPORTS_BIND_AT_LOAD_FLAG)
if(LINKER_SUPPORTS_BIND_AT_LOAD_FLAG)
add_linker_flag("-Wl,-bind_at_load")
# enable support for Darwin extension APIs, like pthread_getthreadid_np
add_definitions(-D_DARWIN_C_SOURCE)

if(CLR_CMAKE_HOST_OSX)
# the new linker in Xcode 15 (ld_new/ld_prime) deprecated the -bind_at_load flag for macOS which causes a warning
# that fails the build since we build with -Werror. Only pass the flag if we need it, i.e. older linkers.
check_linker_flag(C "-Wl,-bind_at_load,-fatal_warnings" LINKER_SUPPORTS_BIND_AT_LOAD_FLAG)
if(LINKER_SUPPORTS_BIND_AT_LOAD_FLAG)
add_linker_flag("-Wl,-bind_at_load")
endif()
endif()
elseif(CLR_CMAKE_HOST_HAIKU)
add_compile_options($<$<COMPILE_LANGUAGE:ASM>:-Wa,--noexecstack>)
Expand Down
1 change: 0 additions & 1 deletion src/coreclr/nativeaot/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ if(CLR_CMAKE_HOST_UNIX)
add_compile_options(-nostdlib)

if(CLR_CMAKE_TARGET_APPLE)
add_definitions(-D_XOPEN_SOURCE)
add_definitions(-DFEATURE_OBJCMARSHAL)
endif(CLR_CMAKE_TARGET_APPLE)

Expand Down
4 changes: 0 additions & 4 deletions src/native/libs/System.Native/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,6 @@ if (NOT CLR_CMAKE_TARGET_MACCATALYST AND NOT CLR_CMAKE_TARGET_IOS AND NOT CLR_CM
add_definitions(-DHAS_CONSOLE_SIGNALS)
endif ()

if (CLR_CMAKE_TARGET_OSX)
add_definitions(-D_DARWIN_C_SOURCE)
endif ()

set(NATIVE_SOURCES
pal_errno.c
pal_interfaceaddresses.c
Expand Down

0 comments on commit 979d711

Please sign in to comment.