summaryrefslogtreecommitdiffstats
path: root/clang/lib/Driver/Driver.cpp
diff options
context:
space:
mode:
authorChandler Carruth <chandlerc@gmail.com>2012-01-24 19:17:46 +0000
committerChandler Carruth <chandlerc@gmail.com>2012-01-24 19:17:46 +0000
commit46f204fef8baf96161269fe403910dc11a125c2f (patch)
treec0006ccf281e812f169c8c871928209a9e9b18c8 /clang/lib/Driver/Driver.cpp
parent3ecbc3d655a9837915e5f8ec08782a1aac2a4ea4 (diff)
downloadbcm5719-llvm-46f204fef8baf96161269fe403910dc11a125c2f.tar.gz
bcm5719-llvm-46f204fef8baf96161269fe403910dc11a125c2f.zip
Start hoisting the logic for computing the target triple into its own
function. The logic for this, and I want to emphasize that this is the logic for computing the *target* triple, is currently scattered throughout various different HostInfo classes ToolChain factoring functions. Best part, it is largely *duplicated* there. The goal is to hoist all of that up to here where we can deal with it once, and in a consistent manner. Unfortunately, this uncovers more fun problems: the ToolChains assume that the *actual* target triple is the one passed into them by these factory functions, while the *host* triple is the one in the driver. This already was a lie, and a damn lie, when the '-target' flag was specified. It only really worked when the difference stemmed from '-m32' and '-m64' flags. I'll have to fix that (and remove all the FIXMEs I've introduced here to document the problem) before I can finish hoisting the target-calculation logic. It's bugs all the way down today it seems... llvm-svn: 148839
Diffstat (limited to 'clang/lib/Driver/Driver.cpp')
-rw-r--r--clang/lib/Driver/Driver.cpp22
1 files changed, 14 insertions, 8 deletions
diff --git a/clang/lib/Driver/Driver.cpp b/clang/lib/Driver/Driver.cpp
index c5007b820f9..217df02b7fd 100644
--- a/clang/lib/Driver/Driver.cpp
+++ b/clang/lib/Driver/Driver.cpp
@@ -237,6 +237,18 @@ DerivedArgList *Driver::TranslateInputArgs(const InputArgList &Args) const {
return DAL;
}
+/// \brief Compute target triple from args.
+///
+/// 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 DefaultTargetTriple,
+ const ArgList &Args) {
+ if (const Arg *A = Args.getLastArg(options::OPT_target))
+ DefaultTargetTriple = A->getValue(Args);
+
+ return llvm::Triple(llvm::Triple::normalize(DefaultTargetTriple));
+}
+
Compilation *Driver::BuildCompilation(ArrayRef<const char *> ArgList) {
llvm::PrettyStackTraceString CrashInfo("Compilation construction");
@@ -305,10 +317,6 @@ Compilation *Driver::BuildCompilation(ArrayRef<const char *> ArgList) {
Cur = Split.second;
}
}
- // FIXME: We shouldn't overwrite the default host triple here, but we have
- // nowhere else to put this currently.
- if (const Arg *A = Args->getLastArg(options::OPT_target))
- DefaultTargetTriple = A->getValue(*Args);
if (const Arg *A = Args->getLastArg(options::OPT_ccc_install_dir))
Dir = InstalledDir = A->getValue(*Args);
for (arg_iterator it = Args->filtered_begin(options::OPT_B),
@@ -322,10 +330,8 @@ Compilation *Driver::BuildCompilation(ArrayRef<const char *> ArgList) {
if (Args->hasArg(options::OPT_nostdlib))
UseStdLib = false;
- // Reset the target triple here as we may have adjusted the
- // DefaultTargetTriple string for flags above.
- // FIXME: Same fix is needed here when the above flag management is fixed.
- TargetTriple = llvm::Triple(llvm::Triple::normalize(DefaultTargetTriple));
+ // Recompute the target triple based on the args.
+ TargetTriple = computeTargetTriple(DefaultTargetTriple, *Args);
Host = GetHostInfo(TargetTriple);
// Perform the default argument translations.
OpenPOWER on IntegriCloud