[PATCH] Introduce llvm:Triple::Hurd.
Thomas Schwinge
thomas at codesourcery.com
Mon Mar 25 09:02:26 PDT 2013
GNU Hurd, <http://www.gnu.org/software/hurd/>.
---
docs/CodeGenerator.rst | 2 ++
include/llvm/ADT/Triple.h | 3 ++-
include/llvm/MC/MCELFObjectWriter.h | 1 +
lib/Support/Triple.cpp | 10 +++++++++-
projects/sample/Makefile.llvm.rules | 2 +-
unittests/ADT/TripleTest.cpp | 11 ++++++++++-
utils/llvmgrep | 2 +-
7 files changed, 26 insertions(+), 5 deletions(-)
diff --git docs/CodeGenerator.rst docs/CodeGenerator.rst
index 75415ab..78be7ea 100644
--- docs/CodeGenerator.rst
+++ docs/CodeGenerator.rst
@@ -2118,6 +2118,8 @@ that people test.
* **x86_64-unknown-linux-gnu** --- Linux
+* **i386-unknown-gnu0.3-gnu** --- GNU/Hurd
+
X86 Calling Conventions supported
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
diff --git include/llvm/ADT/Triple.h include/llvm/ADT/Triple.h
index 8fac222..f76bbce 100644
--- include/llvm/ADT/Triple.h
+++ include/llvm/ADT/Triple.h
@@ -91,6 +91,7 @@ public:
IOS,
KFreeBSD,
Linux,
+ Hurd, // i686-unknown-gnu0.3
Lv2, // PS3
MacOSX,
MinGW32, // i*86-pc-mingw32, *-w64-mingw32
@@ -109,7 +110,7 @@ public:
enum EnvironmentType {
UnknownEnvironment,
- GNU,
+ GNU, // x86_64-unknown-linux-gnu, i686-unknown-gnu0.3
GNUEABI,
GNUEABIHF,
GNUX32,
diff --git include/llvm/MC/MCELFObjectWriter.h include/llvm/MC/MCELFObjectWriter.h
index 562648c..be69904 100644
--- include/llvm/MC/MCELFObjectWriter.h
+++ include/llvm/MC/MCELFObjectWriter.h
@@ -68,6 +68,7 @@ public:
case Triple::FreeBSD:
return ELF::ELFOSABI_FREEBSD;
case Triple::Linux:
+ case Triple::Hurd:
return ELF::ELFOSABI_GNU;
default:
return ELF::ELFOSABI_NONE;
diff --git lib/Support/Triple.cpp lib/Support/Triple.cpp
index d2508ac..7033067 100644
--- lib/Support/Triple.cpp
+++ lib/Support/Triple.cpp
@@ -118,6 +118,7 @@ const char *Triple::getOSTypeName(OSType Kind) {
case IOS: return "ios";
case KFreeBSD: return "kfreebsd";
case Linux: return "linux";
+ case Hurd: return "gnu";
case Lv2: return "lv2";
case MacOSX: return "macosx";
case MinGW32: return "mingw32";
@@ -268,6 +269,8 @@ static Triple::OSType parseOS(StringRef OSName) {
.StartsWith("ios", Triple::IOS)
.StartsWith("kfreebsd", Triple::KFreeBSD)
.StartsWith("linux", Triple::Linux)
+ // Do not just match for starting with "gnu" as that is too greedy.
+ .Cases("gnu", "gnu0.3", Triple::Hurd)
.StartsWith("lv2", Triple::Lv2)
.StartsWith("macosx", Triple::MacOSX)
.StartsWith("mingw32", Triple::MinGW32)
@@ -367,7 +370,12 @@ std::string Triple::normalize(StringRef Str) {
bool Found[4];
Found[0] = Arch != UnknownArch;
Found[1] = Vendor != UnknownVendor;
- Found[2] = OS != UnknownOS;
+ // If we found a "gnu" OS, this must not be final; allow that i386-linux-gnu
+ // can still be permuted into i386--linux-gnu, for example.
+ if (OS == Triple::Hurd)
+ Found[2] = false;
+ else
+ Found[2] = OS != UnknownOS;
Found[3] = Environment != UnknownEnvironment;
// If they are not there already, permute the components into their canonical
diff --git projects/sample/Makefile.llvm.rules projects/sample/Makefile.llvm.rules
index 30f54c4..0e4b9a7 100644
--- projects/sample/Makefile.llvm.rules
+++ projects/sample/Makefile.llvm.rules
@@ -1372,7 +1372,7 @@ LD.Flags += -Wl,-exported_symbol,_main
endif
endif
-ifeq ($(HOST_OS), $(filter $(HOST_OS), Linux NetBSD FreeBSD))
+ifeq ($(HOST_OS), $(filter $(HOST_OS), Linux NetBSD FreeBSD GNU))
ifneq ($(ARCH), Mips)
LD.Flags += -Wl,--version-script=$(PROJ_SRC_ROOT)/autoconf/ExportMap.map
endif
diff --git unittests/ADT/TripleTest.cpp unittests/ADT/TripleTest.cpp
index b402896..cff2d63 100644
--- unittests/ADT/TripleTest.cpp
+++ unittests/ADT/TripleTest.cpp
@@ -179,7 +179,6 @@ TEST(TripleTest, Normalization) {
EXPECT_EQ("-pc", Triple::normalize("pc"));
EXPECT_EQ("--linux", Triple::normalize("linux"));
- EXPECT_EQ("x86_64--linux-gnu", Triple::normalize("x86_64-gnu-linux"));
// Check that normalizing a permutated set of valid components returns a
// triple with the unpermuted components.
@@ -203,6 +202,13 @@ TEST(TripleTest, Normalization) {
for (int Env = 1+Triple::UnknownEnvironment; Env <= Triple::MachO;
++Env) {
+ // As "gnu" is used for both an OS and Environment name (and is thus
+ // accepted for both these fields), there will be a lot of "failures"
+ // detected in the following, so avoid testing these combinations.
+ if ((OS == Triple::Hurd && Env != Triple::GNU) ||
+ (OS != Triple::Hurd && Env == Triple::GNU))
+ continue;
+
C[3] = Triple::getEnvironmentTypeName(Triple::EnvironmentType(Env));
std::string F = Join(C[0], C[1], C[2], C[3]);
@@ -240,10 +246,13 @@ TEST(TripleTest, Normalization) {
// is given in the comment.
EXPECT_EQ("i386--mingw32", Triple::normalize("i386-mingw32")); // i386-pc-mingw32
EXPECT_EQ("x86_64--linux-gnu", Triple::normalize("x86_64-linux-gnu")); // x86_64-pc-linux-gnu
+ EXPECT_EQ("x86_64--linux-gnu", Triple::normalize("x86_64-gnu-linux")); // x86_64-gnu-linux-gnu
EXPECT_EQ("i486--linux-gnu", Triple::normalize("i486-linux-gnu")); // i486-pc-linux-gnu
EXPECT_EQ("i386-redhat-linux", Triple::normalize("i386-redhat-linux")); // i386-redhat-linux-gnu
EXPECT_EQ("i686--linux", Triple::normalize("i686-linux")); // i686-pc-linux-gnu
EXPECT_EQ("arm-none--eabi", Triple::normalize("arm-none-eabi")); // arm-none-eabi
+ EXPECT_EQ("i386--gnu", Triple::normalize("i386-gnu")); // i386-pc-gnu
+ EXPECT_EQ("i386--gnu0.3", Triple::normalize("i386-gnu0.3")); // i386-pc-gnu0.3
}
TEST(TripleTest, MutateName) {
diff --git utils/llvmgrep utils/llvmgrep
index dc15da4..9c704e6 100755
--- utils/llvmgrep
+++ utils/llvmgrep
@@ -29,7 +29,7 @@ if test -d "$TOPDIR" ; then
cd $TOPDIR
case `uname -s` in
SunOS) grep_cmd="ggrep -H -n" ;;
- Linux|Darwin) grep_cmd="egrep -H -n" ;;
+ Linux|GNU|Darwin) grep_cmd="egrep -H -n" ;;
*) grep_cmd="egrep -l -n" ;;
esac
./utils/llvmdo -topdir "$TOPDIR" \
--
1.7.9.5
More information about the llvm-commits
mailing list