[cfe-commits] r160931 - in /cfe/trunk: lib/Driver/Tools.cpp test/Driver/freebsd.c
David Chisnall
csdavec at swan.ac.uk
Sun Jul 29 08:24:45 PDT 2012
Author: theraven
Date: Sun Jul 29 10:24:44 2012
New Revision: 160931
URL: http://llvm.org/viewvc/llvm-project?rev=160931&view=rev
Log:
Provide correct linker command line options on FreeBSD 8 (GNU ld 2.15) and on newer FreeBSD (GNU ld 2.17).
Patch by Dimitry Andric!
Modified:
cfe/trunk/lib/Driver/Tools.cpp
cfe/trunk/test/Driver/freebsd.c
Modified: cfe/trunk/lib/Driver/Tools.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/Tools.cpp?rev=160931&r1=160930&r2=160931&view=diff
==============================================================================
--- cfe/trunk/lib/Driver/Tools.cpp (original)
+++ cfe/trunk/lib/Driver/Tools.cpp Sun Jul 29 10:24:44 2012
@@ -5003,8 +5003,14 @@
const char *LinkingOutput) const {
const Driver &D = getToolChain().getDriver();
ArgStringList CmdArgs;
- CmdArgs.push_back("--hash-style=both");
- CmdArgs.push_back("--enable-new-dtags");
+
+ // Silence warning for "clang -g foo.o -o foo"
+ Args.ClaimAllArgs(options::OPT_g_Group);
+ // and "clang -emit-llvm foo.o -o foo"
+ Args.ClaimAllArgs(options::OPT_emit_llvm);
+ // and for "clang -w foo.o -o foo". Other warning options are already
+ // handled somewhere else.
+ Args.ClaimAllArgs(options::OPT_w);
if (!D.SysRoot.empty())
CmdArgs.push_back(Args.MakeArgString("--sysroot=" + D.SysRoot));
@@ -5021,6 +5027,14 @@
CmdArgs.push_back("-dynamic-linker");
CmdArgs.push_back("/libexec/ld-elf.so.1");
}
+ if (getToolChain().getTriple().getOSMajorVersion() >= 9) {
+ llvm::Triple::ArchType Arch = getToolChain().getArch();
+ if (Arch == llvm::Triple::arm || Arch == llvm::Triple::sparc ||
+ Arch == llvm::Triple::x86 || Arch == llvm::Triple::x86_64) {
+ CmdArgs.push_back("--hash-style=both");
+ }
+ }
+ CmdArgs.push_back("--enable-new-dtags");
}
// When building 32-bit code on FreeBSD/amd64, we have to explicitly
@@ -5432,7 +5446,7 @@
Args.ClaimAllArgs(options::OPT_g_Group);
// and "clang -emit-llvm foo.o -o foo"
Args.ClaimAllArgs(options::OPT_emit_llvm);
- // and for "clang -g foo.o -o foo". Other warning options are already
+ // and for "clang -w foo.o -o foo". Other warning options are already
// handled somewhere else.
Args.ClaimAllArgs(options::OPT_w);
Modified: cfe/trunk/test/Driver/freebsd.c
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/freebsd.c?rev=160931&r1=160930&r2=160931&view=diff
==============================================================================
--- cfe/trunk/test/Driver/freebsd.c (original)
+++ cfe/trunk/test/Driver/freebsd.c Sun Jul 29 10:24:44 2012
@@ -32,7 +32,15 @@
// Check that the new linker flags are passed to FreeBSD
// RUN: %clang -no-canonical-prefixes -target x86_64-pc-freebsd8 -m32 %s \
// RUN: --sysroot=%S/Inputs/multiarch_freebsd64_tree -### 2>&1 \
-// RUN: | FileCheck --check-prefix=CHECK-LDFLAGS %s
-// CHECK-LDFLAGS: --hash-style=both
-// CHECK-LDFLAGS: --enable-new-dtags
+// RUN: | FileCheck --check-prefix=CHECK-LDFLAGS8 %s
+// RUN: %clang -no-canonical-prefixes -target x86_64-pc-freebsd9 -m32 %s \
+// RUN: --sysroot=%S/Inputs/multiarch_freebsd64_tree -### 2>&1 \
+// RUN: | FileCheck --check-prefix=CHECK-LDFLAGS9 %s
+// RUN: %clang -no-canonical-prefixes -target x86_64-pc-freebsd10.0 -m32 %s \
+// RUN: --sysroot=%S/Inputs/multiarch_freebsd64_tree -### 2>&1 \
+// RUN: | FileCheck --check-prefix=CHECK-LDFLAGS9 %s
+// CHECK-LDFLAGS8-NOT: --hash-style=both
+// CHECK-LDFLAGS8: --enable-new-dtags
+// CHECK-LDFLAGS9: --hash-style=both
+// CHECK-LDFLAGS9: --enable-new-dtags
More information about the cfe-commits
mailing list