[PATCH] D54378: Add Hurd triplet

Samuel Thibault via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Sat Nov 10 16:42:42 PST 2018


sthibaul updated this revision to Diff 173541.
sthibaul added a comment.
Herald added a subscriber: mgorny.

Perhaps we could go this way with additional code in cmake/config-ix.cmake, to get "hurd-gnu" as soon as possible just after detection and keep everything else inside llvm straight with llvm conventions?


Repository:
  rL LLVM

https://reviews.llvm.org/D54378

Files:
  cmake/config-ix.cmake
  include/llvm/ADT/Triple.h
  lib/Support/Triple.cpp
  unittests/ADT/TripleTest.cpp


Index: unittests/ADT/TripleTest.cpp
===================================================================
--- unittests/ADT/TripleTest.cpp
+++ unittests/ADT/TripleTest.cpp
@@ -93,6 +93,12 @@
   EXPECT_EQ(Triple::Contiki, T.getOS());
   EXPECT_EQ(Triple::UnknownEnvironment, T.getEnvironment());
 
+  T = Triple("i386-pc-hurd-gnu");
+  EXPECT_EQ(Triple::x86, T.getArch());
+  EXPECT_EQ(Triple::PC, T.getVendor());
+  EXPECT_EQ(Triple::Hurd, T.getOS());
+  EXPECT_EQ(Triple::GNU, T.getEnvironment());
+
   T = Triple("x86_64-pc-linux-gnu");
   EXPECT_EQ(Triple::x86_64, T.getArch());
   EXPECT_EQ(Triple::PC, T.getVendor());
Index: lib/Support/Triple.cpp
===================================================================
--- lib/Support/Triple.cpp
+++ lib/Support/Triple.cpp
@@ -210,6 +210,7 @@
   case Contiki: return "contiki";
   case AMDPAL: return "amdpal";
   case HermitCore: return "hermit";
+  case Hurd: return "hurd";
   }
 
   llvm_unreachable("Invalid OSType");
@@ -508,6 +509,7 @@
     .StartsWith("contiki", Triple::Contiki)
     .StartsWith("amdpal", Triple::AMDPAL)
     .StartsWith("hermit", Triple::HermitCore)
+    .StartsWith("hurd", Triple::Hurd)
     .Default(Triple::UnknownOS);
 }
 
Index: include/llvm/ADT/Triple.h
===================================================================
--- include/llvm/ADT/Triple.h
+++ include/llvm/ADT/Triple.h
@@ -186,7 +186,8 @@
     Contiki,
     AMDPAL,     // AMD PAL Runtime
     HermitCore, // HermitCore Unikernel/Multikernel
-    LastOSType = HermitCore
+    Hurd,       // GNU/Hurd
+    LastOSType = Hurd
   };
   enum EnvironmentType {
     UnknownEnvironment,
@@ -582,9 +583,15 @@
     return getOS() == Triple::KFreeBSD;
   }
 
+  /// Tests whether the OS is Hurd.
+  bool isOSHurd() const {
+    return getOS() == Triple::Hurd;
+  }
+
   /// Tests whether the OS uses glibc.
   bool isOSGlibc() const {
-    return (getOS() == Triple::Linux || getOS() == Triple::KFreeBSD) &&
+    return (getOS() == Triple::Linux || getOS() == Triple::KFreeBSD ||
+            getOS() == Triple::Hurd) &&
            !isAndroid();
   }
 
Index: cmake/config-ix.cmake
===================================================================
--- cmake/config-ix.cmake
+++ cmake/config-ix.cmake
@@ -359,6 +359,11 @@
 include(GetHostTriple)
 get_host_triple(LLVM_INFERRED_HOST_TRIPLE)
 
+# GNU/Hurd's triplet does not contain the "system" part, add it
+string(REPLACE "-unknown-gnu" "-unknown-hurd-gnu" LLVM_INFERRED_HOST_TRIPLE ${LLVM_INFERRED_HOST_TRIPLE})
+string(REPLACE "-pc-gnu" "-pc-hurd-gnu" LLVM_INFERRED_HOST_TRIPLE ${LLVM_INFERRED_HOST_TRIPLE})
+string(REGEX REPLACE "-hurd-gnu[0-9.]*" "-hurd-gnu" LLVM_INFERRED_HOST_TRIPLE ${LLVM_INFERRED_HOST_TRIPLE})
+
 set(LLVM_HOST_TRIPLE "${LLVM_INFERRED_HOST_TRIPLE}" CACHE STRING
     "Host on which LLVM binaries will run")
 


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D54378.173541.patch
Type: text/x-patch
Size: 2825 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20181111/ed7d43d4/attachment.bin>


More information about the llvm-commits mailing list