1 |
Fix the LLVM tool path in variables such as AR, LD, etc. to their |
2 |
current locations prior to manipulating PATH, in order to prevent |
3 |
llvm.eclass from overriding them. Otherwise, a package requiring older |
4 |
LLVM libraries could force older tool versions, possibly incompatible |
5 |
with the object files produced by a newer clang version. |
6 |
|
7 |
Signed-off-by: Michał Górny <mgorny@g.o> |
8 |
--- |
9 |
eclass/llvm.eclass | 27 +++++++++++++++++++++++++++ |
10 |
1 file changed, 27 insertions(+) |
11 |
|
12 |
diff --git a/eclass/llvm.eclass b/eclass/llvm.eclass |
13 |
index 39299d06dbe9..16596ec2ea66 100644 |
14 |
--- a/eclass/llvm.eclass |
15 |
+++ b/eclass/llvm.eclass |
16 |
@@ -214,6 +214,30 @@ llvm_fix_clang_version() { |
17 |
${shopt_save} |
18 |
} |
19 |
|
20 |
+# @FUNCTION: llvm_fix_tool_path |
21 |
+# @USAGE: <variable-name>... |
22 |
+# @DESCRIPTION: |
23 |
+# Fix the LLVM tools referenced in the specified variables to their |
24 |
+# current location, to prevent PATH alterations from forcing older |
25 |
+# versions being used. |
26 |
+llvm_fix_tool_path() { |
27 |
+ debug-print-function ${FUNCNAME} "${@}" |
28 |
+ |
29 |
+ local shopt_save=$(shopt -p -o noglob) |
30 |
+ set -f |
31 |
+ local var |
32 |
+ for var; do |
33 |
+ local split=( ${!var} ) |
34 |
+ local path=$(type -P ${split[0]} 2>/dev/null) |
35 |
+ # if it resides in one of the LLVM prefixes, it's an LLVM tool! |
36 |
+ if [[ ${path} == "${BROOT}/usr/lib/llvm"* ]]; then |
37 |
+ split[0]=${path} |
38 |
+ declare -g "${var}=${split[*]}" |
39 |
+ fi |
40 |
+ done |
41 |
+ ${shopt_save} |
42 |
+} |
43 |
+ |
44 |
# @FUNCTION: llvm_pkg_setup |
45 |
# @DESCRIPTION: |
46 |
# Prepend the appropriate executable directory for the newest |
47 |
@@ -233,6 +257,9 @@ llvm_pkg_setup() { |
48 |
|
49 |
if [[ ${MERGE_TYPE} != binary ]]; then |
50 |
llvm_fix_clang_version CC CPP CXX |
51 |
+ # keep in sync with profiles/features/llvm/make.defaults! |
52 |
+ llvm_fix_tool_path ADDR2LINE AR AS LD NM OBJCOPY OBJDUMP RANLIB |
53 |
+ llvm_fix_tool_path READELF STRINGS STRIP |
54 |
|
55 |
local llvm_path=$(get_llvm_prefix "${LLVM_MAX_SLOT}")/bin |
56 |
local IFS=: |
57 |
-- |
58 |
2.38.0 |