diff options
author | Chandler Carruth <chandlerc@gmail.com> | 2010-03-22 01:52:07 +0000 |
---|---|---|
committer | Chandler Carruth <chandlerc@gmail.com> | 2010-03-22 01:52:07 +0000 |
commit | 48ad6094679ca2bf4f3593068e02e7a208c1a73c (patch) | |
tree | 80addc602298e0572c50e30f95be0429eb456dec | |
parent | 01620704304f819b82ecef769ec114e541a364d7 (diff) |
Add very limited support for GCC's '-B' flag. This allows us to support unusual
toolchain configurations and is a small step toward FreeBSD support.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@99159 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r-- | include/clang/Driver/Driver.h | 6 | ||||
-rw-r--r-- | include/clang/Driver/Options.td | 2 | ||||
-rw-r--r-- | lib/Driver/Driver.cpp | 20 |
3 files changed, 27 insertions, 1 deletions
diff --git a/include/clang/Driver/Driver.h b/include/clang/Driver/Driver.h index f49c3b97c1..37575fc303 100644 --- a/include/clang/Driver/Driver.h +++ b/include/clang/Driver/Driver.h @@ -64,6 +64,12 @@ public: /// The path to the compiler resource directory. std::string ResourceDir; + /// A prefix directory used to emulated a limited subset of GCC's '-Bprefix' + /// functionality. + /// FIXME: This type of customization should be removed in favor of the + /// universal driver when it is ready. + std::string PrefixDir; + /// Default host triple. std::string DefaultHostTriple; diff --git a/include/clang/Driver/Options.td b/include/clang/Driver/Options.td index 71258f9814..6656dbe173 100644 --- a/include/clang/Driver/Options.td +++ b/include/clang/Driver/Options.td @@ -118,7 +118,7 @@ def ccc_ : Joined<"-ccc-">, Group<ccc_Group>, Flags<[Unsupported]>; def _HASH_HASH_HASH : Flag<"-###">, Flags<[DriverOption]>, HelpText<"Print the commands to run for this compilation">; def A : JoinedOrSeparate<"-A">; -def B : JoinedOrSeparate<"-B">, Flags<[Unsupported]>; +def B : JoinedOrSeparate<"-B">; def CC : Flag<"-CC">; def C : Flag<"-C">; def D : JoinedOrSeparate<"-D">, Group<CompileOnly_Group>; diff --git a/lib/Driver/Driver.cpp b/lib/Driver/Driver.cpp index acfff386f4..aa55d39886 100644 --- a/lib/Driver/Driver.cpp +++ b/lib/Driver/Driver.cpp @@ -172,6 +172,8 @@ Compilation *Driver::BuildCompilation(int argc, const char **argv) { HostTriple = A->getValue(*Args); if (const Arg *A = Args->getLastArg(options::OPT_ccc_install_dir)) Dir = A->getValue(*Args); + if (const Arg *A = Args->getLastArg(options::OPT_B)) + PrefixDir = A->getValue(*Args); Host = GetHostInfo(HostTriple); @@ -1088,6 +1090,15 @@ const char *Driver::GetNamedOutputPath(Compilation &C, } std::string Driver::GetFilePath(const char *Name, const ToolChain &TC) const { + // Respect a limited subset of the '-Bprefix' functionality in GCC by + // attempting to use this prefix when lokup up program paths. + if (!PrefixDir.empty()) { + llvm::sys::Path P(PrefixDir); + P.appendComponent(Name); + if (P.exists()) + return P.str(); + } + const ToolChain::path_list &List = TC.getFilePaths(); for (ToolChain::path_list::const_iterator it = List.begin(), ie = List.end(); it != ie; ++it) { @@ -1102,6 +1113,15 @@ std::string Driver::GetFilePath(const char *Name, const ToolChain &TC) const { std::string Driver::GetProgramPath(const char *Name, const ToolChain &TC, bool WantFile) const { + // Respect a limited subset of the '-Bprefix' functionality in GCC by + // attempting to use this prefix when lokup up program paths. + if (!PrefixDir.empty()) { + llvm::sys::Path P(PrefixDir); + P.appendComponent(Name); + if (WantFile ? P.exists() : P.canExecute()) + return P.str(); + } + const ToolChain::path_list &List = TC.getProgramPaths(); for (ToolChain::path_list::const_iterator it = List.begin(), ie = List.end(); it != ie; ++it) { |