Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 8 additions & 1 deletion flang-rt/cmake/modules/AddFlangRT.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -251,8 +251,15 @@ function (add_flangrt_library name)
$<$<COMPILE_LANGUAGE:CXX>:-nogpulib -flto -fvisibility=hidden -Wno-unknown-cuda-version --cuda-feature=+ptx63>
)
elseif (APPLE)
# Clang on Darwin enables non-POSIX extensions by default.
# This causes some macros to leak, such as HUGE from <math.h>, which
# causes some conflicts with Flang symbols (but not with Flang-RT, for
# now).
# It also causes some Flang-RT extensions to be disabled, such as fdate,
# that checks for _POSIX_C_SOURCE.
# Setting _POSIX_C_SOURCE avoids these issues.
target_compile_options(${tgtname} PRIVATE
$<$<COMPILE_LANGUAGE:CXX>:${DARWIN_osx_BUILTIN_MIN_VER_FLAG}>
$<$<COMPILE_LANGUAGE:CXX>:${DARWIN_osx_BUILTIN_MIN_VER_FLAG} -D_POSIX_C_SOURCE=200809>
)
endif ()

Expand Down
9 changes: 9 additions & 0 deletions flang-rt/unittests/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,15 @@ function(add_flangrt_dependent_libs target)
instead falls back to builtins from Compiler-RT. Linking with ${tgtname}
may result in a linker error.")
endif ()
elseif (APPLE)
# Clang on Darwin enables non-POSIX extensions by default.
# This causes some macros to leak, such as HUGE from <math.h>, which
# causes some conflicts with Flang symbols (but not with Flang-RT, for
# now).
# It also causes some Flang-RT extensions to be disabled, such as fdate,
# that checks for _POSIX_C_SOURCE.
# Setting _POSIX_C_SOURCE avoids these issues.
target_compile_options(${target} PRIVATE "-D_POSIX_C_SOURCE=200809")
endif ()
endfunction()

Expand Down
Loading