From: Mandeep Singh Grang Date: Mon, 30 Jul 2018 19:44:13 +0000 (+0000) Subject: [OpenEmbedded] Fix lib paths for OpenEmbedded targets X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=75f2c9d022595bcd81c2362397f5badf1839cbcf;p=clang [OpenEmbedded] Fix lib paths for OpenEmbedded targets Summary: 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 /usr/lib//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: D48861 Reviewers: dlj, rengolin, fedor.sergeev, javed.absar, hfinkel, rsmith Reviewed By: rsmith Subscribers: rsmith, kristof.beyls, cfe-commits Differential Revision: https://reviews.llvm.org/D48862 git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@338294 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/lib/Driver/ToolChains/Gnu.cpp b/lib/Driver/ToolChains/Gnu.cpp index 2c83598f3d..ad702b6d06 100644 --- a/lib/Driver/ToolChains/Gnu.cpp +++ b/lib/Driver/ToolChains/Gnu.cpp @@ -2188,7 +2188,8 @@ void Generic_GCC::GCCInstallationDetector::ScanLibDirForGCCTriple( // this on Freescale triples, though, since some systems put a *lot* of // files in that location, not just GCC installation data. {CandidateTriple.str(), "..", - TargetTriple.getVendor() == llvm::Triple::Freescale}, + TargetTriple.getVendor() == llvm::Triple::Freescale || + TargetTriple.getVendor() == llvm::Triple::OpenEmbedded}, // Natively multiarch systems sometimes put the GCC triple-specific // directory within their multiarch lib directory, resulting in the diff --git a/lib/Driver/ToolChains/Linux.cpp b/lib/Driver/ToolChains/Linux.cpp index d27f994d32..f8f3623918 100644 --- a/lib/Driver/ToolChains/Linux.cpp +++ b/lib/Driver/ToolChains/Linux.cpp @@ -376,7 +376,14 @@ Linux::Linux(const Driver &D, const llvm::Triple &Triple, const ArgList &Args) } addPathIfExists(D, SysRoot + "/usr/lib/" + MultiarchTriple, Paths); - addPathIfExists(D, SysRoot + "/usr/lib/../" + OSLibDir, 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 && + Triple.isArch64Bit()) + addPathIfExists(D, SysRoot + "/usr/" + OSLibDir, Paths); + else + addPathIfExists(D, SysRoot + "/usr/lib/../" + OSLibDir, Paths); if (IsRISCV) { StringRef ABIName = tools::riscv::getRISCVABI(Args, Triple); addPathIfExists(D, SysRoot + "/" + OSLibDir + "/" + ABIName, Paths); diff --git a/test/Driver/Inputs/openembedded_aarch64_linux_tree/usr/include/c++/6.3.0/backward/.keep b/test/Driver/Inputs/openembedded_aarch64_linux_tree/usr/include/c++/6.3.0/backward/.keep new file mode 100644 index 0000000000..e69de29bb2 diff --git a/test/Driver/Inputs/openembedded_aarch64_linux_tree/usr/lib64/aarch64-oe-linux/6.3.0/crtbegin.o b/test/Driver/Inputs/openembedded_aarch64_linux_tree/usr/lib64/aarch64-oe-linux/6.3.0/crtbegin.o new file mode 100644 index 0000000000..e69de29bb2 diff --git a/test/Driver/Inputs/openembedded_aarch64_linux_tree/usr/lib64/aarch64-oe-linux/6.3.0/crtend.o b/test/Driver/Inputs/openembedded_aarch64_linux_tree/usr/lib64/aarch64-oe-linux/6.3.0/crtend.o new file mode 100644 index 0000000000..e69de29bb2 diff --git a/test/Driver/Inputs/openembedded_aarch64_linux_tree/usr/lib64/crt1.o b/test/Driver/Inputs/openembedded_aarch64_linux_tree/usr/lib64/crt1.o new file mode 100644 index 0000000000..e69de29bb2 diff --git a/test/Driver/Inputs/openembedded_aarch64_linux_tree/usr/lib64/crti.o b/test/Driver/Inputs/openembedded_aarch64_linux_tree/usr/lib64/crti.o new file mode 100644 index 0000000000..e69de29bb2 diff --git a/test/Driver/Inputs/openembedded_aarch64_linux_tree/usr/lib64/crtn.o b/test/Driver/Inputs/openembedded_aarch64_linux_tree/usr/lib64/crtn.o new file mode 100644 index 0000000000..e69de29bb2 diff --git a/test/Driver/Inputs/openembedded_arm_linux_tree/usr/include/c++/6.3.0/backward/.keep b/test/Driver/Inputs/openembedded_arm_linux_tree/usr/include/c++/6.3.0/backward/.keep new file mode 100644 index 0000000000..e69de29bb2 diff --git a/test/Driver/Inputs/openembedded_arm_linux_tree/usr/lib/arm-oe-linux-gnueabi/6.3.0/crtbegin.o b/test/Driver/Inputs/openembedded_arm_linux_tree/usr/lib/arm-oe-linux-gnueabi/6.3.0/crtbegin.o new file mode 100644 index 0000000000..e69de29bb2 diff --git a/test/Driver/Inputs/openembedded_arm_linux_tree/usr/lib/arm-oe-linux-gnueabi/6.3.0/crtend.o b/test/Driver/Inputs/openembedded_arm_linux_tree/usr/lib/arm-oe-linux-gnueabi/6.3.0/crtend.o new file mode 100644 index 0000000000..e69de29bb2 diff --git a/test/Driver/Inputs/openembedded_arm_linux_tree/usr/lib/crt1.o b/test/Driver/Inputs/openembedded_arm_linux_tree/usr/lib/crt1.o new file mode 100644 index 0000000000..e69de29bb2 diff --git a/test/Driver/Inputs/openembedded_arm_linux_tree/usr/lib/crti.o b/test/Driver/Inputs/openembedded_arm_linux_tree/usr/lib/crti.o new file mode 100644 index 0000000000..e69de29bb2 diff --git a/test/Driver/Inputs/openembedded_arm_linux_tree/usr/lib/crtn.o b/test/Driver/Inputs/openembedded_arm_linux_tree/usr/lib/crtn.o new file mode 100644 index 0000000000..e69de29bb2 diff --git a/test/Driver/linux-header-search.cpp b/test/Driver/linux-header-search.cpp index 3f024aa495..6d1c22067a 100644 --- a/test/Driver/linux-header-search.cpp +++ b/test/Driver/linux-header-search.cpp @@ -493,3 +493,25 @@ // CHECK-DEBIAN-SPARC64: "-internal-externc-isystem" "[[SYSROOT]]/usr/include/sparc64-linux-gnu" // CHECK-DEBIAN-SPARC64: "-internal-externc-isystem" "[[SYSROOT]]/include" // CHECK-DEBIAN-SPARC64: "-internal-externc-isystem" "[[SYSROOT]]/usr/include" + +// Check header search on OpenEmbedded ARM. +// RUN: %clang -no-canonical-prefixes %s -### -fsyntax-only 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: "{{[^"]*}}clang{{[^"]*}}" "-cc1" +// CHECK-OE-ARM: "-isysroot" "[[SYSROOT:[^"]+]]" +// CHECK-OE-ARM: "-internal-isystem" "[[SYSROOT]]/usr/lib/arm-oe-linux-gnueabi/6.3.0/../../../include/c++/6.3.0" +// CHECK-OE-ARM: "-internal-isystem" "[[SYSROOT]]/usr/lib/arm-oe-linux-gnueabi/6.3.0/../../../include/c++/6.3.0/backward" + +// Check header search on OpenEmbedded AArch64. +// RUN: %clang -no-canonical-prefixes %s -### -fsyntax-only 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: "{{[^"]*}}clang{{[^"]*}}" "-cc1" +// CHECK-OE-AARCH64: "-isysroot" "[[SYSROOT:[^"]+]]" +// 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" diff --git a/test/Driver/linux-ld.c b/test/Driver/linux-ld.c index 02e6618a04..81cb7f8e73 100644 --- a/test/Driver/linux-ld.c +++ b/test/Driver/linux-ld.c @@ -1813,4 +1813,40 @@ // CHECK-LD-AMI: "-lgcc" "--as-needed" "-lgcc_s" "--no-as-needed" // CHECK-LD-AMI: "-lc" // CHECK-LD-AMI: "-lgcc" "--as-needed" "-lgcc_s" "--no-as-needed" -// + +// Check whether the OpenEmbedded ARM libs are added correctly. +// 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/arm-oe-linux-gnueabi/6.3.0/../../../lib{{/|\\\\}}crt1.o" +// CHECK-OE-ARM: "[[SYSROOT]]/usr/lib/arm-oe-linux-gnueabi/6.3.0/../../../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/arm-oe-linux-gnueabi/6.3.0/../../../lib{{/|\\\\}}crtn.o" + +// Check whether the OpenEmbedded AArch64 libs are added correctly. +// 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/aarch64-oe-linux/6.3.0/../../../lib64{{/|\\\\}}crt1.o" +// CHECK-OE-AARCH64: "[[SYSROOT]]/usr/lib64/aarch64-oe-linux/6.3.0/../../../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/aarch64-oe-linux/6.3.0/../../../lib64{{/|\\\\}}crtn.o"