[libcxx-commits] [PATCH] D112112: [libunwind] Link with -unwindlib=none

Harald van Dijk via Phabricator via libcxx-commits libcxx-commits at lists.llvm.org
Tue Oct 19 16:56:44 PDT 2021


hvdijk created this revision.
hvdijk added reviewers: ldionne, mstorsjo.
hvdijk added a project: libunwind.
Herald added subscribers: libcxx-commits, mgorny.
Herald added a reviewer: libunwind.
hvdijk requested review of this revision.
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.

When D95875 <https://reviews.llvm.org/D95875> changed libunwind to link using -nostdlib++ rather than -nodefaultlibs, that missed that clang may now implicitly try to link libunwind against itself. Add -unwindlib=none to avoid that.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D112112

Files:
  libunwind/cmake/config-ix.cmake
  libunwind/src/CMakeLists.txt


Index: libunwind/src/CMakeLists.txt
===================================================================
--- libunwind/src/CMakeLists.txt
+++ libunwind/src/CMakeLists.txt
@@ -83,8 +83,8 @@
 endif()
 
 # Setup flags.
-if (LIBUNWIND_SUPPORTS_NOSTDLIBXX_FLAG)
-  add_link_flags_if_supported(-nostdlib++)
+if (LIBUNWIND_SUPPORTS_NOSTDLIBXX_FLAG AND LIBUNWIND_SUPPORTS_UNWINDLIB_EQ_NONE_FLAG)
+  add_link_flags_if_supported(-nostdlib++ -unwindlib=none)
 else()
   add_link_flags_if_supported(-nodefaultlibs)
 endif()
Index: libunwind/cmake/config-ix.cmake
===================================================================
--- libunwind/cmake/config-ix.cmake
+++ libunwind/cmake/config-ix.cmake
@@ -26,8 +26,9 @@
 # configuration checks to avoid spurious link errors.
 
 check_c_compiler_flag(-nostdlib++ LIBUNWIND_SUPPORTS_NOSTDLIBXX_FLAG)
-if (LIBUNWIND_SUPPORTS_NOSTDLIBXX_FLAG)
-  set(CMAKE_REQUIRED_FLAGS "${CMAKE_REQUIRED_FLAGS} -nostdlib++")
+check_c_compiler_flag(-unwindlib=none LIBUNWIND_SUPPORTS_UNWINDLIB_EQ_NONE_FLAG)
+if (LIBUNWIND_SUPPORTS_NOSTDLIBXX_FLAG AND LIBUNWIND_SUPPORTS_UNWINDLIB_EQ_NONE_FLAG)
+  set(CMAKE_REQUIRED_FLAGS "${CMAKE_REQUIRED_FLAGS} -nostdlib++ -unwindlib=none")
 else()
   check_c_compiler_flag(-nodefaultlibs LIBUNWIND_SUPPORTS_NODEFAULTLIBS_FLAG)
   if (LIBUNWIND_SUPPORTS_NODEFAULTLIBS_FLAG)


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D112112.380826.patch
Type: text/x-patch
Size: 1329 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/libcxx-commits/attachments/20211019/e836c033/attachment.bin>


More information about the libcxx-commits mailing list