[llvm-branch-commits] [clang] 26e4d61 - [PATCH] ToolChain: Add -lgcc_s to the linker flags when using libc++

Nikita Popov via llvm-branch-commits llvm-branch-commits at lists.llvm.org
Tue May 3 01:15:45 PDT 2022


Author: serge-sans-paille
Date: 2022-05-03T10:05:28+02:00
New Revision: 26e4d61303313930e5f37dfd62a10406eb8133bd

URL: https://github.com/llvm/llvm-project/commit/26e4d61303313930e5f37dfd62a10406eb8133bd
DIFF: https://github.com/llvm/llvm-project/commit/26e4d61303313930e5f37dfd62a10406eb8133bd.diff

LOG: [PATCH] ToolChain: Add -lgcc_s to the linker flags when using libc++

The libc++ build for Fedora does not include an implementation of
libunwind, so we need to explicitly link against something that
provides this implementation.

Added: 
    

Modified: 
    clang/lib/Driver/ToolChain.cpp
    clang/test/Driver/netbsd.cpp

Removed: 
    


################################################################################
diff  --git a/clang/lib/Driver/ToolChain.cpp b/clang/lib/Driver/ToolChain.cpp
index d45a90048dcbe..991ad560d1519 100644
--- a/clang/lib/Driver/ToolChain.cpp
+++ b/clang/lib/Driver/ToolChain.cpp
@@ -968,6 +968,7 @@ void ToolChain::AddCXXStdlibLibArgs(const ArgList &Args,
   switch (Type) {
   case ToolChain::CST_Libcxx:
     CmdArgs.push_back("-lc++");
+    CmdArgs.push_back("-lgcc_s");
     break;
 
   case ToolChain::CST_Libstdcxx:

diff  --git a/clang/test/Driver/netbsd.cpp b/clang/test/Driver/netbsd.cpp
index 4af7d8373d672..ff18c627f5605 100644
--- a/clang/test/Driver/netbsd.cpp
+++ b/clang/test/Driver/netbsd.cpp
@@ -131,7 +131,7 @@
 // ARM-7: clang{{.*}}" "-cc1" "-triple" "armv5e-unknown-netbsd7.0.0-eabi"
 // ARM-7: ld{{.*}}" "--eh-frame-hdr" "-dynamic-linker" "/libexec/ld.elf_so"
 // ARM-7: "-o" "a.out" "{{.*}}/usr/lib{{/|\\\\}}crt0.o" "{{.*}}/usr/lib{{/|\\\\}}eabi{{/|\\\\}}crti.o"
-// ARM-7: "{{.*}}/usr/lib{{/|\\\\}}crtbegin.o" "{{.*}}.o" "-lc++" "-lm" "-lc"
+// ARM-7: "{{.*}}/usr/lib{{/|\\\\}}crtbegin.o" "{{.*}}.o" "-lc++" "-lgcc_s" "-lm" "-lc"
 // ARM-7: "{{.*}}/usr/lib{{/|\\\\}}crtend.o" "{{.*}}/usr/lib{{/|\\\\}}crtn.o"
 
 // AARCH64: clang{{.*}}" "-cc1" "-triple" "aarch64-unknown-netbsd"
@@ -250,7 +250,7 @@
 // S-ARM-7: clang{{.*}}" "-cc1" "-triple" "armv5e-unknown-netbsd7.0.0-eabi"
 // S-ARM-7: ld{{.*}}" "--eh-frame-hdr" "-Bstatic"
 // S-ARM-7: "-o" "a.out" "{{.*}}/usr/lib{{/|\\\\}}crt0.o" "{{.*}}/usr/lib{{/|\\\\}}eabi{{/|\\\\}}crti.o"
-// S-ARM-7: "{{.*}}/usr/lib{{/|\\\\}}crtbegin.o" "{{.*}}.o" "-lc++" "-lm" "-lc"
+// S-ARM-7: "{{.*}}/usr/lib{{/|\\\\}}crtbegin.o" "{{.*}}.o" "-lc++" "-lgcc_s" "-lm" "-lc"
 // S-ARM-7: "{{.*}}/usr/lib{{/|\\\\}}crtend.o" "{{.*}}/usr/lib{{/|\\\\}}crtn.o"
 
 // S-AARCH64: clang{{.*}}" "-cc1" "-triple" "aarch64-unknown-netbsd"


        


More information about the llvm-branch-commits mailing list