Skip to content

Commit 3cf5f3f

Browse files
committed
Avoid global add_definitions
1 parent 2f36f41 commit 3cf5f3f

File tree

2 files changed

+7
-4
lines changed

2 files changed

+7
-4
lines changed

flang-rt/CMakeLists.txt

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -143,10 +143,6 @@ endif()
143143
set(CMAKE_CXX_STANDARD 17 CACHE STRING "C++ standard to conform to")
144144
set(CMAKE_CXX_STANDARD_REQUIRED YES)
145145

146-
# Disable libstdc++/libc++ assertions, even in an LLVM_ENABLE_ASSERTIONS build,
147-
# to avoid an unwanted dependency on libstdc++/libc++.so.
148-
add_definitions(-U_GLIBCXX_ASSERTIONS)
149-
add_definitions(-U_LIBCPP_ENABLE_ASSERTIONS)
150146

151147
configure_file(cmake/config.h.cmake.in config.h)
152148

flang-rt/cmake/modules/AddFlangRT.cmake

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,13 @@ function (add_flangrt_library name)
8686
# For flang-rt's configured config.h to be found
8787
target_include_directories(${name} PRIVATE "${FLANGRT_BINARY_DIR}")
8888

89+
# Disable libstdc++/libc++ assertions, even in an LLVM_ENABLE_ASSERTIONS
90+
# build, to avoid an unwanted dependency on libstdc++/libc++.so.
91+
if (CMAKE_CXX_COMPILER_FRONTEND_VARIANT STREQUAL "GNU")
92+
target_compile_options(${name} PUBLIC -U_GLIBCXX_ASSERTIONS)
93+
target_compile_options(${name} PUBLIC -U_LIBCPP_ENABLE_ASSERTIONS)
94+
endif ()
95+
8996
# Flang/Clang (including clang-cl) -compiled programs targeting the MSVC ABI
9097
# should only depend on msv(u)crt. LLVM still emits libgcc/compiler-rt
9198
# functions for 128-bit integer math (__udivti3, __modti3, __fixsfti,

0 commit comments

Comments
 (0)