diff --git a/clang/lib/Driver/ToolChains/Solaris.cpp b/clang/lib/Driver/ToolChains/Solaris.cpp index a22e4c2e47b8..4738279f85d6 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 096ecadbbd60..231e14966ea4 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"