[PATCH] D48862: Fix lib paths for OpenEmbedded targets
Mandeep Singh Grang via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Mon Jul 2 18:35:59 PDT 2018
mgrang created this revision.
mgrang added reviewers: dlj, rengolin, fedor.sergeev.
Herald added a reviewer: javed.absar.
Herald added a subscriber: kristof.beyls.
The lib paths are not correctly picked up for OpenEmbedded sysroots (like arm-oe-linux-gnueabi) for 2 reasons:
1. OpenEmbedded sysroots are of the form <sysroot>/usr/lib/<triple>/x.y.z. This form is handled in clang but only for Freescale vendor.
2. 64-bit OpenEmbedded sysroots may not have a /usr/lib dir. So they cannot find /usr/lib64 as it is referenced as /usr/lib/../lib64 in clang.
This is a follow-up to the llvm patch: https://reviews.llvm.org/D48861
Repository:
rC Clang
https://reviews.llvm.org/D48862
Files:
lib/Driver/ToolChains/Gnu.cpp
lib/Driver/ToolChains/Linux.cpp
test/Driver/Inputs/openembedded_aarch64_linux_tree/aarch64_oe_linux_tree/usr/lib64/aarch64-oe-linux/6.3.0/crtbegin.o
test/Driver/Inputs/openembedded_aarch64_linux_tree/aarch64_oe_linux_tree/usr/lib64/aarch64-oe-linux/6.3.0/crtend.o
test/Driver/Inputs/openembedded_aarch64_linux_tree/aarch64_oe_linux_tree/usr/lib64/crt1.o
test/Driver/Inputs/openembedded_aarch64_linux_tree/aarch64_oe_linux_tree/usr/lib64/crti.o
test/Driver/Inputs/openembedded_aarch64_linux_tree/aarch64_oe_linux_tree/usr/lib64/crtn.o
test/Driver/Inputs/openembedded_aarch64_linux_tree/usr/lib64/aarch64-oe-linux/6.3.0/crtbegin.o
test/Driver/Inputs/openembedded_aarch64_linux_tree/usr/lib64/aarch64-oe-linux/6.3.0/crtend.o
test/Driver/Inputs/openembedded_aarch64_linux_tree/usr/lib64/crt1.o
test/Driver/Inputs/openembedded_aarch64_linux_tree/usr/lib64/crti.o
test/Driver/Inputs/openembedded_aarch64_linux_tree/usr/lib64/crtn.o
test/Driver/Inputs/openembedded_arm_linux_tree/usr/lib/arm-oe-linux-gnueabi/6.3.0/crtbegin.o
test/Driver/Inputs/openembedded_arm_linux_tree/usr/lib/arm-oe-linux-gnueabi/6.3.0/crtend.o
test/Driver/Inputs/openembedded_arm_linux_tree/usr/lib/crt1.o
test/Driver/Inputs/openembedded_arm_linux_tree/usr/lib/crti.o
test/Driver/Inputs/openembedded_arm_linux_tree/usr/lib/crtn.o
test/Driver/linux-ld.c
Index: test/Driver/linux-ld.c
===================================================================
--- test/Driver/linux-ld.c
+++ test/Driver/linux-ld.c
@@ -1792,3 +1792,38 @@
// CHECK-LD-RHLE7-DTS: Selected GCC installation: [[GCC_INSTALL:[[SYSROOT]]/lib/gcc/x86_64-redhat-linux/7]]
// CHECK-LD-RHEL7-DTS-NOT: /usr/bin/ld
// CHECK-LD-RHLE7-DTS: [[GCC_INSTALL]/../../../bin/ld
+
+// RUN: %clang -no-canonical-prefixes %s -### -o %t.o 2>&1 \
+// RUN: --target=arm-oe-linux-gnueabi \
+// RUN: --sysroot=%S/Inputs/openembedded_arm_linux_tree \
+// RUN: | FileCheck --check-prefix=CHECK-OE-ARM %s
+
+// CHECK-OE-ARM: "-cc1" "-triple" "armv4t-oe-linux-gnueabi"
+// CHECK-OE-ARM: ld{{.*}}" "--sysroot=[[SYSROOT:[^"]+]]"
+// CHECK-OE-ARM: "-m" "armelf_linux_eabi" "-dynamic-linker"
+// CHECK-OE-ARM: "[[SYSROOT]]/usr/lib/../lib/crt1.o"
+// CHECK-OE-ARM: "[[SYSROOT]]/usr/lib/../lib/crti.o"
+// CHECK-OE-ARM: "[[SYSROOT]]/usr/lib/arm-oe-linux-gnueabi/6.3.0/crtbegin.o"
+// CHECK-OE-ARM: "-L[[SYSROOT]]/usr/lib/arm-oe-linux-gnueabi/6.3.0"
+// CHECK-OE-ARM: "-L[[SYSROOT]]/usr/lib/arm-oe-linux-gnueabi"
+// CHECK-OE-ARM: "-L[[SYSROOT]]/usr/lib"
+// CHECK-OE-ARM: "-lgcc" "--as-needed" "-lgcc_s" "--no-as-needed" "-lc" "-lgcc" "--as-needed" "-lgcc_s" "--no-as-needed"
+// CHECK-OE-ARM: "[[SYSROOT]]/usr/lib/arm-oe-linux-gnueabi/6.3.0/crtend.o"
+// CHECK-OE-ARM: "[[SYSROOT]]/usr/lib/../lib/crtn.o"
+
+// RUN: %clang -no-canonical-prefixes %s -### -o %t.o 2>&1 \
+// RUN: --target=aarch64-oe-linux \
+// RUN: --sysroot=%S/Inputs/openembedded_aarch64_linux_tree \
+// RUN: | FileCheck --check-prefix=CHECK-OE-AARCH64 %s
+
+// CHECK-OE-AARCH64: "-cc1" "-triple" "aarch64-oe-linux"
+// CHECK-OE-AARCH64: ld{{.*}}" "--sysroot=[[SYSROOT:[^"]+]]"
+// CHECK-OE-AARCH64: "-m" "aarch64linux" "-dynamic-linker"
+// CHECK-OE-AARCH64: "[[SYSROOT]]/usr/lib64/crt1.o"
+// CHECK-OE-AARCH64: "[[SYSROOT]]/usr/lib64/crti.o"
+// CHECK-OE-AARCH64: "[[SYSROOT]]/usr/lib64/aarch64-oe-linux/6.3.0/crtbegin.o"
+// CHECK-OE-AARCH64: "-L[[SYSROOT]]/usr/lib64/aarch64-oe-linux/6.3.0"
+// CHECK-OE-AARCH64: "-L[[SYSROOT]]/usr/lib64"
+// CHECK-OE-AARCH64: "-lgcc" "--as-needed" "-lgcc_s" "--no-as-needed" "-lc" "-lgcc" "--as-needed" "-lgcc_s" "--no-as-needed"
+// CHECK-OE-AARCH64: "[[SYSROOT]]/usr/lib64/aarch64-oe-linux/6.3.0/crtend.o"
+// CHECK-OE-AARCH64: "[[SYSROOT]]/usr/lib64/crtn.o"
Index: lib/Driver/ToolChains/Linux.cpp
===================================================================
--- lib/Driver/ToolChains/Linux.cpp
+++ lib/Driver/ToolChains/Linux.cpp
@@ -383,6 +383,12 @@
addPathIfExists(D, SysRoot + "/usr/" + OSLibDir + "/" + ABIName, Paths);
}
+ // 64-bit OpenEmbedded sysroots may not have a /usr/lib dir. So they cannot
+ // find /usr/lib64 as it is referenced as /usr/lib/../lib64. So we handle
+ // this here.
+ if (Triple.getVendor() == llvm::Triple::OpenEmbedded)
+ addPathIfExists(D, SysRoot + "/usr/" + OSLibDir, Paths);
+
// Try walking via the GCC triple path in case of biarch or multiarch GCC
// installations with strange symlinks.
if (GCCInstallation.isValid()) {
Index: lib/Driver/ToolChains/Gnu.cpp
===================================================================
--- lib/Driver/ToolChains/Gnu.cpp
+++ lib/Driver/ToolChains/Gnu.cpp
@@ -2201,7 +2201,12 @@
// triple.
{"i386-linux-gnu/gcc/" + CandidateTriple.str(), "../../..",
(TargetArch == llvm::Triple::x86 &&
- TargetTriple.getOS() != llvm::Triple::Solaris)}};
+ TargetTriple.getOS() != llvm::Triple::Solaris)},
+
+ // Deal with OpenEmbedded linux sysroots (like for arm-oe-linux-gnueabi)
+ // which are of the form <sysroot>/usr/lib/<triple>/x.y.z.
+ {CandidateTriple.str(), "../..",
+ TargetTriple.getVendor() == llvm::Triple::OpenEmbedded}};
for (auto &Suffix : Suffixes) {
if (!Suffix.Active)
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D48862.153844.patch
Type: text/x-patch
Size: 3866 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20180703/fd3a19f6/attachment.bin>
More information about the cfe-commits
mailing list