[PATCH] D56024: [clang] [Distro] Support detecting Gentoo

Michał Górny via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Fri Dec 21 14:11:31 PST 2018


mgorny created this revision.
mgorny added reviewers: sylvestre.ledru, bruno, bkramer, phosek.

Add support for distinguishing plain Gentoo distribution, and a unit
test for it.  This is going to be used to introduce distro-specific
customizations in the driver code; most notably, it is going to be used
to disable -faddrsig.


Repository:
  rC Clang

https://reviews.llvm.org/D56024

Files:
  include/clang/Driver/Distro.h
  lib/Driver/Distro.cpp
  unittests/Driver/DistroTest.cpp


Index: unittests/Driver/DistroTest.cpp
===================================================================
--- unittests/Driver/DistroTest.cpp
+++ unittests/Driver/DistroTest.cpp
@@ -302,4 +302,28 @@
   ASSERT_FALSE(ArchLinux.IsDebian());
 }
 
+TEST(DistroTest, DetectGentoo) {
+  llvm::vfs::InMemoryFileSystem GentooFileSystem;
+  GentooFileSystem.addFile(
+      "/etc/gentoo-release", 0,
+      llvm::MemoryBuffer::getMemBuffer("Gentoo Base System release 2.6"));
+  GentooFileSystem.addFile(
+      "/etc/os-release", 0,
+      llvm::MemoryBuffer::getMemBuffer(
+          "NAME=Gentoo\n"
+          "ID=gentoo\n"
+          "PRETTY_NAME=\"Gentoo/Linux\"\n"
+          "ANSI_COLOR=\"1;32\"\n"
+          "HOME_URL=\"https://www.gentoo.org/\"\n"
+          "SUPPORT_URL=\"https://www.gentoo.org/support/\"\n"
+          "BUG_REPORT_URL=\"https://bugs.gentoo.org/\"\n"));
+
+  Distro Gentoo{GentooFileSystem};
+  ASSERT_EQ(Distro(Distro::Gentoo), Gentoo);
+  ASSERT_FALSE(Gentoo.IsUbuntu());
+  ASSERT_FALSE(Gentoo.IsRedhat());
+  ASSERT_FALSE(Gentoo.IsOpenSUSE());
+  ASSERT_FALSE(Gentoo.IsDebian());
+}
+
 } // end anonymous namespace
Index: lib/Driver/Distro.cpp
===================================================================
--- lib/Driver/Distro.cpp
+++ lib/Driver/Distro.cpp
@@ -138,6 +138,9 @@
   if (VFS.exists("/etc/arch-release"))
     return Distro::ArchLinux;
 
+  if (VFS.exists("/etc/gentoo-release"))
+    return Distro::Gentoo;
+
   return Distro::UnknownDistro;
 }
 
Index: include/clang/Driver/Distro.h
===================================================================
--- include/clang/Driver/Distro.h
+++ include/clang/Driver/Distro.h
@@ -39,6 +39,7 @@
     RHEL6,
     RHEL7,
     Fedora,
+    Gentoo,
     OpenSUSE,
     UbuntuHardy,
     UbuntuIntrepid,


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D56024.179353.patch
Type: text/x-patch
Size: 1786 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20181221/b020c032/attachment.bin>


More information about the cfe-commits mailing list