summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJim Broadus <jbroadus@xevo.com>2020-03-27 13:06:08 -0700
committerKhem Raj <raj.khem@gmail.com>2020-03-28 08:07:47 -0700
commit7cdc7ff4cdfbd75083ec37ed2e8a380f48fb692c (patch)
tree8bca1bcb39c01e381c67607858d916de71ffaade
parent31732172809bc163eba728857693d933ad193bf5 (diff)
downloadmeta-clang-7cdc7ff4cdfbd75083ec37ed2e8a380f48fb692c.tar.gz
clang: Fix default resources directory when cross compiling
By default, clang looks for resourses relative to the binary location: ${location}/../lib/clang/${version}/ However, the default bindir defined in cross.bbclass is a subdirectory of bin, so clang forms a directory that looks like /usr/bin/lib/clang/10.0.0/ Apply a patch to use ${location}/../../lib/clang/${version} if the directory name of ${location}/.. is "bin". Signed-off-by: Jim Broadus <jbroadus@xevo.com>
-rw-r--r--recipes-devtools/clang/clang/0023-clang-Fix-resource-dir-location-for-cross-toolchains.patch41
-rw-r--r--recipes-devtools/clang/common.inc1
2 files changed, 42 insertions, 0 deletions
diff --git a/recipes-devtools/clang/clang/0023-clang-Fix-resource-dir-location-for-cross-toolchains.patch b/recipes-devtools/clang/clang/0023-clang-Fix-resource-dir-location-for-cross-toolchains.patch
new file mode 100644
index 0000000..decab68
--- /dev/null
+++ b/recipes-devtools/clang/clang/0023-clang-Fix-resource-dir-location-for-cross-toolchains.patch
@@ -0,0 +1,41 @@
1From ed3b5d8bb197f01556b42dfc2281693475fd830e Mon Sep 17 00:00:00 2001
2From: Jim Broadus <jbroadus@xevo.com>
3Date: Thu, 26 Mar 2020 16:05:53 -0700
4Subject: [PATCH] clang: Fix resource dir location for cross toolchains
5
6When clang looks for the resources directory, it does so based on the binary
7location and assumes that the containing directory is a sibling to lib. The
8Yocto cross.bbclass defines the default bindir as
9${exec_prefix}/bin/${CROSS_TARGET_SYS_DIR}. ex: /usr/bin/aarch64-poky-linux/.
10This causes clang to form a path that looks like /usr/bin/lib/clang/...
11
12As a fix for this, check the parent directory name. If that is "bin", then
13use that directory's parent.
14
15Signed-off-by: Jim Broadus <jbroadus@xevo.com>
16---
17 clang/lib/Driver/Driver.cpp | 8 +++++++-
18 1 file changed, 7 insertions(+), 1 deletion(-)
19
20diff --git a/clang/lib/Driver/Driver.cpp b/clang/lib/Driver/Driver.cpp
21index fb8335a3695..819887944b5 100644
22--- a/clang/lib/Driver/Driver.cpp
23+++ b/clang/lib/Driver/Driver.cpp
24@@ -110,7 +110,13 @@ std::string Driver::GetResourcesPath(StringRef BinaryPath,
25 // With a static-library build of libclang, LibClangPath will contain the
26 // path of the embedding binary, which for LLVM binaries will be in bin/.
27 // ../lib gets us to lib/ in both cases.
28- P = llvm::sys::path::parent_path(Dir);
29+ Dir = llvm::sys::path::parent_path(Dir);
30+
31+ // OE cross toolchains are installed, by default, in a subdir of bin.
32+ if (llvm::sys::path::filename(Dir) == "bin") {
33+ Dir = llvm::sys::path::parent_path(Dir);
34+ }
35+ P = Dir;
36 llvm::sys::path::append(P, Twine("lib") + CLANG_LIBDIR_SUFFIX, "clang",
37 CLANG_VERSION_STRING);
38 }
39--
402.24.1
41
diff --git a/recipes-devtools/clang/common.inc b/recipes-devtools/clang/common.inc
index 89696c2..c45e24c 100644
--- a/recipes-devtools/clang/common.inc
+++ b/recipes-devtools/clang/common.inc
@@ -30,6 +30,7 @@ SRC_URI = "\
30 file://0020-clang-Enable-SSP-and-PIE-by-default.patch \ 30 file://0020-clang-Enable-SSP-and-PIE-by-default.patch \
31 file://0021-libcxx-Add-compiler-runtime-library-to-link-step-for.patch \ 31 file://0021-libcxx-Add-compiler-runtime-library-to-link-step-for.patch \
32 file://0022-clang-llvm-cmake-Fix-configure-for-packages-using-fi.patch \ 32 file://0022-clang-llvm-cmake-Fix-configure-for-packages-using-fi.patch \
33 file://0023-clang-Fix-resource-dir-location-for-cross-toolchains.patch \
33" 34"
34 35
35# Fallback to no-PIE if not set 36# Fallback to no-PIE if not set