From 02c14a6e9e031ae6413bfd1ece776c063cde41aa Mon Sep 17 00:00:00 2001 From: Fangrui Song Date: Thu, 25 Mar 2021 16:25:47 -0700 Subject: [PATCH] [Triple][Driver] Add muslx32 environment and use /lib/ld-musl-x32.so.1 for -dynamic-linker Differential Revision: https://reviews.llvm.org/D99308 --- include/llvm/ADT/Triple.h | 4 +++- lib/Support/Triple.cpp | 2 ++ unittests/ADT/TripleTest.cpp | 6 ++++++ 3 files changed, 11 insertions(+), 1 deletion(-) diff --git a/include/llvm/ADT/Triple.h b/include/llvm/ADT/Triple.h index 3b351b732e9..b6a6fe67b7a 100644 --- a/include/llvm/ADT/Triple.h +++ b/include/llvm/ADT/Triple.h @@ -218,6 +218,7 @@ public: Musl, MuslEABI, MuslEABIHF, + MuslX32, MSVC, Itanium, @@ -688,7 +689,8 @@ public: bool isMusl() const { return getEnvironment() == Triple::Musl || getEnvironment() == Triple::MuslEABI || - getEnvironment() == Triple::MuslEABIHF; + getEnvironment() == Triple::MuslEABIHF || + getEnvironment() == Triple::MuslX32; } /// Tests whether the target is SPIR (32- or 64-bit). diff --git a/lib/Support/Triple.cpp b/lib/Support/Triple.cpp index e5dd32fb582..3c2182ecb09 100644 --- a/lib/Support/Triple.cpp +++ b/lib/Support/Triple.cpp @@ -250,6 +250,7 @@ StringRef Triple::getEnvironmentTypeName(EnvironmentType Kind) { case Musl: return "musl"; case MuslEABI: return "musleabi"; case MuslEABIHF: return "musleabihf"; + case MuslX32: return "muslx32"; case Simulator: return "simulator"; } @@ -555,6 +556,7 @@ static Triple::EnvironmentType parseEnvironment(StringRef EnvironmentName) { .StartsWith("android", Triple::Android) .StartsWith("musleabihf", Triple::MuslEABIHF) .StartsWith("musleabi", Triple::MuslEABI) + .StartsWith("muslx32", Triple::MuslX32) .StartsWith("musl", Triple::Musl) .StartsWith("msvc", Triple::MSVC) .StartsWith("itanium", Triple::Itanium) diff --git a/unittests/ADT/TripleTest.cpp b/unittests/ADT/TripleTest.cpp index 0e49a1aa143..2e3c78aa4f6 100644 --- a/unittests/ADT/TripleTest.cpp +++ b/unittests/ADT/TripleTest.cpp @@ -111,6 +111,12 @@ TEST(TripleTest, ParsedIDs) { EXPECT_EQ(Triple::Linux, T.getOS()); EXPECT_EQ(Triple::Musl, T.getEnvironment()); + T = Triple("x86_64-pc-linux-muslx32"); + EXPECT_EQ(Triple::x86_64, T.getArch()); + EXPECT_EQ(Triple::PC, T.getVendor()); + EXPECT_EQ(Triple::Linux, T.getOS()); + EXPECT_EQ(Triple::MuslX32, T.getEnvironment()); + // PS4 has two spellings for the vendor. T = Triple("x86_64-scei-ps4"); EXPECT_EQ(Triple::x86_64, T.getArch());