[cfe-commits] r149869 - /cfe/trunk/lib/Driver/ToolChains.cpp
Benjamin Kramer
benny.kra at googlemail.com
Mon Feb 6 06:40:17 PST 2012
Author: d0k
Date: Mon Feb 6 08:36:09 2012
New Revision: 149869
URL: http://llvm.org/viewvc/llvm-project?rev=149869&view=rev
Log:
Consolidate the ubuntu detection logic a bit, add an entry for Ubuntu 12.04 aka precise pangolin.
Modified:
cfe/trunk/lib/Driver/ToolChains.cpp
Modified: cfe/trunk/lib/Driver/ToolChains.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/ToolChains.cpp?rev=149869&r1=149868&r2=149869&view=diff
==============================================================================
--- cfe/trunk/lib/Driver/ToolChains.cpp (original)
+++ cfe/trunk/lib/Driver/ToolChains.cpp Mon Feb 6 08:36:09 2012
@@ -1796,6 +1796,7 @@
UbuntuMaverick,
UbuntuNatty,
UbuntuOneiric,
+ UbuntuPrecise,
UnknownDistro
};
@@ -1816,10 +1817,7 @@
}
static bool IsUbuntu(enum LinuxDistro Distro) {
- return Distro == UbuntuHardy || Distro == UbuntuIntrepid ||
- Distro == UbuntuLucid || Distro == UbuntuMaverick ||
- Distro == UbuntuJaunty || Distro == UbuntuKarmic ||
- Distro == UbuntuNatty || Distro == UbuntuOneiric;
+ return Distro >= UbuntuHardy && Distro <= UbuntuPrecise;
}
static LinuxDistro DetectLinuxDistro(llvm::Triple::ArchType Arch) {
@@ -1828,25 +1826,21 @@
StringRef Data = File.get()->getBuffer();
SmallVector<StringRef, 8> Lines;
Data.split(Lines, "\n");
- for (unsigned int i = 0, s = Lines.size(); i < s; ++ i) {
- if (Lines[i] == "DISTRIB_CODENAME=hardy")
- return UbuntuHardy;
- else if (Lines[i] == "DISTRIB_CODENAME=intrepid")
- return UbuntuIntrepid;
- else if (Lines[i] == "DISTRIB_CODENAME=jaunty")
- return UbuntuJaunty;
- else if (Lines[i] == "DISTRIB_CODENAME=karmic")
- return UbuntuKarmic;
- else if (Lines[i] == "DISTRIB_CODENAME=lucid")
- return UbuntuLucid;
- else if (Lines[i] == "DISTRIB_CODENAME=maverick")
- return UbuntuMaverick;
- else if (Lines[i] == "DISTRIB_CODENAME=natty")
- return UbuntuNatty;
- else if (Lines[i] == "DISTRIB_CODENAME=oneiric")
- return UbuntuOneiric;
- }
- return UnknownDistro;
+ LinuxDistro Version = UnknownDistro;
+ for (unsigned i = 0, s = Lines.size(); i != s; ++i)
+ if (Version == UnknownDistro && Lines[i].startswith("DISTRIB_CODENAME="))
+ Version = llvm::StringSwitch<LinuxDistro>(Lines[i].substr(17))
+ .Case("hardy", UbuntuHardy)
+ .Case("intrepid", UbuntuIntrepid)
+ .Case("jaunty", UbuntuJaunty)
+ .Case("karmic", UbuntuKarmic)
+ .Case("lucid", UbuntuLucid)
+ .Case("maverick", UbuntuMaverick)
+ .Case("natty", UbuntuNatty)
+ .Case("oneiric", UbuntuOneiric)
+ .Case("precise", UbuntuPrecise)
+ .Default(UnknownDistro);
+ return Version;
}
if (!llvm::MemoryBuffer::getFile("/etc/redhat-release", File)) {
@@ -1983,8 +1977,8 @@
// ABI requires a mapping between the GOT and the symbol table.
// Android loader does not support .gnu.hash.
if (!IsMips && !IsAndroid) {
- if (IsRedhat(Distro) || IsOpenSuse(Distro) || Distro == UbuntuMaverick ||
- Distro == UbuntuNatty || Distro == UbuntuOneiric)
+ if (IsRedhat(Distro) || IsOpenSuse(Distro) ||
+ (IsUbuntu(Distro) && Distro >= UbuntuMaverick))
ExtraOpts.push_back("--hash-style=gnu");
if (IsDebian(Distro) || IsOpenSuse(Distro) || Distro == UbuntuLucid ||
@@ -1998,9 +1992,7 @@
if (Distro == DebianSqueeze || Distro == DebianWheezy ||
IsOpenSuse(Distro) ||
(IsRedhat(Distro) && Distro != RHEL4 && Distro != RHEL5) ||
- Distro == UbuntuLucid ||
- Distro == UbuntuMaverick || Distro == UbuntuKarmic ||
- Distro == UbuntuNatty || Distro == UbuntuOneiric)
+ (IsUbuntu(Distro) && Distro >= UbuntuKarmic))
ExtraOpts.push_back("--build-id");
if (IsOpenSuse(Distro))
More information about the cfe-commits
mailing list