[clang] b084d10 - [Driver] Wrap -lgcc_s in -z ignore/-z record on Solaris (#65487)
via cfe-commits
cfe-commits at lists.llvm.org
Wed Sep 6 10:44:43 PDT 2023
Author: rorth
Date: 2023-09-06T19:44:39+02:00
New Revision: b084d10c2898e4a9da7348cd4774f4fe409fe83c
URL: https://github.com/llvm/llvm-project/commit/b084d10c2898e4a9da7348cd4774f4fe409fe83c
DIFF: https://github.com/llvm/llvm-project/commit/b084d10c2898e4a9da7348cd4774f4fe409fe83c.diff
LOG: [Driver] Wrap -lgcc_s in -z ignore/-z record on Solaris (#65487)
`clang` currently links `libgcc_s` unconditionally on Solaris, which is
unnecessary.
This patch wraps it in `-z ignore`/`-z record` instead.
Tested on `amd64-pc-solaris2.11` and `x86_64-pc-linux-gnu`.
Added:
Modified:
clang/lib/Driver/ToolChains/Solaris.cpp
clang/test/Driver/solaris-ld.c
Removed:
################################################################################
diff --git a/clang/lib/Driver/ToolChains/Solaris.cpp b/clang/lib/Driver/ToolChains/Solaris.cpp
index a22e4c2e47b87e..4738279f85d6c3 100644
--- a/clang/lib/Driver/ToolChains/Solaris.cpp
+++ b/clang/lib/Driver/ToolChains/Solaris.cpp
@@ -244,7 +244,9 @@ void solaris::Linker::ConstructJob(Compilation &C, const JobAction &JA,
CmdArgs.push_back("-latomic");
addAsNeededOption(getToolChain(), Args, CmdArgs, false);
}
+ addAsNeededOption(getToolChain(), Args, CmdArgs, true);
CmdArgs.push_back("-lgcc_s");
+ addAsNeededOption(getToolChain(), Args, CmdArgs, false);
CmdArgs.push_back("-lc");
if (!Args.hasArg(options::OPT_shared)) {
CmdArgs.push_back("-lgcc");
diff --git a/clang/test/Driver/solaris-ld.c b/clang/test/Driver/solaris-ld.c
index 096ecadbbd60a6..231e14966ea42f 100644
--- a/clang/test/Driver/solaris-ld.c
+++ b/clang/test/Driver/solaris-ld.c
@@ -22,7 +22,8 @@
// CHECK-LD-SPARC32-SAME: "-L[[SYSROOT]]/usr/lib"
// CHECK-LD: "-z" "ignore" "-latomic" "-z" "record"
// CHECK-GLD: "--as-needed" "-latomic" "--no-as-needed"
-// CHECK-LD-SPARC32-SAME: "-lgcc_s"
+// CHECK-LD: "-z" "ignore" "-lgcc_s" "-z" "record"
+// CHECK-GLD: "--as-needed" "-lgcc_s" "--no-as-needed"
// CHECK-LD-SPARC32-SAME: "-lc"
// CHECK-LD-SPARC32-SAME: "-lgcc"
// CHECK-LD-SPARC32-SAME: "-lm"
More information about the cfe-commits
mailing list