-
Notifications
You must be signed in to change notification settings - Fork 15.4k
[OpenEmbedded] Fix include and lib paths for multilib targets #121302
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
|
@llvm/pr-subscribers-clang-driver @llvm/pr-subscribers-clang Author: Mike Crowe (mikecrowe) ChangesThe fix in e9ddc44 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:
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());
|
|
This works, but I'm not sure that it's the best solution. I could teach |
The fix in e9ddc44 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.
8e11693 to
e376b82
Compare
|
The include and library path code in the driver needs more love. I have cleaned up some a few years ago but there is still quite a bit tech debt. In particular, the 2018 commit you mentioned (https://reviews.llvm.org/D48862) introduced which could be simplified to A lot of ELF-specific Triple::VendorType should not have been added in the first place. Can you confirm whether you added new OpenEmbedded VendorType due to the following customization? |
|
Thank you for investigating this. Your change in #128428 certainly makes things look a lot neater to me. I believe that OpenEmbedded multilib is relying on the same I rebased this change on top of current main and the tests I added still need the new cases I added to I can certainly try asking on the OpenEmbedded lists whether they'd be willing to try to use the more-standard locations. I suspect that they made their decision a very long time ago when the conventions hadn't been settled. The way embedded development is, even if they do agree to change it there will be many users still using older versions of OpenEmbedded without the change for many years to come. Even with this change things aren't perfect since clangd appears to still be reporting paths in |
|
I tried asking about this on the OpenEmbedded mailing list. The response was that it has been this way for so long that it's going to be a major undertaking to change it even though they would quite like to do so. I had a go at using symlinks to work around the problem. Unfortunately because mkdir -p $sysroot/usr/lib/gcc/arm-oemllib32-linux-gnueabi/9.5.0
cd $sysroot/usr/lib/gcc/arm-oemllib32-linux-gnueabi/9.5.0
ln -s ln -s ../../../arm-oemllib32-linux-gnueabi/9.5.0/* .Presumably there's a reason that |
Thank you for asking OpenEmbedded. |
The fix in e9ddc44 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.