diff options
author | David Chisnall <csdavec@swan.ac.uk> | 2012-07-29 15:24:44 +0000 |
---|---|---|
committer | David Chisnall <csdavec@swan.ac.uk> | 2012-07-29 15:24:44 +0000 |
commit | dfa210b1e1e403855557f68fe471212787b8540e (patch) | |
tree | 27c21c7aae92a53d6366a51202a6dea5adf009ea | |
parent | b2efdf3e92f986956f0a755ba815f3870838583b (diff) |
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!
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@160931 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r-- | lib/Driver/Tools.cpp | 20 | ||||
-rw-r--r-- | test/Driver/freebsd.c | 14 |
2 files changed, 28 insertions, 6 deletions
diff --git a/lib/Driver/Tools.cpp b/lib/Driver/Tools.cpp index df1d5bfec7..54f209d7d9 100644 --- a/lib/Driver/Tools.cpp +++ b/lib/Driver/Tools.cpp @@ -5003,8 +5003,14 @@ void freebsd::Link::ConstructJob(Compilation &C, const JobAction &JA, 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 @@ void freebsd::Link::ConstructJob(Compilation &C, const JobAction &JA, 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 @@ void linuxtools::Link::ConstructJob(Compilation &C, const JobAction &JA, 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); diff --git a/test/Driver/freebsd.c b/test/Driver/freebsd.c index 69da7c9b5e..642c60ce77 100644 --- a/test/Driver/freebsd.c +++ b/test/Driver/freebsd.c @@ -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 |