r247603 - [Solaris] Add -lc also when linking shared libraries
Rafael Espindola via cfe-commits
cfe-commits at lists.llvm.org
Mon Sep 14 12:30:53 PDT 2015
Author: rafael
Date: Mon Sep 14 14:30:53 2015
New Revision: 247603
URL: http://llvm.org/viewvc/llvm-project?rev=247603&view=rev
Log:
[Solaris] Add -lc also when linking shared libraries
This is actually needed, otherwise libc won't be added at all. For
instance when building libclang.so all the libc symbols won't be
found, with ld warning about libc being an "implicit dependency".
Patch by Xan López!
Modified:
cfe/trunk/lib/Driver/Tools.cpp
cfe/trunk/test/Driver/solaris-ld.c
Modified: cfe/trunk/lib/Driver/Tools.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/Tools.cpp?rev=247603&r1=247602&r2=247603&view=diff
==============================================================================
--- cfe/trunk/lib/Driver/Tools.cpp (original)
+++ cfe/trunk/lib/Driver/Tools.cpp Mon Sep 14 14:30:53 2015
@@ -6962,9 +6962,9 @@ void solaris::Linker::ConstructJob(Compi
if (getToolChain().getDriver().CCCIsCXX())
getToolChain().AddCXXStdlibLibArgs(Args, CmdArgs);
CmdArgs.push_back("-lgcc_s");
+ CmdArgs.push_back("-lc");
if (!Args.hasArg(options::OPT_shared)) {
CmdArgs.push_back("-lgcc");
- CmdArgs.push_back("-lc");
CmdArgs.push_back("-lm");
}
}
Modified: cfe/trunk/test/Driver/solaris-ld.c
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/solaris-ld.c?rev=247603&r1=247602&r2=247603&view=diff
==============================================================================
--- cfe/trunk/test/Driver/solaris-ld.c (original)
+++ cfe/trunk/test/Driver/solaris-ld.c Mon Sep 14 14:30:53 2015
@@ -14,3 +14,20 @@
// CHECK: "{{.*}}/usr/gcc/4.8/lib/gcc/sparc-sun-solaris2.11/4.8.2{{/|\\\\}}crtbegin.o"
// CHECK: "{{.*}}/usr/gcc/4.8/lib/gcc/sparc-sun-solaris2.11/4.8.2{{/|\\\\}}crtend.o"
// CHECK: "{{.*}}/usr/lib/crtn.o"
+// CHECK "-lc"
+// CHECK "-lgcc_s"
+// CHECK "-lgcc"
+// CHECK "-lm"
+
+// Check the right -l flags are present with -shared
+// RUN: %clang -no-canonical-prefixes %s -### -o %t.o -shared 2>&1 \
+// RUN: --target=sparc-sun-solaris2.11 \
+// RUN: --gcc-toolchain="" \
+// RUN: --sysroot=%S/Inputs/sparc-sun-solaris2.11 \
+// RUN: | FileCheck --check-prefix=CHECK-SHARED %s
+
+// CHECK-SHARED: ld{{.*}}"
+// CHECK-SHARED "-lc"
+// CHECK-SHARED "-lgcc_s"
+// CHECK-SHARED-NOT "-lgcc"
+// CHECK-SHARED-NOT: "-lm"
More information about the cfe-commits
mailing list