summaryrefslogtreecommitdiffstats
path: root/recipes-devtools/clang/clang/0022-clang-Fix-resource-dir-location-for-cross-toolchains.patch
blob: 85f1d8cd25ea7dfbfa698c782c12a25b442c3ea8 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
From 5fb5780cdf9fe0f26ac1a076d0eaa82de61b5f8b Mon Sep 17 00:00:00 2001
From: Jim Broadus <jbroadus@xevo.com>
Date: Thu, 26 Mar 2020 16:05:53 -0700
Subject: [PATCH 22/24] clang: Fix resource dir location for cross toolchains

When clang looks for the resources directory, it does so based on the binary
location and assumes that the containing directory is a sibling to lib. The
Yocto cross.bbclass defines the default bindir as
${exec_prefix}/bin/${CROSS_TARGET_SYS_DIR}. ex: /usr/bin/aarch64-poky-linux/.
This causes clang to form a path that looks like /usr/bin/lib/clang/...

As a fix for this, check the parent directory name. If that is "bin", then
use that directory's parent.

Signed-off-by: Jim Broadus <jbroadus@xevo.com>
Signed-off-by: Khem Raj <raj.khem@gmail.com>
---
 clang/lib/Driver/Driver.cpp | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)

--- a/clang/lib/Driver/Driver.cpp
+++ b/clang/lib/Driver/Driver.cpp
@@ -112,7 +112,13 @@ std::string Driver::GetResourcesPath(Str
     // With a static-library build of libclang, LibClangPath will contain the
     // path of the embedding binary, which for LLVM binaries will be in bin/.
     // ../lib gets us to lib/ in both cases.
-    P = llvm::sys::path::parent_path(Dir);
+    Dir = std::string(llvm::sys::path::parent_path(Dir));
+
+    // OE cross toolchains are installed, by default, in a subdir of bin.
+    if (llvm::sys::path::filename(Dir) == "bin") {
+      Dir = std::string(llvm::sys::path::parent_path(Dir));
+    }
+    P = Dir;
     llvm::sys::path::append(P, Twine("lib") + CLANG_LIBDIR_SUFFIX, "clang",
                             CLANG_VERSION_STRING);
   }