#include "ToolChains.h"
#include "clang/Basic/ObjCRuntime.h"
#include "clang/Basic/Version.h"
+#include "clang/Basic/VirtualFileSystem.h"
#include "clang/Config/config.h" // for GCC_INSTALL_PREFIX
#include "clang/Driver/Compilation.h"
#include "clang/Driver/Driver.h"
// For now, allow missing resource libraries to support developers who may
// not have compiler-rt checked out or integrated into their build (unless
// we explicitly force linking with this library).
- if (AlwaysLink || llvm::sys::fs::exists(P))
+ if (AlwaysLink || getVFS().exists(P))
CmdArgs.push_back(Args.MakeArgString(P));
// Adding the rpaths might negatively interact when other rpaths are involved,
// isysroot.
if (const Arg *A = Args.getLastArg(options::OPT_isysroot)) {
// Warn if the path does not exist.
- if (!llvm::sys::fs::exists(A->getValue()))
+ if (!getVFS().exists(A->getValue()))
getDriver().Diag(clang::diag::warn_missing_sysroot) << A->getValue();
} else {
if (char *env = ::getenv("SDKROOT")) {
// We only use this value as the default if it is an absolute path,
// exists, and it is not the root path.
- if (llvm::sys::path::is_absolute(env) && llvm::sys::fs::exists(env) &&
+ if (llvm::sys::path::is_absolute(env) && getVFS().exists(env) &&
StringRef(env) != "/") {
Args.append(Args.MakeSeparateArg(
nullptr, Opts.getOption(options::OPT_isysroot), env));
SmallString<128> P(A->getValue());
llvm::sys::path::append(P, "usr", "lib", "libstdc++.dylib");
- if (!llvm::sys::fs::exists(P)) {
+ if (!getVFS().exists(P)) {
llvm::sys::path::remove_filename(P);
llvm::sys::path::append(P, "libstdc++.6.dylib");
- if (llvm::sys::fs::exists(P)) {
+ if (getVFS().exists(P)) {
CmdArgs.push_back(Args.MakeArgString(P));
return;
}
// Otherwise, look in the root.
// FIXME: This should be removed someday when we don't have to care about
// 10.6 and earlier, where /usr/lib/libstdc++.dylib does not exist.
- if (!llvm::sys::fs::exists("/usr/lib/libstdc++.dylib") &&
- llvm::sys::fs::exists("/usr/lib/libstdc++.6.dylib")) {
+ if (!getVFS().exists("/usr/lib/libstdc++.dylib") &&
+ getVFS().exists("/usr/lib/libstdc++.6.dylib")) {
CmdArgs.push_back("/usr/lib/libstdc++.6.dylib");
return;
}
// For now, allow missing resource libraries to support developers who may
// not have compiler-rt checked out or integrated into their build.
- if (llvm::sys::fs::exists(P))
+ if (getVFS().exists(P))
CmdArgs.push_back(Args.MakeArgString(P));
}
/// necessary because the driver doesn't store the final version of the target
/// triple.
void Generic_GCC::GCCInstallationDetector::init(
- const Driver &D, const llvm::Triple &TargetTriple, const ArgList &Args,
+ const llvm::Triple &TargetTriple, const ArgList &Args,
ArrayRef<std::string> ExtraTripleAliases) {
llvm::Triple BiarchVariantTriple = TargetTriple.isArch32Bit()
? TargetTriple.get64BitArchVariant()
// installation available. GCC installs are ranked by version number.
Version = GCCVersion::Parse("0.0.0");
for (const std::string &Prefix : Prefixes) {
- if (!llvm::sys::fs::exists(Prefix))
+ if (!D.getVFS().exists(Prefix))
continue;
for (StringRef Suffix : CandidateLibDirs) {
const std::string LibDir = Prefix + Suffix.str();
- if (!llvm::sys::fs::exists(LibDir))
+ if (!D.getVFS().exists(LibDir))
continue;
for (StringRef Candidate : ExtraTripleAliases) // Try these first.
ScanLibDirForGCCTriple(TargetTriple, Args, LibDir, Candidate);
}
for (StringRef Suffix : CandidateBiarchLibDirs) {
const std::string LibDir = Prefix + Suffix.str();
- if (!llvm::sys::fs::exists(LibDir))
+ if (!D.getVFS().exists(LibDir))
continue;
for (StringRef Candidate : CandidateBiarchTripleAliases)
ScanLibDirForGCCTriple(TargetTriple, Args, LibDir, Candidate,
// \brief -- try common CUDA installation paths looking for files we need for
// CUDA compilation.
-void
-Generic_GCC::CudaInstallationDetector::init(const Driver &D,
- const llvm::Triple &TargetTriple,
- const llvm::opt::ArgList &Args) {
+void Generic_GCC::CudaInstallationDetector::init(
+ const llvm::Triple &TargetTriple, const llvm::opt::ArgList &Args) {
SmallVector<std::string, 4> CudaPathCandidates;
if (Args.hasArg(options::OPT_cuda_path_EQ))
}
for (const auto &CudaPath : CudaPathCandidates) {
- if (CudaPath.empty() || !llvm::sys::fs::exists(CudaPath))
+ if (CudaPath.empty() || !D.getVFS().exists(CudaPath))
continue;
CudaInstallPath = CudaPath;
CudaLibPath =
CudaInstallPath + (TargetTriple.isArch64Bit() ? "/lib64" : "/lib");
- if (!(llvm::sys::fs::exists(CudaIncludePath) &&
- llvm::sys::fs::exists(CudaLibPath) &&
- llvm::sys::fs::exists(CudaLibDevicePath)))
+ if (!(D.getVFS().exists(CudaIncludePath) &&
+ D.getVFS().exists(CudaLibPath) &&
+ D.getVFS().exists(CudaLibDevicePath)))
continue;
IsValid = true;
// /usr/gcc/<major>.<minor>/lib/gcc/<triple>/<major>.<minor>.<patch>/, so we
// need to iterate twice.
std::error_code EC;
- for (llvm::sys::fs::directory_iterator LI(LibDir, EC), LE; !EC && LI != LE;
- LI = LI.increment(EC)) {
- StringRef VersionText = llvm::sys::path::filename(LI->path());
+ for (vfs::directory_iterator LI = D.getVFS().dir_begin(LibDir, EC), LE;
+ !EC && LI != LE; LI = LI.increment(EC)) {
+ StringRef VersionText = llvm::sys::path::filename(LI->getName());
GCCVersion CandidateVersion = GCCVersion::Parse(VersionText);
if (CandidateVersion.Major != -1) // Filter obviously bad entries.
- if (!CandidateGCCInstallPaths.insert(LI->path()).second)
+ if (!CandidateGCCInstallPaths.insert(LI->getName()).second)
continue; // Saw this path before; no need to look at it again.
if (CandidateVersion.isOlderThan(4, 1, 1))
continue;
GCCInstallPath =
LibDir + "/" + VersionText.str() + "/lib/gcc/" + CandidateTriple.str();
- if (!llvm::sys::fs::exists(GCCInstallPath))
+ if (!D.getVFS().exists(GCCInstallPath))
continue;
// If we make it here there has to be at least one GCC version, let's just
// use the latest one.
std::error_code EEC;
- for (llvm::sys::fs::directory_iterator LLI(GCCInstallPath, EEC), LLE;
+ for (vfs::directory_iterator
+ LLI = D.getVFS().dir_begin(GCCInstallPath, EEC),
+ LLE;
!EEC && LLI != LLE; LLI = LLI.increment(EEC)) {
- StringRef SubVersionText = llvm::sys::path::filename(LLI->path());
+ StringRef SubVersionText = llvm::sys::path::filename(LLI->getName());
GCCVersion CandidateSubVersion = GCCVersion::Parse(SubVersionText);
if (CandidateSubVersion > Version)
for (unsigned i = 0; i < NumLibSuffixes; ++i) {
StringRef LibSuffix = LibAndInstallSuffixes[i][0];
std::error_code EC;
- for (llvm::sys::fs::directory_iterator LI(LibDir + LibSuffix, EC), LE;
+ for (vfs::directory_iterator
+ LI = D.getVFS().dir_begin(LibDir + LibSuffix, EC),
+ LE;
!EC && LI != LE; LI = LI.increment(EC)) {
- StringRef VersionText = llvm::sys::path::filename(LI->path());
+ StringRef VersionText = llvm::sys::path::filename(LI->getName());
GCCVersion CandidateVersion = GCCVersion::Parse(VersionText);
if (CandidateVersion.Major != -1) // Filter obviously bad entries.
- if (!CandidateGCCInstallPaths.insert(LI->path()).second)
+ if (!CandidateGCCInstallPaths.insert(LI->getName()).second)
continue; // Saw this path before; no need to look at it again.
if (CandidateVersion.isOlderThan(4, 1, 1))
continue;
// Debian mips multilibs behave more like the rest of the biarch ones,
// so handle them there
if (isMipsArch(TargetArch)) {
- if (!findMIPSMultilibs(TargetTriple, LI->path(), Args, Detected))
+ if (!findMIPSMultilibs(TargetTriple, LI->getName(), Args, Detected))
continue;
- } else if (!findBiarchMultilibs(TargetTriple, LI->path(), Args,
+ } else if (!findBiarchMultilibs(TargetTriple, LI->getName(), Args,
NeedsBiarchSuffix, Detected)) {
continue;
}
Generic_GCC::Generic_GCC(const Driver &D, const llvm::Triple &Triple,
const ArgList &Args)
- : ToolChain(D, Triple, Args), GCCInstallation(), CudaInstallation() {
+ : ToolChain(D, Triple, Args), GCCInstallation(D), CudaInstallation(D) {
getProgramPaths().push_back(getDriver().getInstalledDir());
if (getDriver().getInstalledDir() != getDriver().Dir)
getProgramPaths().push_back(getDriver().Dir);
/// Hexagon Toolchain
std::string HexagonToolChain::GetGnuDir(const std::string &InstalledDir,
- const ArgList &Args) {
+ const ArgList &Args) const {
// Locate the rest of the toolchain ...
std::string GccToolchain = getGCCToolchainDir(Args);
return GccToolchain;
std::string InstallRelDir = InstalledDir + "/../../gnu";
- if (llvm::sys::fs::exists(InstallRelDir))
+ if (getVFS().exists(InstallRelDir))
return InstallRelDir;
std::string PrefixRelDir = std::string(LLVM_PREFIX) + "/../gnu";
- if (llvm::sys::fs::exists(PrefixRelDir))
+ if (getVFS().exists(PrefixRelDir))
return PrefixRelDir;
return InstallRelDir;
return smallDataThreshold && smallDataThreshold[0] == '0';
}
-static void GetHexagonLibraryPaths(const ArgList &Args, const std::string &Ver,
+static void GetHexagonLibraryPaths(const HexagonToolChain &TC,
+ const ArgList &Args, const std::string &Ver,
const std::string &MarchString,
const std::string &InstalledDir,
ToolChain::path_list *LibPaths) {
const std::string MarchSuffix = "/" + MarchString;
const std::string G0Suffix = "/G0";
const std::string MarchG0Suffix = MarchSuffix + G0Suffix;
- const std::string RootDir =
- HexagonToolChain::GetGnuDir(InstalledDir, Args) + "/";
+ const std::string RootDir = TC.GetGnuDir(InstalledDir, Args) + "/";
// lib/gcc/hexagon/...
std::string LibGCCHexagonDir = RootDir + "lib/gcc/hexagon/";
const ArgList &Args)
: Linux(D, Triple, Args) {
const std::string InstalledDir(getDriver().getInstalledDir());
- const std::string GnuDir = HexagonToolChain::GetGnuDir(InstalledDir, Args);
+ const std::string GnuDir = GetGnuDir(InstalledDir, Args);
// Note: Generic_GCC::Generic_GCC adds InstalledDir and getDriver().Dir to
// program paths
const std::string BinDir(GnuDir + "/bin");
- if (llvm::sys::fs::exists(BinDir))
+ if (D.getVFS().exists(BinDir))
getProgramPaths().push_back(BinDir);
// Determine version of GCC libraries and headers to use.
const std::string HexagonDir(GnuDir + "/lib/gcc/hexagon");
std::error_code ec;
GCCVersion MaxVersion = GCCVersion::Parse("0.0.0");
- for (llvm::sys::fs::directory_iterator di(HexagonDir, ec), de;
+ for (vfs::directory_iterator di = D.getVFS().dir_begin(HexagonDir, ec), de;
!ec && di != de; di = di.increment(ec)) {
- GCCVersion cv = GCCVersion::Parse(llvm::sys::path::filename(di->path()));
+ GCCVersion cv = GCCVersion::Parse(llvm::sys::path::filename(di->getName()));
if (MaxVersion < cv)
MaxVersion = cv;
}
// support 'linux' we'll need to fix this up
LibPaths->clear();
- GetHexagonLibraryPaths(Args, GetGCCLibAndIncVersion(), GetTargetCPU(Args),
- InstalledDir, LibPaths);
+ GetHexagonLibraryPaths(*this, Args, GetGCCLibAndIncVersion(),
+ GetTargetCPU(Args), InstalledDir, LibPaths);
}
HexagonToolChain::~HexagonToolChain() {}
return;
std::string Ver(GetGCCLibAndIncVersion());
- std::string GnuDir = HexagonToolChain::GetGnuDir(D.InstalledDir, DriverArgs);
+ std::string GnuDir = GetGnuDir(D.InstalledDir, DriverArgs);
std::string HexagonDir(GnuDir + "/lib/gcc/hexagon/" + Ver);
addExternCSystemInclude(DriverArgs, CC1Args, HexagonDir + "/include");
addExternCSystemInclude(DriverArgs, CC1Args, HexagonDir + "/include-fixed");
const Driver &D = getDriver();
std::string Ver(GetGCCLibAndIncVersion());
- SmallString<128> IncludeDir(
- HexagonToolChain::GetGnuDir(D.InstalledDir, DriverArgs));
+ SmallString<128> IncludeDir(GetGnuDir(D.InstalledDir, DriverArgs));
llvm::sys::path::append(IncludeDir, "hexagon/include/c++/");
llvm::sys::path::append(IncludeDir, Ver);
// back to '/usr/lib' if it doesn't exist.
if ((Triple.getArch() == llvm::Triple::x86 ||
Triple.getArch() == llvm::Triple::ppc) &&
- llvm::sys::fs::exists(getDriver().SysRoot + "/usr/lib32/crt1.o"))
+ D.getVFS().exists(getDriver().SysRoot + "/usr/lib32/crt1.o"))
getFilePaths().push_back(getDriver().SysRoot + "/usr/lib32");
else
getFilePaths().push_back(getDriver().SysRoot + "/usr/lib");
Tool *Minix::buildLinker() const { return new tools::minix::Linker(*this); }
-static void addPathIfExists(Twine Path, ToolChain::path_list &Paths) {
- if (llvm::sys::fs::exists(Path))
+static void addPathIfExists(const Driver &D, const Twine &Path,
+ ToolChain::path_list &Paths) {
+ if (D.getVFS().exists(Path))
Paths.push_back(Path.str());
}
const ArgList &Args)
: Generic_GCC(D, Triple, Args) {
- GCCInstallation.init(D, Triple, Args);
+ GCCInstallation.init(Triple, Args);
path_list &Paths = getFilePaths();
if (GCCInstallation.isValid())
- addPathIfExists(GCCInstallation.getInstallPath(), Paths);
+ addPathIfExists(D, GCCInstallation.getInstallPath(), Paths);
- addPathIfExists(getDriver().getInstalledDir(), Paths);
+ addPathIfExists(D, getDriver().getInstalledDir(), Paths);
if (getDriver().getInstalledDir() != getDriver().Dir)
- addPathIfExists(getDriver().Dir, Paths);
+ addPathIfExists(D, getDriver().Dir, Paths);
- addPathIfExists(getDriver().SysRoot + getDriver().Dir + "/../lib", Paths);
+ addPathIfExists(D, getDriver().SysRoot + getDriver().Dir + "/../lib", Paths);
std::string LibPath = "/usr/lib/";
switch (Triple.getArch()) {
llvm_unreachable("Unsupported architecture");
}
- addPathIfExists(getDriver().SysRoot + LibPath, Paths);
+ addPathIfExists(D, getDriver().SysRoot + LibPath, Paths);
}
Tool *Solaris::buildAssembler() const {
return Distro >= UbuntuHardy && Distro <= UbuntuWily;
}
-static Distro DetectDistro(llvm::Triple::ArchType Arch) {
+static Distro DetectDistro(const Driver &D, llvm::Triple::ArchType Arch) {
llvm::ErrorOr<std::unique_ptr<llvm::MemoryBuffer>> File =
llvm::MemoryBuffer::getFile("/etc/lsb-release");
if (File) {
return UnknownDistro;
}
- if (llvm::sys::fs::exists("/etc/SuSE-release"))
+ if (D.getVFS().exists("/etc/SuSE-release"))
return OpenSUSE;
- if (llvm::sys::fs::exists("/etc/exherbo-release"))
+ if (D.getVFS().exists("/etc/exherbo-release"))
return Exherbo;
- if (llvm::sys::fs::exists("/etc/arch-release"))
+ if (D.getVFS().exists("/etc/arch-release"))
return ArchLinux;
return UnknownDistro;
/// a target-triple directory in the library and header search paths.
/// Unfortunately, this triple does not align with the vanilla target triple,
/// so we provide a rough mapping here.
-static std::string getMultiarchTriple(const llvm::Triple &TargetTriple,
+static std::string getMultiarchTriple(const Driver &D,
+ const llvm::Triple &TargetTriple,
StringRef SysRoot) {
llvm::Triple::EnvironmentType TargetEnvironment = TargetTriple.getEnvironment();
case llvm::Triple::arm:
case llvm::Triple::thumb:
if (TargetEnvironment == llvm::Triple::GNUEABIHF) {
- if (llvm::sys::fs::exists(SysRoot + "/lib/arm-linux-gnueabihf"))
+ if (D.getVFS().exists(SysRoot + "/lib/arm-linux-gnueabihf"))
return "arm-linux-gnueabihf";
} else {
- if (llvm::sys::fs::exists(SysRoot + "/lib/arm-linux-gnueabi"))
+ if (D.getVFS().exists(SysRoot + "/lib/arm-linux-gnueabi"))
return "arm-linux-gnueabi";
}
break;
case llvm::Triple::armeb:
case llvm::Triple::thumbeb:
if (TargetEnvironment == llvm::Triple::GNUEABIHF) {
- if (llvm::sys::fs::exists(SysRoot + "/lib/armeb-linux-gnueabihf"))
+ if (D.getVFS().exists(SysRoot + "/lib/armeb-linux-gnueabihf"))
return "armeb-linux-gnueabihf";
} else {
- if (llvm::sys::fs::exists(SysRoot + "/lib/armeb-linux-gnueabi"))
+ if (D.getVFS().exists(SysRoot + "/lib/armeb-linux-gnueabi"))
return "armeb-linux-gnueabi";
}
break;
case llvm::Triple::x86:
- if (llvm::sys::fs::exists(SysRoot + "/lib/i386-linux-gnu"))
+ if (D.getVFS().exists(SysRoot + "/lib/i386-linux-gnu"))
return "i386-linux-gnu";
break;
case llvm::Triple::x86_64:
// We don't want this for x32, otherwise it will match x86_64 libs
if (TargetEnvironment != llvm::Triple::GNUX32 &&
- llvm::sys::fs::exists(SysRoot + "/lib/x86_64-linux-gnu"))
+ D.getVFS().exists(SysRoot + "/lib/x86_64-linux-gnu"))
return "x86_64-linux-gnu";
break;
case llvm::Triple::aarch64:
- if (llvm::sys::fs::exists(SysRoot + "/lib/aarch64-linux-gnu"))
+ if (D.getVFS().exists(SysRoot + "/lib/aarch64-linux-gnu"))
return "aarch64-linux-gnu";
break;
case llvm::Triple::aarch64_be:
- if (llvm::sys::fs::exists(SysRoot + "/lib/aarch64_be-linux-gnu"))
+ if (D.getVFS().exists(SysRoot + "/lib/aarch64_be-linux-gnu"))
return "aarch64_be-linux-gnu";
break;
case llvm::Triple::mips:
- if (llvm::sys::fs::exists(SysRoot + "/lib/mips-linux-gnu"))
+ if (D.getVFS().exists(SysRoot + "/lib/mips-linux-gnu"))
return "mips-linux-gnu";
break;
case llvm::Triple::mipsel:
- if (llvm::sys::fs::exists(SysRoot + "/lib/mipsel-linux-gnu"))
+ if (D.getVFS().exists(SysRoot + "/lib/mipsel-linux-gnu"))
return "mipsel-linux-gnu";
break;
case llvm::Triple::mips64:
- if (llvm::sys::fs::exists(SysRoot + "/lib/mips64-linux-gnu"))
+ if (D.getVFS().exists(SysRoot + "/lib/mips64-linux-gnu"))
return "mips64-linux-gnu";
- if (llvm::sys::fs::exists(SysRoot + "/lib/mips64-linux-gnuabi64"))
+ if (D.getVFS().exists(SysRoot + "/lib/mips64-linux-gnuabi64"))
return "mips64-linux-gnuabi64";
break;
case llvm::Triple::mips64el:
- if (llvm::sys::fs::exists(SysRoot + "/lib/mips64el-linux-gnu"))
+ if (D.getVFS().exists(SysRoot + "/lib/mips64el-linux-gnu"))
return "mips64el-linux-gnu";
- if (llvm::sys::fs::exists(SysRoot + "/lib/mips64el-linux-gnuabi64"))
+ if (D.getVFS().exists(SysRoot + "/lib/mips64el-linux-gnuabi64"))
return "mips64el-linux-gnuabi64";
break;
case llvm::Triple::ppc:
- if (llvm::sys::fs::exists(SysRoot + "/lib/powerpc-linux-gnuspe"))
+ if (D.getVFS().exists(SysRoot + "/lib/powerpc-linux-gnuspe"))
return "powerpc-linux-gnuspe";
- if (llvm::sys::fs::exists(SysRoot + "/lib/powerpc-linux-gnu"))
+ if (D.getVFS().exists(SysRoot + "/lib/powerpc-linux-gnu"))
return "powerpc-linux-gnu";
break;
case llvm::Triple::ppc64:
- if (llvm::sys::fs::exists(SysRoot + "/lib/powerpc64-linux-gnu"))
+ if (D.getVFS().exists(SysRoot + "/lib/powerpc64-linux-gnu"))
return "powerpc64-linux-gnu";
break;
case llvm::Triple::ppc64le:
- if (llvm::sys::fs::exists(SysRoot + "/lib/powerpc64le-linux-gnu"))
+ if (D.getVFS().exists(SysRoot + "/lib/powerpc64le-linux-gnu"))
return "powerpc64le-linux-gnu";
break;
case llvm::Triple::sparc:
- if (llvm::sys::fs::exists(SysRoot + "/lib/sparc-linux-gnu"))
+ if (D.getVFS().exists(SysRoot + "/lib/sparc-linux-gnu"))
return "sparc-linux-gnu";
break;
case llvm::Triple::sparcv9:
- if (llvm::sys::fs::exists(SysRoot + "/lib/sparc64-linux-gnu"))
+ if (D.getVFS().exists(SysRoot + "/lib/sparc64-linux-gnu"))
return "sparc64-linux-gnu";
break;
case llvm::Triple::systemz:
- if (llvm::sys::fs::exists(SysRoot + "/lib/s390x-linux-gnu"))
+ if (D.getVFS().exists(SysRoot + "/lib/s390x-linux-gnu"))
return "s390x-linux-gnu";
break;
}
Linux::Linux(const Driver &D, const llvm::Triple &Triple, const ArgList &Args)
: Generic_ELF(D, Triple, Args) {
- GCCInstallation.init(D, Triple, Args);
- CudaInstallation.init(D, Triple, Args);
+ GCCInstallation.init(Triple, Args);
+ CudaInstallation.init(Triple, Args);
Multilibs = GCCInstallation.getMultilibs();
llvm::Triple::ArchType Arch = Triple.getArch();
std::string SysRoot = computeSysRoot();
Linker = GetLinkerPath();
- Distro Distro = DetectDistro(Arch);
+ Distro Distro = DetectDistro(D, Arch);
if (IsOpenSUSE(Distro) || IsUbuntu(Distro)) {
ExtraOpts.push_back("-z");
path_list &Paths = getFilePaths();
const std::string OSLibDir = getOSLibDir(Triple, Args);
- const std::string MultiarchTriple = getMultiarchTriple(Triple, SysRoot);
+ const std::string MultiarchTriple = getMultiarchTriple(D, Triple, SysRoot);
// Add the multilib suffixed paths where they are available.
if (GCCInstallation.isValid()) {
// Sourcery CodeBench MIPS toolchain holds some libraries under
// a biarch-like suffix of the GCC installation.
- addPathIfExists((GCCInstallation.getInstallPath() + Multilib.gccSuffix()),
+ addPathIfExists(D, GCCInstallation.getInstallPath() + Multilib.gccSuffix(),
Paths);
// GCC cross compiling toolchains will install target libraries which ship
//
// Note that this matches the GCC behavior. See the below comment for where
// Clang diverges from GCC's behavior.
- addPathIfExists(LibPath + "/../" + GCCTriple.str() + "/lib/../" + OSLibDir +
- Multilib.osSuffix(),
+ addPathIfExists(D, LibPath + "/../" + GCCTriple.str() + "/lib/../" +
+ OSLibDir + Multilib.osSuffix(),
Paths);
// If the GCC installation we found is inside of the sysroot, we want to
// configurations but this seems somewhere between questionable and simply
// a bug.
if (StringRef(LibPath).startswith(SysRoot)) {
- addPathIfExists(LibPath + "/" + MultiarchTriple, Paths);
- addPathIfExists(LibPath + "/../" + OSLibDir, Paths);
+ addPathIfExists(D, LibPath + "/" + MultiarchTriple, Paths);
+ addPathIfExists(D, LibPath + "/../" + OSLibDir, Paths);
}
}
// FIXME: It's not clear whether we should use the driver's installed
// directory ('Dir' below) or the ResourceDir.
if (StringRef(D.Dir).startswith(SysRoot)) {
- addPathIfExists(D.Dir + "/../lib/" + MultiarchTriple, Paths);
- addPathIfExists(D.Dir + "/../" + OSLibDir, Paths);
+ addPathIfExists(D, D.Dir + "/../lib/" + MultiarchTriple, Paths);
+ addPathIfExists(D, D.Dir + "/../" + OSLibDir, Paths);
}
- addPathIfExists(SysRoot + "/lib/" + MultiarchTriple, Paths);
- addPathIfExists(SysRoot + "/lib/../" + OSLibDir, Paths);
- addPathIfExists(SysRoot + "/usr/lib/" + MultiarchTriple, Paths);
- addPathIfExists(SysRoot + "/usr/lib/../" + OSLibDir, Paths);
+ addPathIfExists(D, SysRoot + "/lib/" + MultiarchTriple, Paths);
+ addPathIfExists(D, SysRoot + "/lib/../" + OSLibDir, Paths);
+ addPathIfExists(D, SysRoot + "/usr/lib/" + MultiarchTriple, Paths);
+ addPathIfExists(D, SysRoot + "/usr/lib/../" + OSLibDir, Paths);
// Try walking via the GCC triple path in case of biarch or multiarch GCC
// installations with strange symlinks.
if (GCCInstallation.isValid()) {
- addPathIfExists(SysRoot + "/usr/lib/" + GCCInstallation.getTriple().str() +
+ addPathIfExists(D,
+ SysRoot + "/usr/lib/" + GCCInstallation.getTriple().str() +
"/../../" + OSLibDir,
Paths);
// Add the 'other' biarch variant path
Multilib BiarchSibling;
if (GCCInstallation.getBiarchSibling(BiarchSibling)) {
- addPathIfExists(
- GCCInstallation.getInstallPath() + BiarchSibling.gccSuffix(), Paths);
+ addPathIfExists(D, GCCInstallation.getInstallPath() +
+ BiarchSibling.gccSuffix(),
+ Paths);
}
// See comments above on the multilib variant for details of why this is
const std::string &LibPath = GCCInstallation.getParentLibPath();
const llvm::Triple &GCCTriple = GCCInstallation.getTriple();
const Multilib &Multilib = GCCInstallation.getMultilib();
- addPathIfExists(LibPath + "/../" + GCCTriple.str() + "/lib" +
- Multilib.osSuffix(),
+ addPathIfExists(D, LibPath + "/../" + GCCTriple.str() + "/lib" +
+ Multilib.osSuffix(),
Paths);
// See comments above on the multilib variant for details of why this is
// only included from within the sysroot.
if (StringRef(LibPath).startswith(SysRoot))
- addPathIfExists(LibPath, Paths);
+ addPathIfExists(D, LibPath, Paths);
}
// Similar to the logic for GCC above, if we are currently running Clang
// FIXME: It's not clear whether we should use the driver's installed
// directory ('Dir' below) or the ResourceDir.
if (StringRef(D.Dir).startswith(SysRoot))
- addPathIfExists(D.Dir + "/../lib", Paths);
+ addPathIfExists(D, D.Dir + "/../lib", Paths);
- addPathIfExists(SysRoot + "/lib", Paths);
- addPathIfExists(SysRoot + "/usr/lib", Paths);
+ addPathIfExists(D, SysRoot + "/lib", Paths);
+ addPathIfExists(D, SysRoot + "/usr/lib", Paths);
}
bool Linux::HasNativeLLVMSupport() const { return true; }
(InstallDir + "/../../../../" + TripleStr + "/libc" + Multilib.osSuffix())
.str();
- if (llvm::sys::fs::exists(Path))
+ if (getVFS().exists(Path))
return Path;
Path = (InstallDir + "/../../../../sysroot" + Multilib.osSuffix()).str();
- if (llvm::sys::fs::exists(Path))
+ if (getVFS().exists(Path))
return Path;
return std::string();
break;
}
for (StringRef Dir : MultiarchIncludeDirs) {
- if (llvm::sys::fs::exists(SysRoot + Dir)) {
+ if (D.getVFS().exists(SysRoot + Dir)) {
addExternCSystemInclude(DriverArgs, CC1Args, SysRoot + Dir);
break;
}
}
/// \brief Helper to add the variant paths of a libstdc++ installation.
-/*static*/ bool Linux::addLibStdCXXIncludePaths(
+bool Linux::addLibStdCXXIncludePaths(
Twine Base, Twine Suffix, StringRef GCCTriple, StringRef GCCMultiarchTriple,
StringRef TargetMultiarchTriple, Twine IncludeSuffix,
- const ArgList &DriverArgs, ArgStringList &CC1Args) {
- if (!llvm::sys::fs::exists(Base + Suffix))
+ const ArgList &DriverArgs, ArgStringList &CC1Args) const {
+ if (!getVFS().exists(Base + Suffix))
return false;
addSystemInclude(DriverArgs, CC1Args, Base + Suffix);
// that path exists or we have neither a GCC nor target multiarch triple, use
// this vanilla search path.
if ((GCCMultiarchTriple.empty() && TargetMultiarchTriple.empty()) ||
- llvm::sys::fs::exists(Base + Suffix + "/" + GCCTriple + IncludeSuffix)) {
+ getVFS().exists(Base + Suffix + "/" + GCCTriple + IncludeSuffix)) {
addSystemInclude(DriverArgs, CC1Args,
Base + Suffix + "/" + GCCTriple + IncludeSuffix);
} else {
// FIXME: We should really remove this. It doesn't make any sense.
getDriver().SysRoot + "/usr/include/c++/v1"};
for (const auto &IncludePath : LibCXXIncludePathCandidates) {
- if (!llvm::sys::fs::exists(IncludePath))
+ if (!getVFS().exists(IncludePath))
continue;
// Add the first candidate that exists.
addSystemInclude(DriverArgs, CC1Args, IncludePath);
StringRef InstallDir = GCCInstallation.getInstallPath();
StringRef TripleStr = GCCInstallation.getTriple().str();
const Multilib &Multilib = GCCInstallation.getMultilib();
- const std::string GCCMultiarchTriple =
- getMultiarchTriple(GCCInstallation.getTriple(), getDriver().SysRoot);
+ const std::string GCCMultiarchTriple = getMultiarchTriple(
+ getDriver(), GCCInstallation.getTriple(), getDriver().SysRoot);
const std::string TargetMultiarchTriple =
- getMultiarchTriple(getTriple(), getDriver().SysRoot);
+ getMultiarchTriple(getDriver(), getTriple(), getDriver().SysRoot);
const GCCVersion &Version = GCCInstallation.getVersion();
// The primary search for libstdc++ supports multiarch variants.
getFilePaths().push_back(getDriver().Dir + "/../lib");
getFilePaths().push_back("/usr/lib");
- if (llvm::sys::fs::exists("/usr/lib/gcc47"))
+ if (D.getVFS().exists("/usr/lib/gcc47"))
getFilePaths().push_back("/usr/lib/gcc47");
else
getFilePaths().push_back("/usr/lib/gcc44");
case llvm::Triple::sparc:
case llvm::Triple::sparcel:
case llvm::Triple::shave:
- GCCInstallation.init(D, Triple, Args, {"sparc-myriad-elf"});
+ GCCInstallation.init(Triple, Args, {"sparc-myriad-elf"});
}
}