[PATCH] Rename clang::driver::toolchains::Linux to clang::driver::toolchains::GNUOrAndroidEnvironment and handle llvm::Triple::Hurd.
Thomas Schwinge
thomas at codesourcery.com
Mon Mar 25 09:15:20 PDT 2013
---
lib/Basic/Targets.cpp | 2 +-
lib/Driver/Driver.cpp | 5 +++-
lib/Driver/ToolChains.cpp | 60 +++++++++++++++++++++++++++------------------
lib/Driver/ToolChains.h | 9 ++++---
lib/Driver/Tools.cpp | 4 +--
5 files changed, 49 insertions(+), 31 deletions(-)
diff --git lib/Basic/Targets.cpp lib/Basic/Targets.cpp
index ad63fd7..0f6256c 100644
--- lib/Basic/Targets.cpp
+++ lib/Basic/Targets.cpp
@@ -4996,7 +4996,7 @@ static TargetInfo *AllocateTarget(const std::string &T) {
case llvm::Triple::aarch64:
switch (os) {
case llvm::Triple::Linux:
- return new LinuxTargetInfo<AArch64TargetInfo>(T);
+ return new GNUOrAndroidEnvironmentTargetInfo<AArch64TargetInfo>(T);
default:
return new AArch64TargetInfo(T);
}
diff --git lib/Driver/Driver.cpp lib/Driver/Driver.cpp
index 689ecbc..b23b873 100644
--- lib/Driver/Driver.cpp
+++ lib/Driver/Driver.cpp
@@ -1677,6 +1677,8 @@ const ToolChain &Driver::getToolChain(const ArgList &Args,
ToolChain *&TC = ToolChains[Target.str()];
if (!TC) {
+ // FIXME: Perhaps this should first decide and specialize based upon the
+ // Environment, then Operating System, then Vendor, then Architecture.
switch (Target.getOS()) {
case llvm::Triple::AuroraUX:
TC = new toolchains::AuroraUX(*this, Target, Args);
@@ -1711,10 +1713,11 @@ const ToolChain &Driver::getToolChain(const ArgList &Args,
TC = new toolchains::Minix(*this, Target, Args);
break;
case llvm::Triple::Linux:
+ case llvm::Triple::Hurd:
if (Target.getArch() == llvm::Triple::hexagon)
TC = new toolchains::Hexagon_TC(*this, Target, Args);
else
- TC = new toolchains::Linux(*this, Target, Args);
+ TC = new toolchains::GNUOrAndroidEnvironment(*this, Target, Args);
break;
case llvm::Triple::Solaris:
TC = new toolchains::Solaris(*this, Target, Args);
diff --git lib/Driver/ToolChains.cpp lib/Driver/ToolChains.cpp
index bcfe51e..b355709 100644
--- lib/Driver/ToolChains.cpp
+++ lib/Driver/ToolChains.cpp
@@ -912,7 +912,7 @@ Darwin_Generic_GCC::ComputeEffectiveClangTriple(const ArgList &Args,
///
/// This is the primary means of forming GCCVersion objects.
/*static*/
-Generic_GCC::GCCVersion Linux::GCCVersion::Parse(StringRef VersionText) {
+Generic_GCC::GCCVersion GNUOrAndroidEnvironment::GCCVersion::Parse(StringRef VersionText) {
const GCCVersion BadVersion = { VersionText.str(), -1, -1, -1, "" };
std::pair<StringRef, StringRef> First = VersionText.split('.');
std::pair<StringRef, StringRef> Second = First.second.split('.');
@@ -1108,7 +1108,11 @@ Generic_GCC::GCCInstallationDetector::GCCInstallationDetector(
"i386-redhat-linux",
"i586-suse-linux",
"i486-slackware-linux",
- "i686-montavista-linux"
+ "i686-montavista-linux",
+ "i686-gnu", "i686-pc-gnu", "i686-unknown-gnu",
+ "i586-gnu", "i586-pc-gnu", "i586-unknown-gnu",
+ "i486-gnu", "i486-pc-gnu", "i486-unknown-gnu",
+ "i386-gnu", "i386-pc-gnu", "i386-unknown-gnu",
};
static const char *const MIPSLibDirs[] = { "/lib" };
@@ -1472,7 +1476,7 @@ static void GetHexagonLibraryPaths(
Hexagon_TC::Hexagon_TC(const Driver &D, const llvm::Triple &Triple,
const ArgList &Args)
- : Linux(D, Triple, Args) {
+ : GNUOrAndroidEnvironment(D, Triple, Args) {
const std::string InstalledDir(getDriver().getInstalledDir());
const std::string GnuDir = Hexagon_TC::GetGnuDir(InstalledDir);
@@ -1496,9 +1500,10 @@ Hexagon_TC::Hexagon_TC(const Driver &D, const llvm::Triple &Triple,
ToolChain::path_list *LibPaths= &getFilePaths();
- // Remove paths added by Linux toolchain. Currently Hexagon_TC really targets
- // 'elf' OS type, so the Linux paths are not appropriate. When we actually
- // support 'linux' we'll need to fix this up
+ // Remove paths added by GNUOrAndroidEnvironment toolchain. Currently
+ // Hexagon_TC really targets 'elf' OS type, so the GNUOrAndroidEnvironment
+ // paths are not appropriate. When we actually add such support, we'll need
+ // to fix this up.
LibPaths->clear();
GetHexagonLibraryPaths(
@@ -2003,6 +2008,8 @@ static std::string getMultiarchTriple(const llvm::Triple TargetTriple,
case llvm::Triple::x86:
if (llvm::sys::fs::exists(SysRoot + "/lib/i386-linux-gnu"))
return "i386-linux-gnu";
+ else if (llvm::sys::fs::exists(SysRoot + "/lib/i386-gnu"))
+ return "i386-gnu";
return TargetTriple.str();
case llvm::Triple::x86_64:
if (llvm::sys::fs::exists(SysRoot + "/lib/x86_64-linux-gnu"))
@@ -2076,7 +2083,9 @@ static StringRef getMultilibDir(const llvm::Triple &Triple,
return Triple.isArch32Bit() ? "lib" : "lib64";
}
-Linux::Linux(const Driver &D, const llvm::Triple &Triple, const ArgList &Args)
+GNUOrAndroidEnvironment::GNUOrAndroidEnvironment(const Driver &D,
+ const llvm::Triple &Triple,
+ const ArgList &Args)
: Generic_ELF(D, Triple, Args) {
llvm::Triple::ArchType Arch = Triple.getArch();
const std::string &SysRoot = getDriver().SysRoot;
@@ -2199,20 +2208,20 @@ Linux::Linux(const Driver &D, const llvm::Triple &Triple, const ArgList &Args)
addPathIfExists(SysRoot + "/usr/lib", Paths);
}
-bool Linux::HasNativeLLVMSupport() const {
+bool GNUOrAndroidEnvironment::HasNativeLLVMSupport() const {
return true;
}
-Tool *Linux::buildLinker() const {
+Tool *GNUOrAndroidEnvironment::buildLinker() const {
return new tools::gnutools::Link(*this);
}
-Tool *Linux::buildAssembler() const {
+Tool *GNUOrAndroidEnvironment::buildAssembler() const {
return new tools::gnutools::Assemble(*this);
}
-void Linux::addClangTargetOptions(const ArgList &DriverArgs,
- ArgStringList &CC1Args) const {
+void GNUOrAndroidEnvironment::addClangTargetOptions(const ArgList &DriverArgs,
+ ArgStringList &CC1Args) const {
const Generic_GCC::GCCVersion &V = GCCInstallation.getVersion();
bool UseInitArrayDefault
= V >= Generic_GCC::GCCVersion::Parse("4.7.0") ||
@@ -2224,8 +2233,8 @@ void Linux::addClangTargetOptions(const ArgList &DriverArgs,
CC1Args.push_back("-fuse-init-array");
}
-void Linux::AddClangSystemIncludeArgs(const ArgList &DriverArgs,
- ArgStringList &CC1Args) const {
+void GNUOrAndroidEnvironment::AddClangSystemIncludeArgs(const ArgList &DriverArgs,
+ ArgStringList &CC1Args) const {
const Driver &D = getDriver();
if (DriverArgs.hasArg(options::OPT_nostdinc))
@@ -2271,6 +2280,7 @@ void Linux::AddClangSystemIncludeArgs(const ArgList &DriverArgs,
};
const StringRef X86MultiarchIncludeDirs[] = {
"/usr/include/i386-linux-gnu",
+ "/usr/include/i386-gnu",
// FIXME: These are older forms of multiarch. It's not clear that they're
// in use in any released version of Debian, so we should consider
@@ -2342,9 +2352,10 @@ void Linux::AddClangSystemIncludeArgs(const ArgList &DriverArgs,
}
/// \brief Helper to add the three variant paths for a libstdc++ installation.
-/*static*/ bool Linux::addLibStdCXXIncludePaths(Twine Base, Twine TargetArchDir,
- const ArgList &DriverArgs,
- ArgStringList &CC1Args) {
+/*static*/ bool GNUOrAndroidEnvironment::addLibStdCXXIncludePaths(Twine Base,
+ Twine TargetArchDir,
+ const ArgList &DriverArgs,
+ ArgStringList &CC1Args) {
if (!llvm::sys::fs::exists(Base))
return false;
addSystemInclude(DriverArgs, CC1Args, Base);
@@ -2355,11 +2366,12 @@ void Linux::AddClangSystemIncludeArgs(const ArgList &DriverArgs,
/// \brief Helper to add an extra variant path for an (Ubuntu) multilib
/// libstdc++ installation.
-/*static*/ bool Linux::addLibStdCXXIncludePaths(Twine Base, Twine Suffix,
- Twine TargetArchDir,
- Twine MultiLibSuffix,
- const ArgList &DriverArgs,
- ArgStringList &CC1Args) {
+/*static*/ bool GNUOrAndroidEnvironment::addLibStdCXXIncludePaths(Twine Base,
+ Twine Suffix,
+ Twine TargetArchDir,
+ Twine MultiLibSuffix,
+ const ArgList &DriverArgs,
+ ArgStringList &CC1Args) {
if (!addLibStdCXXIncludePaths(Base+Suffix, TargetArchDir + MultiLibSuffix,
DriverArgs, CC1Args))
return false;
@@ -2369,8 +2381,8 @@ void Linux::AddClangSystemIncludeArgs(const ArgList &DriverArgs,
return true;
}
-void Linux::AddClangCXXStdlibIncludeArgs(const ArgList &DriverArgs,
- ArgStringList &CC1Args) const {
+void GNUOrAndroidEnvironment::AddClangCXXStdlibIncludeArgs(const ArgList &DriverArgs,
+ ArgStringList &CC1Args) const {
if (DriverArgs.hasArg(options::OPT_nostdlibinc) ||
DriverArgs.hasArg(options::OPT_nostdincxx))
return;
diff --git lib/Driver/ToolChains.h lib/Driver/ToolChains.h
index 3421c53..b232ef6 100644
--- lib/Driver/ToolChains.h
+++ lib/Driver/ToolChains.h
@@ -497,9 +497,12 @@ protected:
virtual Tool *buildLinker() const;
};
-class LLVM_LIBRARY_VISIBILITY Linux : public Generic_ELF {
+// FIXME: Perhaps this mixes up too many different things: GNU vs. Android
+// Environment; Linux vs. Hurd Operating System.
+class LLVM_LIBRARY_VISIBILITY GNUOrAndroidEnvironment : public Generic_ELF {
public:
- Linux(const Driver &D, const llvm::Triple& Triple, const ArgList &Args);
+ GNUOrAndroidEnvironment(const Driver &D, const llvm::Triple& Triple,
+ const ArgList &Args);
virtual bool HasNativeLLVMSupport() const;
@@ -528,7 +531,7 @@ private:
ArgStringList &CC1Args);
};
-class LLVM_LIBRARY_VISIBILITY Hexagon_TC : public Linux {
+class LLVM_LIBRARY_VISIBILITY Hexagon_TC : public GNUOrAndroidEnvironment {
protected:
GCCVersion GCCLibAndIncVersion;
virtual Tool *buildAssembler() const;
diff --git lib/Driver/Tools.cpp lib/Driver/Tools.cpp
index 37e6abb..b80765f 100644
--- lib/Driver/Tools.cpp
+++ lib/Driver/Tools.cpp
@@ -5706,8 +5706,8 @@ void gnutools::Link::ConstructJob(Compilation &C, const JobAction &JA,
const InputInfoList &Inputs,
const ArgList &Args,
const char *LinkingOutput) const {
- const toolchains::Linux& ToolChain =
- static_cast<const toolchains::Linux&>(getToolChain());
+ const toolchains::GNUOrAndroidEnvironment& ToolChain =
+ static_cast<const toolchains::GNUOrAndroidEnvironment&>(getToolChain());
const Driver &D = ToolChain.getDriver();
const bool isAndroid =
ToolChain.getTriple().getEnvironment() == llvm::Triple::Android;
--
1.7.9.5
More information about the cfe-commits
mailing list