[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`.
This commit is contained in:
rorth 2023-09-06 19:44:39 +02:00 committed by GitHub
parent d1487670ee
commit b084d10c28
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 4 additions and 1 deletions

View File

@ -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");

View File

@ -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"