summaryrefslogtreecommitdiffstats
path: root/clang/lib
diff options
context:
space:
mode:
authorSimon Atanasyan <simon@atanasyan.com>2014-08-06 05:44:47 +0000
committerSimon Atanasyan <simon@atanasyan.com>2014-08-06 05:44:47 +0000
commit9e49e145b109a9132c692de0b27784c9dadf09f3 (patch)
tree7b62ac10a1d426e73a93f1d4c5dd1a6260acb0a9 /clang/lib
parentce49b5ba98209f66b06629d778274aad07d25cdc (diff)
downloadbcm5719-llvm-9e49e145b109a9132c692de0b27784c9dadf09f3.tar.gz
bcm5719-llvm-9e49e145b109a9132c692de0b27784c9dadf09f3.zip
[Driver] Move information about toolchain specific include directories
from the common driver code to the corresponding `MultilibSet` declarations. Now the `MultilibSet` can hold an optional callback function which is responsible to return a set of include directories specific for the toolchain. That allows to remove MIPS toolchain specific directories from `Linux::AddClangSystemIncludeArgs` method and simplify adding new directories in the future. llvm-svn: 214949
Diffstat (limited to 'clang/lib')
-rw-r--r--clang/lib/Driver/ToolChains.cpp52
1 files changed, 35 insertions, 17 deletions
diff --git a/clang/lib/Driver/ToolChains.cpp b/clang/lib/Driver/ToolChains.cpp
index 15ae27cb89d..63ad2619d9c 100644
--- a/clang/lib/Driver/ToolChains.cpp
+++ b/clang/lib/Driver/ToolChains.cpp
@@ -1726,7 +1726,14 @@ static bool findMIPSMultilibs(const llvm::Triple &TargetTriple, StringRef Path,
.Maybe(SoftFloat)
.Maybe(Nan2008)
.FilterOut(".*sof/nan2008")
- .FilterOut(NonExistent);
+ .FilterOut(NonExistent)
+ .setIncludeDirsCallback([](
+ StringRef InstallDir, StringRef TripleStr, const Multilib &M) {
+ std::vector<std::string> Dirs;
+ Dirs.push_back((InstallDir + "/include").str());
+ Dirs.push_back((InstallDir + "/../../../../sysroot/usr/include").str());
+ return Dirs;
+ });
}
// Check for Code Sourcery toolchain multilibs
@@ -1771,7 +1778,15 @@ static bool findMIPSMultilibs(const llvm::Triple &TargetTriple, StringRef Path,
.Maybe(MAbi64)
.FilterOut("/mips16.*/64")
.FilterOut("/micromips.*/64")
- .FilterOut(NonExistent);
+ .FilterOut(NonExistent)
+ .setIncludeDirsCallback([](
+ StringRef InstallDir, StringRef TripleStr, const Multilib &M) {
+ std::vector<std::string> Dirs;
+ Dirs.push_back((InstallDir + "/include").str());
+ Dirs.push_back((InstallDir + "/../../../../" + TripleStr +
+ "/libc/usr/include").str());
+ return Dirs;
+ });
}
MultilibSet AndroidMipsMultilibs = MultilibSet()
@@ -1813,7 +1828,14 @@ static bool findMIPSMultilibs(const llvm::Triple &TargetTriple, StringRef Path,
.Maybe(Mips64r6)
.Maybe(MAbi64)
.Maybe(LittleEndian)
- .FilterOut(NonExistent);
+ .FilterOut(NonExistent)
+ .setIncludeDirsCallback([](
+ StringRef InstallDir, StringRef TripleStr, const Multilib &M) {
+ std::vector<std::string> Dirs;
+ Dirs.push_back((InstallDir + "/include").str());
+ Dirs.push_back((InstallDir + "/../../../../sysroot/usr/include").str());
+ return Dirs;
+ });
}
StringRef CPUName;
@@ -3215,20 +3237,16 @@ void Linux::AddClangSystemIncludeArgs(const ArgList &DriverArgs,
// Lacking those, try to detect the correct set of system includes for the
// target triple.
- // Sourcery CodeBench and modern FSF Mips toolchains put extern C
- // system includes under three additional directories.
- if (GCCInstallation.isValid() && isMipsArch(getTriple().getArch())) {
- addExternCSystemIncludeIfExists(
- DriverArgs, CC1Args, GCCInstallation.getInstallPath() + "/include");
-
- addExternCSystemIncludeIfExists(
- DriverArgs, CC1Args,
- GCCInstallation.getInstallPath() + "/../../../../" +
- GCCInstallation.getTriple().str() + "/libc/usr/include");
-
- addExternCSystemIncludeIfExists(
- DriverArgs, CC1Args,
- GCCInstallation.getInstallPath() + "/../../../../sysroot/usr/include");
+ // Add include directories specific to the selected multilib set and multilib.
+ if (GCCInstallation.isValid()) {
+ auto Callback = Multilibs.includeDirsCallback();
+ if (Callback) {
+ const auto IncludePaths = Callback(GCCInstallation.getInstallPath(),
+ GCCInstallation.getTriple().str(),
+ GCCInstallation.getMultilib());
+ for (const auto &Path : IncludePaths)
+ addExternCSystemIncludeIfExists(DriverArgs, CC1Args, Path);
+ }
}
// Implement generic Debian multiarch support.
OpenPOWER on IntegriCloud