[PATCH] D99308: [Triple][Driver] Add muslx32 environment and use /lib/ld-musl-x32.so.1 for -dynamic-linker
Fangrui Song via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Wed Mar 24 16:40:27 PDT 2021
MaskRay created this revision.
MaskRay added reviewers: compnerd, raj.khem.
Herald added subscribers: dexonsmith, hiraditya.
MaskRay requested review of this revision.
Herald added projects: clang, LLVM.
Herald added subscribers: llvm-commits, cfe-commits.
Repository:
rG LLVM Github Monorepo
https://reviews.llvm.org/D99308
Files:
clang/lib/Driver/ToolChains/Linux.cpp
clang/test/Driver/linux-cross.cpp
llvm/include/llvm/ADT/Triple.h
llvm/lib/Support/Triple.cpp
llvm/unittests/ADT/TripleTest.cpp
Index: llvm/unittests/ADT/TripleTest.cpp
===================================================================
--- llvm/unittests/ADT/TripleTest.cpp
+++ llvm/unittests/ADT/TripleTest.cpp
@@ -111,6 +111,12 @@
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());
Index: llvm/lib/Support/Triple.cpp
===================================================================
--- llvm/lib/Support/Triple.cpp
+++ llvm/lib/Support/Triple.cpp
@@ -250,6 +250,7 @@
case Musl: return "musl";
case MuslEABI: return "musleabi";
case MuslEABIHF: return "musleabihf";
+ case MuslX32: return "muslx32";
case Simulator: return "simulator";
}
@@ -555,6 +556,7 @@
.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)
Index: llvm/include/llvm/ADT/Triple.h
===================================================================
--- llvm/include/llvm/ADT/Triple.h
+++ llvm/include/llvm/ADT/Triple.h
@@ -218,6 +218,7 @@
Musl,
MuslEABI,
MuslEABIHF,
+ MuslX32,
MSVC,
Itanium,
@@ -688,7 +689,8 @@
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).
Index: clang/test/Driver/linux-cross.cpp
===================================================================
--- clang/test/Driver/linux-cross.cpp
+++ clang/test/Driver/linux-cross.cpp
@@ -70,3 +70,12 @@
// DEBIAN_AARCH64-SAME: {{^}} "-L[[SYSROOT]]/usr/lib/gcc-cross/aarch64-linux-gnu/10/../../.."
// DEBIAN_AARCH64-SAME: {{^}} "-L[[SYSROOT]]/lib"
// DEBIAN_AARCH64-SAME: {{^}} "-L[[SYSROOT]]/usr/lib"
+
+/// LDSO_ARCH is i386 for all x86-32 variants.
+// RUN: %clang -### %s --target=i686-linux-musl --sysroot= \
+// RUN: --stdlib=platform --rtlib=platform 2>&1 | FileCheck %s --check-prefix=MUSL_I686
+// MUSL_I686: "-dynamic-linker" "/lib/ld-musl-i386.so.1"
+
+// RUN: %clang -### %s --target=x86_64-linux-muslx32 --sysroot= \
+// RUN: --stdlib=platform --rtlib=platform 2>&1 | FileCheck %s --check-prefix=MUSL_X32
+// MUSL_X32: "-dynamic-linker" "/lib/ld-musl-i386.so.1"
Index: clang/lib/Driver/ToolChains/Linux.cpp
===================================================================
--- clang/lib/Driver/ToolChains/Linux.cpp
+++ clang/lib/Driver/ToolChains/Linux.cpp
@@ -398,6 +398,11 @@
ArchName = "armeb";
IsArm = true;
break;
+ case llvm::Triple::x86_64:
+ ArchName = Triple.getEnvironment() == llvm::Triple::MuslX32
+ ? "x32"
+ : Triple.getArchName().str();
+ break;
default:
ArchName = Triple.getArchName().str();
}
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D99308.333175.patch
Type: text/x-patch
Size: 3424 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20210324/6c1b459a/attachment-0001.bin>
More information about the cfe-commits
mailing list