[cfe-commits] r110028 - in /cfe/trunk/lib/Driver: HostInfo.cpp ToolChains.cpp ToolChains.h
Daniel Dunbar
daniel at zuster.org
Sun Aug 1 22:44:07 PDT 2010
Author: ddunbar
Date: Mon Aug 2 00:44:07 2010
New Revision: 110028
URL: http://llvm.org/viewvc/llvm-project?rev=110028&view=rev
Log:
Driver/Darwin: Change where Darwin computes the host version, to normalize tool
chain construction.
Modified:
cfe/trunk/lib/Driver/HostInfo.cpp
cfe/trunk/lib/Driver/ToolChains.cpp
cfe/trunk/lib/Driver/ToolChains.h
Modified: cfe/trunk/lib/Driver/HostInfo.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/HostInfo.cpp?rev=110028&r1=110027&r2=110028&view=diff
==============================================================================
--- cfe/trunk/lib/Driver/HostInfo.cpp (original)
+++ cfe/trunk/lib/Driver/HostInfo.cpp Mon Aug 2 00:44:07 2010
@@ -38,9 +38,6 @@
/// DarwinHostInfo - Darwin host information implementation.
class DarwinHostInfo : public HostInfo {
- /// Darwin version of host.
- unsigned DarwinVersion[3];
-
/// Cache of tool chains we have created.
mutable llvm::DenseMap<unsigned, ToolChain*> ToolChains;
@@ -56,15 +53,6 @@
DarwinHostInfo::DarwinHostInfo(const Driver &D, const llvm::Triple& Triple)
: HostInfo(D, Triple) {
-
- assert(Triple.getArch() != llvm::Triple::UnknownArch && "Invalid arch!");
- assert(memcmp(&getOSName()[0], "darwin", 6) == 0 &&
- "Unknown Darwin platform.");
- bool HadExtra;
- if (!Driver::GetReleaseVersion(&getOSName()[6],
- DarwinVersion[0], DarwinVersion[1],
- DarwinVersion[2], HadExtra))
- D.Diag(clang::diag::err_drv_invalid_darwin_version) << getOSName();
}
DarwinHostInfo::~DarwinHostInfo() {
@@ -128,10 +116,10 @@
const char *UseNewToolChain = ::getenv("CCC_ENABLE_NEW_DARWIN_TOOLCHAIN");
if (UseNewToolChain ||
Arch == llvm::Triple::arm || Arch == llvm::Triple::thumb) {
- TC = new toolchains::DarwinClang(*this, TCTriple, DarwinVersion);
+ TC = new toolchains::DarwinClang(*this, TCTriple);
} else if (Arch == llvm::Triple::x86 || Arch == llvm::Triple::x86_64) {
// We still use the legacy DarwinGCC toolchain on X86.
- TC = new toolchains::DarwinGCC(*this, TCTriple, DarwinVersion);
+ TC = new toolchains::DarwinGCC(*this, TCTriple);
} else
TC = new toolchains::Darwin_Generic_GCC(*this, TCTriple);
}
Modified: cfe/trunk/lib/Driver/ToolChains.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/ToolChains.cpp?rev=110028&r1=110027&r2=110028&view=diff
==============================================================================
--- cfe/trunk/lib/Driver/ToolChains.cpp (original)
+++ cfe/trunk/lib/Driver/ToolChains.cpp Mon Aug 2 00:44:07 2010
@@ -31,13 +31,20 @@
/// Darwin - Darwin tool chain for i386 and x86_64.
-Darwin::Darwin(const HostInfo &Host, const llvm::Triple& Triple,
- const unsigned (&_DarwinVersion)[3])
+Darwin::Darwin(const HostInfo &Host, const llvm::Triple& Triple)
: ToolChain(Host, Triple), TargetInitialized(false)
{
+ // Compute the initial Darwin version based on the host.
+ bool HadExtra;
+ std::string OSName = Triple.getOSName();
+ if (!Driver::GetReleaseVersion(&OSName[6],
+ DarwinVersion[0], DarwinVersion[1],
+ DarwinVersion[2], HadExtra))
+ getDriver().Diag(clang::diag::err_drv_invalid_darwin_version) << OSName;
+
llvm::raw_string_ostream(MacosxVersionMin)
- << "10." << std::max(0, (int)_DarwinVersion[0] - 4) << '.'
- << _DarwinVersion[1];
+ << "10." << std::max(0, (int)DarwinVersion[0] - 4) << '.'
+ << DarwinVersion[1];
}
types::ID Darwin::LookupTypeForExtension(const char *Ext) const {
@@ -113,9 +120,8 @@
}
}
-DarwinGCC::DarwinGCC(const HostInfo &Host, const llvm::Triple& Triple,
- const unsigned (&DarwinVersion)[3])
- : Darwin(Host, Triple, DarwinVersion)
+DarwinGCC::DarwinGCC(const HostInfo &Host, const llvm::Triple& Triple)
+ : Darwin(Host, Triple)
{
// We can only work with 4.2.1 currently.
GCCVersion[0] = 4;
@@ -326,9 +332,8 @@
}
}
-DarwinClang::DarwinClang(const HostInfo &Host, const llvm::Triple& Triple,
- const unsigned (&DarwinVersion)[3])
- : Darwin(Host, Triple, DarwinVersion)
+DarwinClang::DarwinClang(const HostInfo &Host, const llvm::Triple& Triple)
+ : Darwin(Host, Triple)
{
// We expect 'as', 'ld', etc. to be adjacent to our install dir.
getProgramPaths().push_back(getDriver().getInstalledDir());
Modified: cfe/trunk/lib/Driver/ToolChains.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/ToolChains.h?rev=110028&r1=110027&r2=110028&view=diff
==============================================================================
--- cfe/trunk/lib/Driver/ToolChains.h (original)
+++ cfe/trunk/lib/Driver/ToolChains.h Mon Aug 2 00:44:07 2010
@@ -42,6 +42,11 @@
/// Darwin - The base Darwin tool chain.
class LLVM_LIBRARY_VISIBILITY Darwin : public ToolChain {
+public:
+ /// The host version.
+ unsigned DarwinVersion[3];
+
+private:
mutable llvm::DenseMap<unsigned, Tool*> Tools;
/// Whether the information on the target has been initialized.
@@ -65,8 +70,7 @@
void AddDeploymentTarget(DerivedArgList &Args) const;
public:
- Darwin(const HostInfo &Host, const llvm::Triple& Triple,
- const unsigned (&DarwinVersion)[3]);
+ Darwin(const HostInfo &Host, const llvm::Triple& Triple);
~Darwin();
/// @name Darwin Specific Toolchain API
@@ -204,8 +208,7 @@
/// DarwinClang - The Darwin toolchain used by Clang.
class LLVM_LIBRARY_VISIBILITY DarwinClang : public Darwin {
public:
- DarwinClang(const HostInfo &Host, const llvm::Triple& Triple,
- const unsigned (&DarwinVersion)[3]);
+ DarwinClang(const HostInfo &Host, const llvm::Triple& Triple);
/// @name Darwin ToolChain Implementation
/// {
@@ -228,8 +231,7 @@
std::string ToolChainDir;
public:
- DarwinGCC(const HostInfo &Host, const llvm::Triple& Triple,
- const unsigned (&DarwinVersion)[3]);
+ DarwinGCC(const HostInfo &Host, const llvm::Triple& Triple);
/// @name Darwin ToolChain Implementation
/// {
More information about the cfe-commits
mailing list