diff options
| author | Benjamin Kramer <benny.kra@googlemail.com> | 2012-02-06 14:36:09 +0000 |
|---|---|---|
| committer | Benjamin Kramer <benny.kra@googlemail.com> | 2012-02-06 14:36:09 +0000 |
| commit | 7c3f09d416fc93e50b32c9a9d37f4fece189c0ea (patch) | |
| tree | 4661c7125d699d3b616162bd017e626c05b5676c /clang/lib/Driver/ToolChains.cpp | |
| parent | 65f7c3dba22f0a1da715911b5395255528a9fda9 (diff) | |
| download | bcm5719-llvm-7c3f09d416fc93e50b32c9a9d37f4fece189c0ea.tar.gz bcm5719-llvm-7c3f09d416fc93e50b32c9a9d37f4fece189c0ea.zip | |
Consolidate the ubuntu detection logic a bit, add an entry for Ubuntu 12.04 aka precise pangolin.
llvm-svn: 149869
Diffstat (limited to 'clang/lib/Driver/ToolChains.cpp')
| -rw-r--r-- | clang/lib/Driver/ToolChains.cpp | 48 |
1 files changed, 20 insertions, 28 deletions
diff --git a/clang/lib/Driver/ToolChains.cpp b/clang/lib/Driver/ToolChains.cpp index 48d798b9906..15492774a5c 100644 --- a/clang/lib/Driver/ToolChains.cpp +++ b/clang/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<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 @@ 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)) |

