summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDouglas Katzman <dougk@google.com>2015-11-18 16:24:46 +0000
committerDouglas Katzman <dougk@google.com>2015-11-18 16:24:46 +0000
commit674a31243bebfab1aaf3897e07108147f90c54b8 (patch)
tree6e24867a94bf1695851db7330e24750c22ec21cf
parentc02670ed50f009eeb24ad7f0fe00cbf887e008d0 (diff)
downloadbcm5719-llvm-674a31243bebfab1aaf3897e07108147f90c54b8.tar.gz
bcm5719-llvm-674a31243bebfab1aaf3897e07108147f90c54b8.zip
[Myriad]: insert -L paths into linker cmd only when they exist.
Differential Revision: http://reviews.llvm.org/D14754 llvm-svn: 253467
-rw-r--r--clang/lib/Driver/ToolChains.cpp41
-rw-r--r--clang/lib/Driver/ToolChains.h2
-rw-r--r--clang/lib/Driver/Tools.cpp18
-rw-r--r--clang/test/Driver/Inputs/basic_myriad_tree/lib/gcc/sparc-myriad-elf/4.8.2/crtend.o0
-rw-r--r--clang/test/Driver/Inputs/basic_myriad_tree/lib/gcc/sparc-myriad-elf/4.8.2/crti.o0
-rw-r--r--clang/test/Driver/Inputs/basic_myriad_tree/lib/gcc/sparc-myriad-elf/4.8.2/crtn.o0
-rw-r--r--clang/test/Driver/Inputs/basic_myriad_tree/sparc-myriad-elf/lib/crt0.o0
7 files changed, 25 insertions, 36 deletions
diff --git a/clang/lib/Driver/ToolChains.cpp b/clang/lib/Driver/ToolChains.cpp
index 78a611e56d4..8485d0fe945 100644
--- a/clang/lib/Driver/ToolChains.cpp
+++ b/clang/lib/Driver/ToolChains.cpp
@@ -4367,6 +4367,26 @@ MyriadToolChain::MyriadToolChain(const Driver &D, const llvm::Triple &Triple,
case llvm::Triple::shave:
GCCInstallation.init(Triple, Args, {"sparc-myriad-elf"});
}
+
+ if (GCCInstallation.isValid()) {
+ // The contents of LibDir are independent of the version of gcc.
+ // This contains libc, libg (a superset of libc), libm, libstdc++, libssp.
+ SmallString<128> LibDir(GCCInstallation.getParentLibPath());
+ if (Triple.getArch() == llvm::Triple::sparcel)
+ llvm::sys::path::append(LibDir, "../sparc-myriad-elf/lib/le");
+ else
+ llvm::sys::path::append(LibDir, "../sparc-myriad-elf/lib");
+ addPathIfExists(D, LibDir, getFilePaths());
+
+ // This directory contains crt{i,n,begin,end}.o as well as libgcc.
+ // These files are tied to a particular version of gcc.
+ SmallString<128> CompilerSupportDir(GCCInstallation.getInstallPath());
+ // There are actually 4 choices: {le,be} x {fpu,nofpu}
+ // but as this toolchain is for LEON sparc, it can assume FPU.
+ if (Triple.getArch() == llvm::Triple::sparcel)
+ llvm::sys::path::append(CompilerSupportDir, "le");
+ addPathIfExists(D, CompilerSupportDir, getFilePaths());
+ }
}
MyriadToolChain::~MyriadToolChain() {}
@@ -4413,27 +4433,6 @@ Tool *MyriadToolChain::SelectTool(const JobAction &JA) const {
}
}
-void MyriadToolChain::getCompilerSupportDir(std::string &Dir) const {
- // This directory contains crt{i,n,begin,end}.o as well as libgcc.
- // These files are tied to a particular version of gcc.
- SmallString<128> Result(GCCInstallation.getInstallPath());
- // There are actually 4 choices: {le,be} x {fpu,nofpu}
- // but as this toolchain is for LEON sparc, it can assume FPU.
- if (this->getTriple().getArch() == llvm::Triple::sparcel)
- llvm::sys::path::append(Result, "le");
- Dir.assign(Result.str());
-}
-void MyriadToolChain::getBuiltinLibDir(std::string &Dir) const {
- // The contents of LibDir are independent of the version of gcc.
- // This contains libc, libg (a superset of libc), libm, libstdc++, libssp.
- SmallString<128> Result(GCCInstallation.getParentLibPath());
- if (this->getTriple().getArch() == llvm::Triple::sparcel)
- llvm::sys::path::append(Result, "../sparc-myriad-elf/lib/le");
- else
- llvm::sys::path::append(Result, "../sparc-myriad-elf/lib");
- Dir.assign(Result.str());
-}
-
Tool *MyriadToolChain::buildLinker() const {
return new tools::Myriad::Linker(*this);
}
diff --git a/clang/lib/Driver/ToolChains.h b/clang/lib/Driver/ToolChains.h
index 2b655f62bdd..bda74d4d2cf 100644
--- a/clang/lib/Driver/ToolChains.h
+++ b/clang/lib/Driver/ToolChains.h
@@ -1068,8 +1068,6 @@ public:
const llvm::opt::ArgList &DriverArgs,
llvm::opt::ArgStringList &CC1Args) const override;
Tool *SelectTool(const JobAction &JA) const override;
- void getCompilerSupportDir(std::string &Dir) const;
- void getBuiltinLibDir(std::string &Dir) const;
unsigned GetDefaultDwarfVersion() const override { return 2; }
protected:
diff --git a/clang/lib/Driver/Tools.cpp b/clang/lib/Driver/Tools.cpp
index 2685687ba69..d951a48510a 100644
--- a/clang/lib/Driver/Tools.cpp
+++ b/clang/lib/Driver/Tools.cpp
@@ -9945,10 +9945,6 @@ void tools::Myriad::Linker::ConstructJob(Compilation &C, const JobAction &JA,
bool UseDefaultLibs =
!Args.hasArg(options::OPT_nostdlib, options::OPT_nodefaultlibs);
- std::string StartFilesDir, BuiltinLibDir;
- TC.getCompilerSupportDir(StartFilesDir);
- TC.getBuiltinLibDir(BuiltinLibDir);
-
if (T.getArch() == llvm::Triple::sparc)
CmdArgs.push_back("-EB");
else // SHAVE assumes little-endian, and sparcel is expressly so.
@@ -9972,19 +9968,15 @@ void tools::Myriad::Linker::ConstructJob(Compilation &C, const JobAction &JA,
if (UseStartfiles) {
// If you want startfiles, it means you want the builtin crti and crtbegin,
// but not crt0. Myriad link commands provide their own crt0.o as needed.
- CmdArgs.push_back(Args.MakeArgString(StartFilesDir + "/crti.o"));
- CmdArgs.push_back(Args.MakeArgString(StartFilesDir + "/crtbegin.o"));
+ CmdArgs.push_back(Args.MakeArgString(TC.GetFilePath("crti.o")));
+ CmdArgs.push_back(Args.MakeArgString(TC.GetFilePath("crtbegin.o")));
}
Args.AddAllArgs(CmdArgs, {options::OPT_L, options::OPT_T_Group,
options::OPT_e, options::OPT_s, options::OPT_t,
options::OPT_Z_Flag, options::OPT_r});
- // The linker doesn't use these builtin paths unless directed to,
- // because it was not compiled for support with sysroots, nor does
- // it have a default of little-endian with FPU.
- CmdArgs.push_back(Args.MakeArgString("-L" + BuiltinLibDir));
- CmdArgs.push_back(Args.MakeArgString("-L" + StartFilesDir));
+ TC.AddFilePathLibArgs(Args, CmdArgs);
AddLinkerInputs(getToolChain(), Inputs, Args, CmdArgs);
@@ -10004,8 +9996,8 @@ void tools::Myriad::Linker::ConstructJob(Compilation &C, const JobAction &JA,
CmdArgs.push_back("-lgcc");
}
if (UseStartfiles) {
- CmdArgs.push_back(Args.MakeArgString(StartFilesDir + "/crtend.o"));
- CmdArgs.push_back(Args.MakeArgString(StartFilesDir + "/crtn.o"));
+ CmdArgs.push_back(Args.MakeArgString(TC.GetFilePath("crtend.o")));
+ CmdArgs.push_back(Args.MakeArgString(TC.GetFilePath("crtn.o")));
}
std::string Exec =
diff --git a/clang/test/Driver/Inputs/basic_myriad_tree/lib/gcc/sparc-myriad-elf/4.8.2/crtend.o b/clang/test/Driver/Inputs/basic_myriad_tree/lib/gcc/sparc-myriad-elf/4.8.2/crtend.o
new file mode 100644
index 00000000000..e69de29bb2d
--- /dev/null
+++ b/clang/test/Driver/Inputs/basic_myriad_tree/lib/gcc/sparc-myriad-elf/4.8.2/crtend.o
diff --git a/clang/test/Driver/Inputs/basic_myriad_tree/lib/gcc/sparc-myriad-elf/4.8.2/crti.o b/clang/test/Driver/Inputs/basic_myriad_tree/lib/gcc/sparc-myriad-elf/4.8.2/crti.o
new file mode 100644
index 00000000000..e69de29bb2d
--- /dev/null
+++ b/clang/test/Driver/Inputs/basic_myriad_tree/lib/gcc/sparc-myriad-elf/4.8.2/crti.o
diff --git a/clang/test/Driver/Inputs/basic_myriad_tree/lib/gcc/sparc-myriad-elf/4.8.2/crtn.o b/clang/test/Driver/Inputs/basic_myriad_tree/lib/gcc/sparc-myriad-elf/4.8.2/crtn.o
new file mode 100644
index 00000000000..e69de29bb2d
--- /dev/null
+++ b/clang/test/Driver/Inputs/basic_myriad_tree/lib/gcc/sparc-myriad-elf/4.8.2/crtn.o
diff --git a/clang/test/Driver/Inputs/basic_myriad_tree/sparc-myriad-elf/lib/crt0.o b/clang/test/Driver/Inputs/basic_myriad_tree/sparc-myriad-elf/lib/crt0.o
new file mode 100644
index 00000000000..e69de29bb2d
--- /dev/null
+++ b/clang/test/Driver/Inputs/basic_myriad_tree/sparc-myriad-elf/lib/crt0.o
OpenPOWER on IntegriCloud