From: Benjamin Kramer Date: Mon, 6 Feb 2012 14:36:09 +0000 (+0000) Subject: Consolidate the ubuntu detection logic a bit, add an entry for Ubuntu 12.04 aka preci... X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=668ecd9c8d428bdb2cd3566c8caf83b870609b4a;p=clang Consolidate the ubuntu detection logic a bit, add an entry for Ubuntu 12.04 aka precise pangolin. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@149869 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/lib/Driver/ToolChains.cpp b/lib/Driver/ToolChains.cpp index 48d798b990..15492774a5 100644 --- a/lib/Driver/ToolChains.cpp +++ b/lib/Driver/ToolChains.cpp @@ -1796,6 +1796,7 @@ enum LinuxDistro { UbuntuMaverick, UbuntuNatty, UbuntuOneiric, + UbuntuPrecise, UnknownDistro }; @@ -1816,10 +1817,7 @@ static bool IsDebian(enum LinuxDistro Distro) { } 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 @@ static LinuxDistro DetectLinuxDistro(llvm::Triple::ArchType Arch) { StringRef Data = File.get()->getBuffer(); SmallVector 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(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 @@ Linux::Linux(const Driver &D, const llvm::Triple &Triple) // 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 @@ Linux::Linux(const Driver &D, const llvm::Triple &Triple) 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))