Skip to content

Commit

Permalink
Revert "[runtimes] Probe for -nostdlib++ and -nostdinc++ with the C c…
Browse files Browse the repository at this point in the history
  • Loading branch information
vitalybuka authored and NoumanAmir657 committed Nov 4, 2024
1 parent 650e45e commit 758b527
Show file tree
Hide file tree
Showing 6 changed files with 19 additions and 35 deletions.
12 changes: 4 additions & 8 deletions libcxx/cmake/config-ix.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -38,13 +38,9 @@ check_cxx_compiler_flag(-nolibc CXX_SUPPORTS_NOLIBC_FLAG)
# required during compilation (which has the -nostdlib++ or -nodefaultlibs). libc is
# required for the link to go through. We remove sanitizers from the
# configuration checks to avoid spurious link errors.
#
# Adding flags to CMAKE_REQUIRED_FLAGS will include the flags both when testing
# compilation of C and C++. Therefore test to make sure that the flags are
# supported by the C compiler driver, before deciding to include them.

check_c_compiler_flag(-nostdlib++ C_SUPPORTS_NOSTDLIBXX_FLAG)
if (C_SUPPORTS_NOSTDLIBXX_FLAG)
check_cxx_compiler_flag(-nostdlib++ CXX_SUPPORTS_NOSTDLIBXX_FLAG)
if (CXX_SUPPORTS_NOSTDLIBXX_FLAG)
set(CMAKE_REQUIRED_FLAGS "${CMAKE_REQUIRED_FLAGS} -nostdlib++")
else()
check_c_compiler_flag(-nodefaultlibs C_SUPPORTS_NODEFAULTLIBS_FLAG)
Expand All @@ -55,7 +51,7 @@ endif()

