[clang] [llvm] [OpenEmbedded] Fix include and lib paths for multilib targets (PR #121302)
via llvm-commits
llvm-commits at lists.llvm.org
Sun Dec 29 12:06:45 PST 2024
llvmbot wrote:
<!--LLVM PR SUMMARY COMMENT-->
@llvm/pr-subscribers-clang
Author: Mike Crowe (mikecrowe)
<details>
<summary>Changes</summary>
The fix in e9ddc44a604318739a27249d267aa7267d13d93b wasn't enough for multilib targets since they use a custom vendor that contains the multilib variant. There are two common multilib variants: lib32 and libx32, so let's support both.
---
Full diff: https://github.com/llvm/llvm-project/pull/121302.diff
16 Files Affected:
- (added) clang/test/Driver/Inputs/openembedded_arm_multilib_lib32_linux_tree/usr/include/c++/9.5.0/backward/.keep ()
- (added) clang/test/Driver/Inputs/openembedded_arm_multilib_lib32_linux_tree/usr/lib/arm-oemllib32-linux-gnueabi/9.5.0/crtbegin.o ()
- (added) clang/test/Driver/Inputs/openembedded_arm_multilib_lib32_linux_tree/usr/lib/arm-oemllib32-linux-gnueabi/9.5.0/crtend.o ()
- (added) clang/test/Driver/Inputs/openembedded_arm_multilib_lib32_linux_tree/usr/lib/crt1.o ()
- (added) clang/test/Driver/Inputs/openembedded_arm_multilib_lib32_linux_tree/usr/lib/crti.o ()
- (added) clang/test/Driver/Inputs/openembedded_arm_multilib_lib32_linux_tree/usr/lib/crtn.o ()
- (added) clang/test/Driver/Inputs/openembedded_x86_64_multilib_libx32_linux_tree/usr/include/c++/14.2.0/backward/.keep ()
- (added) clang/test/Driver/Inputs/openembedded_x86_64_multilib_libx32_linux_tree/usr/libx32/crt1.o ()
- (added) clang/test/Driver/Inputs/openembedded_x86_64_multilib_libx32_linux_tree/usr/libx32/crti.o ()
- (added) clang/test/Driver/Inputs/openembedded_x86_64_multilib_libx32_linux_tree/usr/libx32/crtn.o ()
- (added) clang/test/Driver/Inputs/openembedded_x86_64_multilib_libx32_linux_tree/usr/libx32/x86_64-oemllibx32-linux-gnux32/14.2.0/crtbegin.o ()
- (added) clang/test/Driver/Inputs/openembedded_x86_64_multilib_libx32_linux_tree/usr/libx32/x86_64-oemllibx32-linux-gnux32/14.2.0/crtend.o ()
- (modified) clang/test/Driver/linux-header-search.cpp (+22)
- (modified) clang/test/Driver/linux-ld.c (+36)
- (modified) llvm/lib/TargetParser/Triple.cpp (+2)
- (modified) llvm/unittests/TargetParser/TripleTest.cpp (+12)
``````````diff
diff --git a/clang/test/Driver/Inputs/openembedded_arm_multilib_lib32_linux_tree/usr/include/c++/9.5.0/backward/.keep b/clang/test/Driver/Inputs/openembedded_arm_multilib_lib32_linux_tree/usr/include/c++/9.5.0/backward/.keep
new file mode 100644
index 00000000000000..e69de29bb2d1d6
diff --git a/clang/test/Driver/Inputs/openembedded_arm_multilib_lib32_linux_tree/usr/lib/arm-oemllib32-linux-gnueabi/9.5.0/crtbegin.o b/clang/test/Driver/Inputs/openembedded_arm_multilib_lib32_linux_tree/usr/lib/arm-oemllib32-linux-gnueabi/9.5.0/crtbegin.o
new file mode 100644
index 00000000000000..e69de29bb2d1d6
diff --git a/clang/test/Driver/Inputs/openembedded_arm_multilib_lib32_linux_tree/usr/lib/arm-oemllib32-linux-gnueabi/9.5.0/crtend.o b/clang/test/Driver/Inputs/openembedded_arm_multilib_lib32_linux_tree/usr/lib/arm-oemllib32-linux-gnueabi/9.5.0/crtend.o
new file mode 100644
index 00000000000000..e69de29bb2d1d6
diff --git a/clang/test/Driver/Inputs/openembedded_arm_multilib_lib32_linux_tree/usr/lib/crt1.o b/clang/test/Driver/Inputs/openembedded_arm_multilib_lib32_linux_tree/usr/lib/crt1.o
new file mode 100644
index 00000000000000..e69de29bb2d1d6
diff --git a/clang/test/Driver/Inputs/openembedded_arm_multilib_lib32_linux_tree/usr/lib/crti.o b/clang/test/Driver/Inputs/openembedded_arm_multilib_lib32_linux_tree/usr/lib/crti.o
new file mode 100644
index 00000000000000..e69de29bb2d1d6
diff --git a/clang/test/Driver/Inputs/openembedded_arm_multilib_lib32_linux_tree/usr/lib/crtn.o b/clang/test/Driver/Inputs/openembedded_arm_multilib_lib32_linux_tree/usr/lib/crtn.o
new file mode 100644
index 00000000000000..e69de29bb2d1d6
diff --git a/clang/test/Driver/Inputs/openembedded_x86_64_multilib_libx32_linux_tree/usr/include/c++/14.2.0/backward/.keep b/clang/test/Driver/Inputs/openembedded_x86_64_multilib_libx32_linux_tree/usr/include/c++/14.2.0/backward/.keep
new file mode 100644
index 00000000000000..e69de29bb2d1d6
diff --git a/clang/test/Driver/Inputs/openembedded_x86_64_multilib_libx32_linux_tree/usr/libx32/crt1.o b/clang/test/Driver/Inputs/openembedded_x86_64_multilib_libx32_linux_tree/usr/libx32/crt1.o
new file mode 100644
index 00000000000000..e69de29bb2d1d6
diff --git a/clang/test/Driver/Inputs/openembedded_x86_64_multilib_libx32_linux_tree/usr/libx32/crti.o b/clang/test/Driver/Inputs/openembedded_x86_64_multilib_libx32_linux_tree/usr/libx32/crti.o
new file mode 100644
index 00000000000000..e69de29bb2d1d6
diff --git a/clang/test/Driver/Inputs/openembedded_x86_64_multilib_libx32_linux_tree/usr/libx32/crtn.o b/clang/test/Driver/Inputs/openembedded_x86_64_multilib_libx32_linux_tree/usr/libx32/crtn.o
new file mode 100644
index 00000000000000..e69de29bb2d1d6
diff --git a/clang/test/Driver/Inputs/openembedded_x86_64_multilib_libx32_linux_tree/usr/libx32/x86_64-oemllibx32-linux-gnux32/14.2.0/crtbegin.o b/clang/test/Driver/Inputs/openembedded_x86_64_multilib_libx32_linux_tree/usr/libx32/x86_64-oemllibx32-linux-gnux32/14.2.0/crtbegin.o
new file mode 100644
index 00000000000000..e69de29bb2d1d6
diff --git a/clang/test/Driver/Inputs/openembedded_x86_64_multilib_libx32_linux_tree/usr/libx32/x86_64-oemllibx32-linux-gnux32/14.2.0/crtend.o b/clang/test/Driver/Inputs/openembedded_x86_64_multilib_libx32_linux_tree/usr/libx32/x86_64-oemllibx32-linux-gnux32/14.2.0/crtend.o
new file mode 100644
index 00000000000000..e69de29bb2d1d6
diff --git a/clang/test/Driver/linux-header-search.cpp b/clang/test/Driver/linux-header-search.cpp
index 70a85deac89e40..8ec84e1e93d2c1 100644
--- a/clang/test/Driver/linux-header-search.cpp
+++ b/clang/test/Driver/linux-header-search.cpp
@@ -309,6 +309,28 @@
// CHECK-OE-AARCH64: "-internal-isystem" "[[SYSROOT]]/usr/lib64/aarch64-oe-linux/6.3.0/../../../include/c++/6.3.0"
// CHECK-OE-AARCH64: "-internal-isystem" "[[SYSROOT]]/usr/lib64/aarch64-oe-linux/6.3.0/../../../include/c++/6.3.0/backward"
+// Check header search on OpenEmbedded multilib lib32.
+// RUN: %clang -### %s -fsyntax-only 2>&1 \
+// RUN: --target=arm-oemllib32-linux-gnueabi -stdlib=libstdc++ \
+// RUN: --sysroot=%S/Inputs/openembedded_arm_multilib_lib32_linux_tree \
+// RUN: | FileCheck --check-prefix=CHECK-OE-ARM-MULTILIB-LIB32 %s
+
+// CHECK-OE-ARM-MULTILIB-LIB32: "-cc1"
+// CHECK-OE-ARM-MULTILIB-LIB32: "-isysroot" "[[SYSROOT:[^"]+]]"
+// CHECK-OE-ARM-MULTILIB-LIB32: "-internal-isystem" "[[SYSROOT]]/usr/lib/arm-oemllib32-linux-gnueabi/9.5.0/../../../include/c++/9.5.0"
+// CHECK-OE-ARM-MULTILIB-LIB32: "-internal-isystem" "[[SYSROOT]]/usr/lib/arm-oemllib32-linux-gnueabi/9.5.0/../../../include/c++/9.5.0/backward"
+
+// Check header search on OpenEmbedded multilib libx32.
+// RUN: %clang -### %s -fsyntax-only 2>&1 \
+// RUN: --target=x86_64-oemllibx32-linux-gnux32 -stdlib=libstdc++ \
+// RUN: --sysroot=%S/Inputs/openembedded_x86_64_multilib_libx32_linux_tree \
+// RUN: | FileCheck --check-prefix=CHECK-OE-X86_64-MULTILIB-LIBX32 %s
+
+// CHECK-OE-X86_64-MULTILIB-LIBX32: "-cc1"
+// CHECK-OE-X86_64-MULTILIB-LIBX32: "-isysroot" "[[SYSROOT:[^"]+]]"
+// CHECK-OE-X86_64-MULTILIB-LIBX32: "-internal-isystem" "[[SYSROOT]]/usr/libx32/x86_64-oemllibx32-linux-gnux32/14.2.0/../../../include/c++/14.2.0"
+// CHECK-OE-X86_64-MULTILIB-LIBX32: "-internal-isystem" "[[SYSROOT]]/usr/libx32/x86_64-oemllibx32-linux-gnux32/14.2.0/../../../include/c++/14.2.0/backward"
+
// Check header search with Cray's gcc package.
// RUN: %clang -### %s -fsyntax-only 2>&1 \
// RUN: --target=x86_64-unknown-linux-gnu -stdlib=libstdc++ \
diff --git a/clang/test/Driver/linux-ld.c b/clang/test/Driver/linux-ld.c
index 4d641c8f1b46e9..bd033b26a77e75 100644
--- a/clang/test/Driver/linux-ld.c
+++ b/clang/test/Driver/linux-ld.c
@@ -1789,6 +1789,42 @@
// CHECK-OE-AARCH64: "[[SYSROOT]]/usr/lib64/aarch64-oe-linux/6.3.0{{/|\\\\}}crtend.o"
// CHECK-OE-AARCH64: "[[SYSROOT]]/usr/lib64/aarch64-oe-linux/6.3.0/../../../lib64{{/|\\\\}}crtn.o"
+// Check whether the OpenEmbedded ARM multilib lib32 libs are added correctly.
+// RUN: %clang -### %s -no-pie 2>&1 \
+// RUN: --target=arm-oemllib32-linux-gnueabi -rtlib=libgcc --unwindlib=platform \
+// RUN: --sysroot=%S/Inputs/openembedded_arm_multilib_lib32_linux_tree \
+// RUN: | FileCheck --check-prefix=CHECK-OE-ARM-MULTILIB-LIB32 %s
+
+// CHECK-OE-ARM-MULTILIB-LIB32: "-cc1" "-triple" "armv4t-oemllib32-linux-gnueabi"
+// CHECK-OE-ARM-MULTILIB-LIB32: ld{{.*}}" "--sysroot=[[SYSROOT:[^"]+]]"
+// CHECK-OE-ARM-MULTILIB-LIB32: "-m" "armelf_linux_eabi" "-dynamic-linker"
+// CHECK-OE-ARM-MULTILIB-LIB32: "[[SYSROOT]]/usr/lib/arm-oemllib32-linux-gnueabi/9.5.0/../../../lib{{/|\\\\}}crt1.o"
+// CHECK-OE-ARM-MULTILIB-LIB32: "[[SYSROOT]]/usr/lib/arm-oemllib32-linux-gnueabi/9.5.0/../../../lib{{/|\\\\}}crti.o"
+// CHECK-OE-ARM-MULTILIB-LIB32: "[[SYSROOT]]/usr/lib/arm-oemllib32-linux-gnueabi/9.5.0{{/|\\\\}}crtbegin.o"
+// CHECK-OE-ARM-MULTILIB-LIB32: "-L[[SYSROOT]]/usr/lib/arm-oemllib32-linux-gnueabi/9.5.0"
+// CHECK-OE-ARM-MULTILIB-LIB32: "-L[[SYSROOT]]/usr/lib"
+// CHECK-OE-ARM-MULTILIB-LIB32: "-lgcc" "--as-needed" "-lgcc_s" "--no-as-needed" "-lc" "-lgcc" "--as-needed" "-lgcc_s" "--no-as-needed"
+// CHECK-OE-ARM-MULTILIB-LIB32: "[[SYSROOT]]/usr/lib/arm-oemllib32-linux-gnueabi/9.5.0{{/|\\\\}}crtend.o"
+// CHECK-OE-ARM-MULTILIB-LIB32: "[[SYSROOT]]/usr/lib/arm-oemllib32-linux-gnueabi/9.5.0/../../../lib{{/|\\\\}}crtn.o"
+
+// Check whether the OpenEmbedded x86_64 multilib libx32 libs are added correctly.
+// RUN: %clang -### %s -no-pie 2>&1 \
+// RUN: --target=x86_64-oemllibx32-linux-gnux32 -rtlib=libgcc --unwindlib=platform \
+// RUN: --sysroot=%S/Inputs/openembedded_x86_64_multilib_libx32_linux_tree \
+// RUN: | FileCheck --check-prefix=CHECK-OE-X86_64-MULTILIB-LIBX32 %s
+
+// CHECK-OE-X86_64-MULTILIB-LIBX32: "-cc1" "-triple" "x86_64-oemllibx32-linux-gnux32"
+// CHECK-OE-X86_64-MULTILIB-LIBX32: ld{{.*}}" "--sysroot=[[SYSROOT:[^"]+]]"
+// CHECK-OE-X86_64-MULTILIB-LIBX32: "-m" "elf32_x86_64" "-dynamic-linker"
+// CHECK-OE-X86_64-MULTILIB-LIBX32: "[[SYSROOT]]/usr/libx32/x86_64-oemllibx32-linux-gnux32/14.2.0/../../../libx32{{/|\\\\}}crt1.o"
+// CHECK-OE-X86_64-MULTILIB-LIBX32: "[[SYSROOT]]/usr/libx32/x86_64-oemllibx32-linux-gnux32/14.2.0/../../../libx32{{/|\\\\}}crti.o"
+// CHECK-OE-X86_64-MULTILIB-LIBX32: "[[SYSROOT]]/usr/libx32/x86_64-oemllibx32-linux-gnux32/14.2.0{{/|\\\\}}crtbegin.o"
+// CHECK-OE-X86_64-MULTILIB-LIBX32: "-L[[SYSROOT]]/usr/libx32/x86_64-oemllibx32-linux-gnux32/14.2.0"
+// CHECK-OE-X86_64-MULTILIB-LIBX32: "-L[[SYSROOT]]/usr/libx32"
+// CHECK-OE-X86_64-MULTILIB-LIBX32: "-lgcc" "--as-needed" "-lgcc_s" "--no-as-needed" "-lc" "-lgcc" "--as-needed" "-lgcc_s" "--no-as-needed"
+// CHECK-OE-X86_64-MULTILIB-LIBX32: "[[SYSROOT]]/usr/libx32/x86_64-oemllibx32-linux-gnux32/14.2.0{{/|\\\\}}crtend.o"
+// CHECK-OE-X86_64-MULTILIB-LIBX32: "[[SYSROOT]]/usr/libx32/x86_64-oemllibx32-linux-gnux32/14.2.0/../../../libx32{{/|\\\\}}crtn.o"
+
/// -nopie is OpenBSD-specific.
// RUN: not %clang -### --target=x86_64-unknown-linux-gnu %s -nopie 2>&1 | FileCheck %s --check-prefix=CHECK-NOPIE
// CHECK-NOPIE: error: unsupported option '-nopie' for target 'x86_64-unknown-linux-gnu'
diff --git a/llvm/lib/TargetParser/Triple.cpp b/llvm/lib/TargetParser/Triple.cpp
index 7e040688dc1a7b..1e74b918b6ce80 100644
--- a/llvm/lib/TargetParser/Triple.cpp
+++ b/llvm/lib/TargetParser/Triple.cpp
@@ -643,6 +643,8 @@ static Triple::VendorType parseVendor(StringRef VendorName) {
.Case("mesa", Triple::Mesa)
.Case("suse", Triple::SUSE)
.Case("oe", Triple::OpenEmbedded)
+ .Case("oemllib32", Triple::OpenEmbedded)
+ .Case("oemllibx32", Triple::OpenEmbedded)
.Case("intel", Triple::Intel)
.Default(Triple::UnknownVendor);
}
diff --git a/llvm/unittests/TargetParser/TripleTest.cpp b/llvm/unittests/TargetParser/TripleTest.cpp
index 7fb7625f8c2d10..d4ee9b0f2bbd32 100644
--- a/llvm/unittests/TargetParser/TripleTest.cpp
+++ b/llvm/unittests/TargetParser/TripleTest.cpp
@@ -1075,6 +1075,18 @@ TEST(TripleTest, ParsedIDs) {
EXPECT_EQ(Triple::Linux, T.getOS());
EXPECT_EQ(Triple::GNUEABI, T.getEnvironment());
+ T = Triple("arm-oemllib32-linux-gnueabi");
+ EXPECT_EQ(Triple::arm, T.getArch());
+ EXPECT_EQ(Triple::OpenEmbedded, T.getVendor());
+ EXPECT_EQ(Triple::Linux, T.getOS());
+ EXPECT_EQ(Triple::GNUEABI, T.getEnvironment());
+
+ T = Triple("x86_64-oemllibx32-linux-gnux32");
+ EXPECT_EQ(Triple::x86_64, T.getArch());
+ EXPECT_EQ(Triple::OpenEmbedded, T.getVendor());
+ EXPECT_EQ(Triple::Linux, T.getOS());
+ EXPECT_EQ(Triple::GNUX32, T.getEnvironment());
+
T = Triple("aarch64-oe-linux");
EXPECT_EQ(Triple::aarch64, T.getArch());
EXPECT_EQ(Triple::OpenEmbedded, T.getVendor());
``````````
</details>
https://github.com/llvm/llvm-project/pull/121302
More information about the llvm-commits
mailing list