Index: include/clang/Driver/Distro.h =================================================================== --- include/clang/Driver/Distro.h +++ include/clang/Driver/Distro.h @@ -37,6 +37,7 @@ RHEL6, RHEL7, Fedora, + Mageia, OpenSUSE, UbuntuHardy, UbuntuIntrepid, @@ -112,6 +113,11 @@ bool IsUbuntu() const { return DistroVal >= UbuntuHardy && DistroVal <= UbuntuZesty; } + + bool IsMageia() const { + return DistroVal == Mageia; + } + /// @} }; Index: lib/Driver/Distro.cpp =================================================================== --- lib/Driver/Distro.cpp +++ lib/Driver/Distro.cpp @@ -127,6 +127,9 @@ if (VFS.exists("/etc/arch-release")) return Distro::ArchLinux; + + if (VFS.exists("/etc/mageia-release")) + return Distro::Mageia; return Distro::UnknownDistro; } Index: lib/Driver/ToolChains.cpp =================================================================== --- lib/Driver/ToolChains.cpp +++ lib/Driver/ToolChains.cpp @@ -1538,9 +1538,11 @@ static const char *const ARMLibDirs[] = {"/lib"}; static const char *const ARMTriples[] = {"arm-linux-gnueabi", - "arm-linux-androideabi"}; + "arm-linux-androideabi", + "armv5tl-mageia-linux-gnueabi"}; static const char *const ARMHFTriples[] = {"arm-linux-gnueabihf", - "armv7hl-redhat-linux-gnueabi"}; + "armv7hl-redhat-linux-gnueabi", + "armv7hl-mageia-linux-gnueabi"}; static const char *const ARMebLibDirs[] = {"/lib"}; static const char *const ARMebTriples[] = {"armeb-linux-gnueabi", "armeb-linux-androideabi"}; @@ -1554,7 +1556,7 @@ "x86_64-redhat-linux", "x86_64-suse-linux", "x86_64-manbo-linux-gnu", "x86_64-linux-gnu", "x86_64-slackware-linux", "x86_64-linux-android", - "x86_64-unknown-linux"}; + "x86_64-mageia-linux-gnu","x86_64-unknown-linux"}; static const char *const X32LibDirs[] = {"/libx32"}; static const char *const X86LibDirs[] = {"/lib32", "/lib"}; static const char *const X86Triples[] = { @@ -1562,7 +1564,7 @@ "i386-linux-gnu", "i386-redhat-linux6E", "i686-redhat-linux", "i586-redhat-linux", "i386-redhat-linux", "i586-suse-linux", "i486-slackware-linux", "i686-montavista-linux", "i686-linux-android", - "i586-linux-gnu"}; + "i586-mageia-linux-gnu","i586-linux-gnu"}; static const char *const MIPSLibDirs[] = {"/lib"}; static const char *const MIPSTriples[] = {"mips-linux-gnu", "mips-mti-linux", @@ -4095,7 +4097,7 @@ Distro Distro(D.getVFS()); - if (Distro.IsOpenSUSE() || Distro.IsUbuntu()) { + if (Distro.IsOpenSUSE() || Distro.IsUbuntu() || Distro.IsMageia()) { ExtraOpts.push_back("-z"); ExtraOpts.push_back("relro"); } @@ -4115,7 +4117,7 @@ // ABI requires a mapping between the GOT and the symbol table. // Android loader does not support .gnu.hash. if (!IsMips && !IsAndroid) { - if (Distro.IsRedhat() || Distro.IsOpenSUSE() || + if (Distro.IsRedhat() || Distro.IsOpenSUSE() || Distro.IsMageia() || (Distro.IsUbuntu() && Distro >= Distro::UbuntuMaverick)) ExtraOpts.push_back("--hash-style=gnu"); @@ -4124,7 +4126,8 @@ ExtraOpts.push_back("--hash-style=both"); } - if (Distro.IsRedhat() && Distro != Distro::RHEL5 && Distro != Distro::RHEL6) + if ((Distro.IsRedhat() && Distro != Distro::RHEL5 && Distro != Distro::RHEL6) || + (Distro.IsMageia())) ExtraOpts.push_back("--no-add-needed"); #ifdef ENABLE_LINKER_BUILD_ID @@ -4131,7 +4134,7 @@ ExtraOpts.push_back("--build-id"); #endif - if (Distro.IsOpenSUSE()) + if ((Distro.IsOpenSUSE()) || (Distro.IsMageia())) ExtraOpts.push_back("--enable-new-dtags"); // The selection of paths to try here is designed to match the patterns which Index: unittests/Driver/DistroTest.cpp =================================================================== --- unittests/Driver/DistroTest.cpp +++ unittests/Driver/DistroTest.cpp @@ -51,6 +51,7 @@ ASSERT_FALSE(UbuntuTrusty.IsRedhat()); ASSERT_FALSE(UbuntuTrusty.IsOpenSUSE()); ASSERT_FALSE(UbuntuTrusty.IsDebian()); + ASSERT_FALSE(UbuntuTrusty.IsMageia()); vfs::InMemoryFileSystem UbuntuYakketyFileSystem; UbuntuYakketyFileSystem.addFile("/etc/debian_version", 0, @@ -80,6 +81,7 @@ ASSERT_FALSE(UbuntuYakkety.IsRedhat()); ASSERT_FALSE(UbuntuYakkety.IsOpenSUSE()); ASSERT_FALSE(UbuntuYakkety.IsDebian()); + ASSERT_FALSE(UbuntuYakkety.IsMageia()); } TEST(DistroTest, DetectRedhat) { @@ -114,6 +116,7 @@ ASSERT_TRUE(Fedora25.IsRedhat()); ASSERT_FALSE(Fedora25.IsOpenSUSE()); ASSERT_FALSE(Fedora25.IsDebian()); + ASSERT_FALSE(Fedora25.IsMageia()); vfs::InMemoryFileSystem CentOS7FileSystem; CentOS7FileSystem.addFile("/etc/system-release-cpe", 0, @@ -150,6 +153,7 @@ ASSERT_TRUE(CentOS7.IsRedhat()); ASSERT_FALSE(CentOS7.IsOpenSUSE()); ASSERT_FALSE(CentOS7.IsDebian()); + ASSERT_FALSE(CentOS7.IsMageia()); } TEST(DistroTest, DetectOpenSUSE) { @@ -177,6 +181,7 @@ ASSERT_FALSE(OpenSUSELeap421.IsRedhat()); ASSERT_TRUE(OpenSUSELeap421.IsOpenSUSE()); ASSERT_FALSE(OpenSUSELeap421.IsDebian()); + ASSERT_FALSE(OpenSUSELeap421.IsMageia()); vfs::InMemoryFileSystem OpenSUSE132FileSystem; OpenSUSE132FileSystem.addFile("/etc/SuSE-release", 0, @@ -202,6 +207,7 @@ ASSERT_FALSE(OpenSUSE132.IsRedhat()); ASSERT_TRUE(OpenSUSE132.IsOpenSUSE()); ASSERT_FALSE(OpenSUSE132.IsDebian()); + ASSERT_FALSE(OpenSUSE132.IsMageia()); vfs::InMemoryFileSystem SLES10FileSystem; SLES10FileSystem.addFile("/etc/SuSE-release", 0, @@ -218,6 +224,7 @@ ASSERT_FALSE(SLES10.IsRedhat()); ASSERT_FALSE(SLES10.IsOpenSUSE()); ASSERT_FALSE(SLES10.IsDebian()); + ASSERT_FALSE(SLES10.IsMageia()); } TEST(DistroTest, DetectDebian) { @@ -240,6 +247,7 @@ ASSERT_FALSE(DebianJessie.IsRedhat()); ASSERT_FALSE(DebianJessie.IsOpenSUSE()); ASSERT_TRUE(DebianJessie.IsDebian()); + ASSERT_FALSE(DebianJessie.IsMageia()); vfs::InMemoryFileSystem DebianStretchSidFileSystem; DebianStretchSidFileSystem.addFile("/etc/debian_version", 0, @@ -258,6 +266,7 @@ ASSERT_FALSE(DebianStretchSid.IsRedhat()); ASSERT_FALSE(DebianStretchSid.IsOpenSUSE()); ASSERT_TRUE(DebianStretchSid.IsDebian()); + ASSERT_FALSE(DebianStretchSid.IsMageia()); } TEST(DistroTest, DetectExherbo) { @@ -279,6 +288,7 @@ ASSERT_FALSE(Exherbo.IsRedhat()); ASSERT_FALSE(Exherbo.IsOpenSUSE()); ASSERT_FALSE(Exherbo.IsDebian()); + ASSERT_FALSE(Exherbo.IsMageia()); } TEST(DistroTest, DetectArchLinux) { @@ -300,6 +310,32 @@ ASSERT_FALSE(ArchLinux.IsRedhat()); ASSERT_FALSE(ArchLinux.IsOpenSUSE()); ASSERT_FALSE(ArchLinux.IsDebian()); + ASSERT_FALSE(ArchLinux.IsMageia()); } +TEST(DistroTest, DetectMageia) { + vfs::InMemoryFileSystem curDistroFS; + curDistroFS.addFile("/etc/mageia-release", 0, // (empty) + llvm::MemoryBuffer::getMemBuffer("")); + curDistroFS.addFile("/etc/os-release", 0, + llvm::MemoryBuffer::getMemBuffer("NAME=\"Mageia\"\n" + "VERSION=\"6\"\n" + "ID=mageia\n" + "VERSION_ID=6\n" + "ID_LIKE=\"mandriva fedora\"\n" + "PRETTY_NAME=\"Mageia 6\"\n" + "ANSI_COLOR=\"1;36\"\n" + "HOME_URL=\"http://www.mageia.org/\"\n" + "SUPPORT_URL=\"http://www.mageia.org/support/\"\n" + "BUG_REPORT_URL=\"https://bugs.mageia.org/\"\n" + "PRIVACY_POLICY_URL=\"https://wiki.mageia.org/en/Privacy_policy\"\n")); + Distro curDistro{curDistroFS}; + ASSERT_EQ(Distro(Distro::Mageia), curDistro); + ASSERT_FALSE(curDistro.IsUbuntu()); + ASSERT_FALSE(curDistro.IsRedhat()); + ASSERT_FALSE(curDistro.IsOpenSUSE()); + ASSERT_FALSE(curDistro.IsDebian()); + ASSERT_TRUE(curDistro.IsMageia()); +} + } // end anonymous namespace