# Only link against compiler-rt manually if we use -nodefaultlibs, since
# otherwise the compiler will do the right thing on its own.
if (NOT C_SUPPORTS_NOSTDLIBXX_FLAG AND C_SUPPORTS_NODEFAULTLIBS_FLAG)
if (NOT CXX_SUPPORTS_NOSTDLIBXX_FLAG AND C_SUPPORTS_NODEFAULTLIBS_FLAG)
if (LIBCXX_USE_COMPILER_RT)
include(HandleCompilerRT)
find_compiler_rt_library(builtins LIBCXX_BUILTINS_LIBRARY
Expand Down Expand Up @@ -85,7 +81,7 @@ if (NOT C_SUPPORTS_NOSTDLIBXX_FLAG AND C_SUPPORTS_NODEFAULTLIBS_FLAG)
endif()
endif()

if (C_SUPPORTS_NOSTDLIBXX_FLAG OR C_SUPPORTS_NODEFAULTLIBS_FLAG)
if (CXX_SUPPORTS_NOSTDLIBXX_FLAG OR C_SUPPORTS_NODEFAULTLIBS_FLAG)
if (CMAKE_C_FLAGS MATCHES -fsanitize OR CMAKE_CXX_FLAGS MATCHES -fsanitize)
set(CMAKE_REQUIRED_FLAGS "${CMAKE_REQUIRED_FLAGS} -fno-sanitize=all")
endif ()
Expand Down
12 changes: 4 additions & 8 deletions libcxxabi/cmake/config-ix.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -22,13 +22,9 @@ endif ()
# required during compilation (which has the -nodefaultlibs). libc is
# required for the link to go through. We remove sanitizers from the
# configuration checks to avoid spurious link errors.
#
# Adding flags to CMAKE_REQUIRED_FLAGS will include the flags both when testing
# compilation of C and C++. Therefore test to make sure that the flags are
# supported by the C compiler driver, before deciding to include them.

check_c_compiler_flag(-nostdlib++ C_SUPPORTS_NOSTDLIBXX_FLAG)
if (C_SUPPORTS_NOSTDLIBXX_FLAG)
check_cxx_compiler_flag(-nostdlib++ CXX_SUPPORTS_NOSTDLIBXX_FLAG)
if (CXX_SUPPORTS_NOSTDLIBXX_FLAG)
set(CMAKE_REQUIRED_FLAGS "${CMAKE_REQUIRED_FLAGS} -nostdlib++")
else()
check_c_compiler_flag(-nodefaultlibs C_SUPPORTS_NODEFAULTLIBS_FLAG)
Expand All @@ -39,7 +35,7 @@ endif()

# Only link against compiler-rt manually if we use -nodefaultlibs, since
# otherwise the compiler will do the right thing on its own.
if (NOT C_SUPPORTS_NOSTDLIBXX_FLAG AND C_SUPPORTS_NODEFAULTLIBS_FLAG)
if (NOT CXX_SUPPORTS_NOSTDLIBXX_FLAG AND C_SUPPORTS_NODEFAULTLIBS_FLAG)
if (LIBCXXABI_HAS_C_LIB)
list(APPEND CMAKE_REQUIRED_LIBRARIES c)
endif ()
Expand Down Expand Up @@ -75,7 +71,7 @@ if (NOT C_SUPPORTS_NOSTDLIBXX_FLAG AND C_SUPPORTS_NODEFAULTLIBS_FLAG)
endif()
endif()

if (C_SUPPORTS_NOSTDLIBXX_FLAG OR C_SUPPORTS_NODEFAULTLIBS_FLAG)
if (CXX_SUPPORTS_NOSTDLIBXX_FLAG OR C_SUPPORTS_NODEFAULTLIBS_FLAG)
if (CMAKE_C_FLAGS MATCHES -fsanitize OR CMAKE_CXX_FLAGS MATCHES -fsanitize)
set(CMAKE_REQUIRED_FLAGS "${CMAKE_REQUIRED_FLAGS} -fno-sanitize=all")
endif ()
Expand Down
4 changes: 2 additions & 2 deletions libcxxabi/src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ if (ANDROID AND ANDROID_PLATFORM_LEVEL LESS 21)
endif()

# Setup flags.
if (C_SUPPORTS_NOSTDLIBXX_FLAG)
if (CXX_SUPPORTS_NOSTDLIBXX_FLAG)
add_link_flags_if_supported(-nostdlib++)
else()
add_link_flags_if_supported(-nodefaultlibs)
Expand Down Expand Up @@ -167,7 +167,7 @@ if (LIBCXXABI_USE_LLVM_UNWINDER)
endif()
endif()
target_link_libraries(cxxabi_shared_objects PRIVATE cxx-headers ${LIBCXXABI_LIBRARIES})
if (NOT C_SUPPORTS_NOSTDLIBXX_FLAG)
if (NOT CXX_SUPPORTS_NOSTDLIBXX_FLAG)
target_link_libraries(cxxabi_shared_objects PRIVATE ${LIBCXXABI_BUILTINS_LIBRARY})
endif()
target_link_libraries(cxxabi_shared_objects PUBLIC cxxabi-headers)
Expand Down
12 changes: 4 additions & 8 deletions libunwind/cmake/config-ix.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -34,13 +34,9 @@ endif()
# required during compilation (which has the -nostdlib++ or -nodefaultlibs). libc is
# required for the link to go through. We remove sanitizers from the
# configuration checks to avoid spurious link errors.
#
# Adding flags to CMAKE_REQUIRED_FLAGS will include the flags both when testing
# compilation of C and C++. Therefore test to make sure that the flags are
# supported by the C compiler driver, before deciding to include them.

llvm_check_compiler_linker_flag(C "-nostdlib++" C_SUPPORTS_NOSTDLIBXX_FLAG)
if (C_SUPPORTS_NOSTDLIBXX_FLAG)
llvm_check_compiler_linker_flag(CXX "-nostdlib++" CXX_SUPPORTS_NOSTDLIBXX_FLAG)
if (CXX_SUPPORTS_NOSTDLIBXX_FLAG)
set(CMAKE_REQUIRED_FLAGS "${CMAKE_REQUIRED_FLAGS} -nostdlib++")
else()
llvm_check_compiler_linker_flag(C "-nodefaultlibs" C_SUPPORTS_NODEFAULTLIBS_FLAG)
Expand All @@ -51,7 +47,7 @@ endif()

# Only link against compiler-rt manually if we use -nodefaultlibs, since
# otherwise the compiler will do the right thing on its own.
if (NOT C_SUPPORTS_NOSTDLIBXX_FLAG AND C_SUPPORTS_NODEFAULTLIBS_FLAG)
if (NOT CXX_SUPPORTS_NOSTDLIBXX_FLAG AND C_SUPPORTS_NODEFAULTLIBS_FLAG)
if (LIBUNWIND_HAS_C_LIB)
list(APPEND CMAKE_REQUIRED_LIBRARIES c)
endif ()
Expand Down Expand Up @@ -86,7 +82,7 @@ if (NOT C_SUPPORTS_NOSTDLIBXX_FLAG AND C_SUPPORTS_NODEFAULTLIBS_FLAG)
endif()
endif()

if (C_SUPPORTS_NOSTDLIBXX_FLAG OR C_SUPPORTS_NODEFAULTLIBS_FLAG)
if (CXX_SUPPORTS_NOSTDLIBXX_FLAG OR C_SUPPORTS_NODEFAULTLIBS_FLAG)
if (CMAKE_C_FLAGS MATCHES -fsanitize OR CMAKE_CXX_FLAGS MATCHES -fsanitize)
set(CMAKE_REQUIRED_FLAGS "${CMAKE_REQUIRED_FLAGS} -fno-sanitize=all")
endif ()
Expand Down
2 changes: 1 addition & 1 deletion libunwind/src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ set(LIBUNWIND_SOURCES
${LIBUNWIND_ASM_SOURCES})

# Generate library list.
if (C_SUPPORTS_NOSTDLIBXX_FLAG)
if (CXX_SUPPORTS_NOSTDLIBXX_FLAG)
add_link_flags_if_supported(-nostdlib++)
else()
if (LIBUNWIND_USE_COMPILER_RT)
Expand Down
12 changes: 4 additions & 8 deletions runtimes/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -143,16 +143,12 @@ endif()
# Check for -nostdlib++ first; if there's no C++ standard library yet,
# all check_cxx_compiler_flag commands will fail until we add -nostdlib++
# (or -nodefaultlibs).
#
# Adding flags to CMAKE_REQUIRED_FLAGS will include the flags both when testing
# compilation of C and C++. Therefore test to make sure that the flags are
# supported by the C compiler driver, before deciding to include them.
llvm_check_compiler_linker_flag(C "-nostdlib++" C_SUPPORTS_NOSTDLIBXX_FLAG)
if (C_SUPPORTS_NOSTDLIBXX_FLAG)
llvm_check_compiler_linker_flag(CXX "-nostdlib++" CXX_SUPPORTS_NOSTDLIBXX_FLAG)
if (CXX_SUPPORTS_NOSTDLIBXX_FLAG)
set(CMAKE_REQUIRED_FLAGS "${CMAKE_REQUIRED_FLAGS} -nostdlib++")
endif()
check_c_compiler_flag(-nostdinc++ C_SUPPORTS_NOSTDINCXX_FLAG)
if (C_SUPPORTS_NOSTDINCXX_FLAG)
check_cxx_compiler_flag(-nostdinc++ CXX_SUPPORTS_NOSTDINCXX_FLAG)
if (CXX_SUPPORTS_NOSTDINCXX_FLAG)
set(CMAKE_REQUIRED_FLAGS "${CMAKE_REQUIRED_FLAGS} -nostdinc++")
endif()

Expand Down

0 comments on commit 758b527

Please sign in to comment.