summaryrefslogtreecommitdiffstats
path: root/meta/classes
diff options
context:
space:
mode:
authorRichard Purdie <richard.purdie@linuxfoundation.org>2022-08-05 13:34:42 +0100
committerRichard Purdie <richard.purdie@linuxfoundation.org>2022-08-08 15:44:20 +0100
commitcdd65a42a8b7c23d3640d341c84e747dfb96d269 (patch)
tree18927a113237ccabf5bc7b4b86c72287a2c18a5b /meta/classes
parent0b374dc724cae3c1979d5191a477cab5eb333ab1 (diff)
downloadpoky-cdd65a42a8b7c23d3640d341c84e747dfb96d269.tar.gz
rust-common: Simplify libc handling
The current libc handling code is simply wrong in many cases. Simplify it to a check of the triplet for musl handling which is much simpler and less error prone when handling things like nativesdk targets. (From OE-Core rev: f35d5af06db10fa20e55f4c738e665b35f5c394b) Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'meta/classes')
-rw-r--r--meta/classes/rust-common.bbclass45
1 files changed, 8 insertions, 37 deletions
diff --git a/meta/classes/rust-common.bbclass b/meta/classes/rust-common.bbclass
index 7c432ed131..516b258c15 100644
--- a/meta/classes/rust-common.bbclass
+++ b/meta/classes/rust-common.bbclass
@@ -13,27 +13,6 @@ RUSTFLAGS += "${RUSTLIB} ${RUST_DEBUG_REMAP}"
13RUSTLIB_DEP ?= "libstd-rs" 13RUSTLIB_DEP ?= "libstd-rs"
14RUST_PANIC_STRATEGY ?= "unwind" 14RUST_PANIC_STRATEGY ?= "unwind"
15 15
16# Native builds are not effected by TCLIBC. Without this, rust-native
17# thinks it's "target" (i.e. x86_64-linux) is a musl target.
18RUST_LIBC = "${TCLIBC}"
19RUST_LIBC:class-crosssdk = "glibc"
20RUST_LIBC:class-native = "glibc"
21
22def determine_libc(d, thing):
23 '''Determine which libc something should target'''
24
25 # BUILD is never musl, TARGET may be musl or glibc,
26 # HOST could be musl, but only if a compiler is built to be run on
27 # target in which case HOST_SYS != BUILD_SYS.
28 if thing == 'TARGET':
29 libc = d.getVar('RUST_LIBC')
30 elif thing == 'BUILD' and (d.getVar('HOST_SYS') != d.getVar('BUILD_SYS')):
31 libc = d.getVar('RUST_LIBC')
32 else:
33 libc = d.getVar('RUST_LIBC:class-native')
34
35 return libc
36
37def target_is_armv7(d): 16def target_is_armv7(d):
38 '''Determine if target is armv7''' 17 '''Determine if target is armv7'''
39 # TUNE_FEATURES may include arm* even if the target is not arm 18 # TUNE_FEATURES may include arm* even if the target is not arm
@@ -73,26 +52,18 @@ def rust_base_triple(d, thing):
73 if thing == "BUILD" and bpn in ["rust"]: 52 if thing == "BUILD" and bpn in ["rust"]:
74 return arch + "-unknown-linux-gnu" 53 return arch + "-unknown-linux-gnu"
75 54
76 # All the Yocto targets are Linux and are 'unknown' 55 vendor = d.getVar('{}_VENDOR'.format(thing))
77 vendor = "-unknown"
78 os = d.getVar('{}_OS'.format(thing))
79 libc = determine_libc(d, thing)
80
81 # Prefix with a dash and convert glibc -> gnu
82 if libc == "glibc":
83 libc = "-gnu"
84 elif libc == "musl":
85 libc = "-musl"
86
87 # Don't double up musl (only appears to be the case on aarch64)
88 if os == "linux-musl":
89 if libc != "-musl":
90 bb.fatal("{}_OS was '{}' but TCLIBC was not 'musl'".format(thing, os))
91 os = "linux"
92 56
57 # Default to glibc
58 libc = "-gnu"
59 os = d.getVar('{}_OS'.format(thing))
93 # This catches ARM targets and appends the necessary hard float bits 60 # This catches ARM targets and appends the necessary hard float bits
94 if os == "linux-gnueabi" or os == "linux-musleabi": 61 if os == "linux-gnueabi" or os == "linux-musleabi":
95 libc = bb.utils.contains('TUNE_FEATURES', 'callconvention-hard', 'hf', '', d) 62 libc = bb.utils.contains('TUNE_FEATURES', 'callconvention-hard', 'hf', '', d)
63 elif "musl" in os:
64 libc = "-musl"
65 os = "linux"
66
96 return arch + vendor + '-' + os + libc 67 return arch + vendor + '-' + os + libc
97 68
98 69