Skip to content

Commit c59cc2b

Browse files
authored
[libunwind] Remove checks for -nostdlib++ (#143162)
libunwind uses a C linker, so it's never even trying to link against any C++ libraries. This removes the code which tries to drop C++ libraries, which makes the CMake configuration simpler and allows for upgrading GCC.
1 parent 9797b5f commit c59cc2b

File tree

2 files changed

+0
-68
lines changed

2 files changed

+0
-68
lines changed

libunwind/cmake/config-ix.cmake

Lines changed: 0 additions & 56 deletions
Original file line numberDiff line numberDiff line change
@@ -26,62 +26,6 @@ if (NOT LIBUNWIND_USE_COMPILER_RT)
2626
endif ()
2727
endif()
2828

29-
# libunwind is using -nostdlib++ at the link step when available,
30-
# otherwise -nodefaultlibs is used. We want all our checks to also
31-
# use one of these options, otherwise we may end up with an inconsistency between
32-
# the flags we think we require during configuration (if the checks are
33-
# performed without one of those options) and the flags that are actually
34-
# required during compilation (which has the -nostdlib++ or -nodefaultlibs). libc is
35-
# required for the link to go through. We remove sanitizers from the
36-
# configuration checks to avoid spurious link errors.
37-
38-
llvm_check_compiler_linker_flag(CXX "-nostdlib++" CXX_SUPPORTS_NOSTDLIBXX_FLAG)
39-
if (CXX_SUPPORTS_NOSTDLIBXX_FLAG)
40-
set(CMAKE_REQUIRED_FLAGS "${CMAKE_REQUIRED_FLAGS} -nostdlib++")
41-
else()
42-
llvm_check_compiler_linker_flag(C "-nodefaultlibs" C_SUPPORTS_NODEFAULTLIBS_FLAG)
43-
if (C_SUPPORTS_NODEFAULTLIBS_FLAG)
44-
set(CMAKE_REQUIRED_FLAGS "${CMAKE_REQUIRED_FLAGS} -nodefaultlibs")
45-
endif()
46-
endif()
47-
48-
# Only link against compiler-rt manually if we use -nodefaultlibs, since
49-
# otherwise the compiler will do the right thing on its own.
50-
if (NOT CXX_SUPPORTS_NOSTDLIBXX_FLAG AND C_SUPPORTS_NODEFAULTLIBS_FLAG)
51-
if (LIBUNWIND_HAS_C_LIB)
52-
list(APPEND CMAKE_REQUIRED_LIBRARIES c)
53-
endif ()
54-
if (LIBUNWIND_HAS_ROOT_LIB)
55-
list(APPEND CMAKE_REQUIRED_LIBRARIES root)
56-
endif ()
57-
if (LIBUNWIND_USE_COMPILER_RT)
58-
include(HandleCompilerRT)
59-
find_compiler_rt_library(builtins LIBUNWIND_BUILTINS_LIBRARY
60-
FLAGS ${LIBUNWIND_COMPILE_FLAGS})
61-
list(APPEND CMAKE_REQUIRED_LIBRARIES "${LIBUNWIND_BUILTINS_LIBRARY}")
62-
else ()
63-
if (LIBUNWIND_HAS_GCC_S_LIB)
64-
list(APPEND CMAKE_REQUIRED_LIBRARIES gcc_s)
65-
endif ()
66-
if (LIBUNWIND_HAS_GCC_LIB)
67-
list(APPEND CMAKE_REQUIRED_LIBRARIES gcc)
68-
endif ()
69-
endif ()
70-
if (MINGW)
71-
# Mingw64 requires quite a few "C" runtime libraries in order for basic
72-
# programs to link successfully with -nodefaultlibs.
73-
if (LIBUNWIND_USE_COMPILER_RT)
74-
set(MINGW_RUNTIME ${LIBUNWIND_BUILTINS_LIBRARY})
75-
else ()
76-
set(MINGW_RUNTIME gcc_s gcc)
77-
endif()
78-
set(MINGW_LIBRARIES mingw32 ${MINGW_RUNTIME} moldname mingwex msvcrt advapi32
79-
shell32 user32 kernel32 mingw32 ${MINGW_RUNTIME}
80-
moldname mingwex msvcrt)
81-
list(APPEND CMAKE_REQUIRED_LIBRARIES ${MINGW_LIBRARIES})
82-
endif()
83-
endif()
84-
8529
if (CXX_SUPPORTS_NOSTDLIBXX_FLAG OR C_SUPPORTS_NODEFAULTLIBS_FLAG)
8630
if (CMAKE_C_FLAGS MATCHES -fsanitize OR CMAKE_CXX_FLAGS MATCHES -fsanitize)
8731
set(CMAKE_REQUIRED_FLAGS "${CMAKE_REQUIRED_FLAGS} -fno-sanitize=all")

libunwind/src/CMakeLists.txt

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -71,18 +71,6 @@ set(LIBUNWIND_SOURCES
7171
${LIBUNWIND_ASM_SOURCES})
7272

7373
# Generate library list.
74-
if (CXX_SUPPORTS_NOSTDLIBXX_FLAG)
75-
add_link_flags_if_supported(-nostdlib++)
76-
else()
77-
if (LIBUNWIND_USE_COMPILER_RT)
78-
add_library_flags("${LIBUNWIND_BUILTINS_LIBRARY}")
79-
else()
80-
add_library_flags_if(LIBUNWIND_HAS_GCC_S_LIB gcc_s)
81-
add_library_flags_if(LIBUNWIND_HAS_GCC_LIB gcc)
82-
endif()
83-
add_library_flags_if(LIBUNWIND_HAS_C_LIB c)
84-
endif()
85-
8674
if (NOT APPLE)
8775
add_library_flags_if(LIBUNWIND_HAS_DL_LIB dl)
8876
endif()

0 commit comments

Comments
 (0)