diff options
author | Chandler Carruth <chandlerc@gmail.com> | 2012-01-31 02:21:20 +0000 |
---|---|---|
committer | Chandler Carruth <chandlerc@gmail.com> | 2012-01-31 02:21:20 +0000 |
commit | 1d16f0f805c2a3e2198a87154990347b2759f6bd (patch) | |
tree | 7afce7b50a405477874544763ef4a98a8338f373 /lib/Driver/Driver.cpp | |
parent | b9b0f6fb6e113b5e6be3ed9754c4bf01186a17bf (diff) |
Revert r149083 which is not the direction we're going in the Clang
driver based on discussions with Doug Gregor. There are several issues:
1) The patch was not reviewed prior to commit and there were review comments.
2) The design of the functionality (triple-prefixed tool invocation)
isn't the design we want for Clang going forward: it focuses on the
"user triple" rather than on the "toolchain triple", and forces that
bit of state into the API of every single toolchain instead of
handling it automatically in the common base classes.
3) The tests provided are not stable. They fail on a few Linux variants
(Gentoo among them) and on mingw32 and some other environments.
I *am* interested in the Clang driver being able to invoke
triple-prefixed tools, but we need to design that feature the right way.
This patch just extends the previous hack without fixing the underlying
problems with it. I'm working on a new design for this that I will mail
for review by tomorrow.
I am aware that this removes functionality that NetBSD relies on, but
this is ToT, not a release. This functionality hasn't been properly
designed, implemented, and tested yet. We can't "regress" until we get
something that really works, both with the immediate use cases and with
long term maintenance of the Clang driver.
For reference, the original commit log:
Keep track of the original target the user specified before
normalization. This used to be captured in DefaultTargetTriple and is
used for the (optional) $triple-$tool lookup for cross-compilation.
Do this properly by making it an attribute of the toolchain and use it
in combination with the computed triple as index for the toolchain
lookup.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@149337 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Driver/Driver.cpp')
-rw-r--r-- | lib/Driver/Driver.cpp | 46 |
1 files changed, 22 insertions, 24 deletions
diff --git a/lib/Driver/Driver.cpp b/lib/Driver/Driver.cpp index 10e2fd970b..7c26a0ef15 100644 --- a/lib/Driver/Driver.cpp +++ b/lib/Driver/Driver.cpp @@ -1507,7 +1507,7 @@ static bool isPathExecutable(llvm::sys::Path &P, bool WantFile) { std::string Driver::GetProgramPath(const char *Name, const ToolChain &TC, bool WantFile) const { - std::string TargetSpecificExecutable(TC.getUserTriple() + "-" + Name); + std::string TargetSpecificExecutable(DefaultTargetTriple + "-" + Name); // Respect a limited subset of the '-Bprefix' functionality in GCC by // attempting to use this prefix when lokup up program paths. for (Driver::prefix_list::const_iterator it = PrefixDirs.begin(), @@ -1574,10 +1574,13 @@ std::string Driver::GetTemporaryPath(StringRef Prefix, const char *Suffix) /// /// This routine provides the logic to compute a target triple from various /// args passed to the driver and the default triple string. -static llvm::Triple computeTargetTriple(StringRef TargetTriple, +static llvm::Triple computeTargetTriple(StringRef DefaultTargetTriple, const ArgList &Args, StringRef DarwinArchName) { - llvm::Triple Target(llvm::Triple::normalize(TargetTriple)); + if (const Arg *A = Args.getLastArg(options::OPT_target)) + DefaultTargetTriple = A->getValue(Args); + + llvm::Triple Target(llvm::Triple::normalize(DefaultTargetTriple)); // Handle Darwin-specific options available here. if (Target.isOSDarwin()) { @@ -1624,19 +1627,14 @@ static llvm::Triple computeTargetTriple(StringRef TargetTriple, const ToolChain &Driver::getToolChain(const ArgList &Args, StringRef DarwinArchName) const { - std::string TargetTriple(DefaultTargetTriple); - if (const Arg *A = Args.getLastArg(options::OPT_target)) - TargetTriple = A->getValue(Args); - - llvm::Triple Target = computeTargetTriple(TargetTriple, Args, DarwinArchName); - - std::string TargetIndex = TargetTriple + "::" + Target.str(); + llvm::Triple Target = computeTargetTriple(DefaultTargetTriple, Args, + DarwinArchName); - ToolChain *&TC = ToolChains[TargetIndex]; + ToolChain *&TC = ToolChains[Target.str()]; if (!TC) { switch (Target.getOS()) { case llvm::Triple::AuroraUX: - TC = new toolchains::AuroraUX(*this, Target, TargetTriple); + TC = new toolchains::AuroraUX(*this, Target); break; case llvm::Triple::Darwin: case llvm::Triple::MacOSX: @@ -1645,44 +1643,44 @@ const ToolChain &Driver::getToolChain(const ArgList &Args, Target.getArch() == llvm::Triple::x86_64 || Target.getArch() == llvm::Triple::arm || Target.getArch() == llvm::Triple::thumb) - TC = new toolchains::DarwinClang(*this, Target, TargetTriple); + TC = new toolchains::DarwinClang(*this, Target); else - TC = new toolchains::Darwin_Generic_GCC(*this, Target, TargetTriple); + TC = new toolchains::Darwin_Generic_GCC(*this, Target); break; case llvm::Triple::DragonFly: - TC = new toolchains::DragonFly(*this, Target, TargetTriple); + TC = new toolchains::DragonFly(*this, Target); break; case llvm::Triple::OpenBSD: - TC = new toolchains::OpenBSD(*this, Target, TargetTriple); + TC = new toolchains::OpenBSD(*this, Target); break; case llvm::Triple::NetBSD: - TC = new toolchains::NetBSD(*this, Target, TargetTriple); + TC = new toolchains::NetBSD(*this, Target); break; case llvm::Triple::FreeBSD: - TC = new toolchains::FreeBSD(*this, Target, TargetTriple); + TC = new toolchains::FreeBSD(*this, Target); break; case llvm::Triple::Minix: - TC = new toolchains::Minix(*this, Target, TargetTriple); + TC = new toolchains::Minix(*this, Target); break; case llvm::Triple::Linux: if (Target.getArch() == llvm::Triple::hexagon) - TC = new toolchains::Hexagon_TC(*this, Target, TargetTriple); + TC = new toolchains::Hexagon_TC(*this, Target); else - TC = new toolchains::Linux(*this, Target, TargetTriple); + TC = new toolchains::Linux(*this, Target); break; case llvm::Triple::Win32: - TC = new toolchains::Windows(*this, Target, TargetTriple); + TC = new toolchains::Windows(*this, Target); break; case llvm::Triple::MinGW32: // FIXME: We need a MinGW toolchain. Fallthrough for now. default: // TCE is an OSless target if (Target.getArchName() == "tce") { - TC = new toolchains::TCEToolChain(*this, Target, TargetTriple); + TC = new toolchains::TCEToolChain(*this, Target); break; } - TC = new toolchains::Generic_GCC(*this, Target, TargetTriple); + TC = new toolchains::Generic_GCC(*this, Target); break; } } |