Index: include/llvm/ADT/Triple.h =================================================================== --- include/llvm/ADT/Triple.h +++ include/llvm/ADT/Triple.h @@ -176,7 +176,8 @@ WatchOS, // Apple watchOS Mesa3D, Contiki, - LastOSType = Contiki + Hurd, + LastOSType = Hurd }; enum EnvironmentType { UnknownEnvironment, Index: lib/Support/Triple.cpp =================================================================== --- lib/Support/Triple.cpp +++ lib/Support/Triple.cpp @@ -201,6 +201,7 @@ case WatchOS: return "watchos"; case Mesa3D: return "mesa3d"; case Contiki: return "contiki"; + case Hurd: return "gnu"; } llvm_unreachable("Invalid OSType"); @@ -481,6 +482,7 @@ .StartsWith("watchos", Triple::WatchOS) .StartsWith("mesa3d", Triple::Mesa3D) .StartsWith("contiki", Triple::Contiki) + .StartsWith("gnu0", Triple::Hurd) .Default(Triple::UnknownOS); } Index: unittests/ADT/TripleTest.cpp =================================================================== --- unittests/ADT/TripleTest.cpp +++ unittests/ADT/TripleTest.cpp @@ -290,6 +290,12 @@ EXPECT_EQ(Triple::Linux, T.getOS()); EXPECT_EQ(Triple::GNUEABI, T.getEnvironment()); + T = Triple("i686-unknown-gnu0.9"); + EXPECT_EQ(Triple::x86, T.getArch()); + EXPECT_EQ(Triple::UnknownVendor, T.getVendor()); + EXPECT_EQ(Triple::Hurd, T.getOS()); + EXPECT_EQ(Triple::UnknownEnvironment, T.getEnvironment()); + T = Triple("huh"); EXPECT_EQ(Triple::UnknownArch, T.getArch()); } @@ -391,6 +397,12 @@ for (int OS = FirstOSType; OS <= Triple::LastOSType; ++OS) { if (OS == Triple::Win32) continue; + // We skip the Hurd OS, as permutations of it (whose string is "gnu") + // might produce different results than expected -- it could be + // misrecognized as environment, when placed as last element in the + // permutation. + if (OS == Triple::Hurd) + continue; StringRef C[] = {InitialC[0], InitialC[1], InitialC[2], InitialC[3]}; C[2] = Triple::getOSTypeName(Triple::OSType(OS)); std::string E = Join(C[0], C[1], C[2]);