summaryrefslogtreecommitdiffstats
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:41:36 +0100
commitf35d5af06db10fa20e55f4c738e665b35f5c394b (patch)
tree40f6372ad940b1157931d5d99a196568b2433a4e
parentec15882fbf396de8d3a5921a3028850ba3fccc48 (diff)
downloadopenembedded-core-contrib-f35d5af06db10fa20e55f4c738e665b35f5c394b.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. Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
-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}"
RUSTLIB_DEP ?= "libstd-rs"
RUST_PANIC_STRATEGY ?= "unwind"
-# Native builds are not effected by TCLIBC. Without this, rust-native
-# thinks it's "target" (i.e. x86_64-linux) is a musl target.
-RUST_LIBC = "${TCLIBC}"
-RUST_LIBC:class-crosssdk = "glibc"
-RUST_LIBC:class-native = "glibc"
-
-def determine_libc(d, thing):
- '''Determine which libc something should target'''
-
- # BUILD is never musl, TARGET may be musl or glibc,
- # HOST could be musl, but only if a compiler is built to be run on
- # target in which case HOST_SYS != BUILD_SYS.
- if thing == 'TARGET':
- libc = d.getVar('RUST_LIBC')
- elif thing == 'BUILD' and (d.getVar('HOST_SYS') != d.getVar('BUILD_SYS')):
- libc = d.getVar('RUST_LIBC')
- else:
- libc = d.getVar('RUST_LIBC:class-native')
-
- return libc
-
def target_is_armv7(d):
'''Determine if target is armv7'''
# TUNE_FEATURES may include arm* even if the target is not arm
@@ -73,26 +52,18 @@ def rust_base_triple(d, thing):
if thing == "BUILD" and bpn in ["rust"]:
return arch + "-unknown-linux-gnu"
- # All the Yocto targets are Linux and are 'unknown'
- vendor = "-unknown"
- os = d.getVar('{}_OS'.format(thing))
- libc = determine_libc(d, thing)
-
- # Prefix with a dash and convert glibc -> gnu
- if libc == "glibc":
- libc = "-gnu"
- elif libc == "musl":
- libc = "-musl"
-
- # Don't double up musl (only appears to be the case on aarch64)
- if os == "linux-musl":
- if libc != "-musl":
- bb.fatal("{}_OS was '{}' but TCLIBC was not 'musl'".format(thing, os))
- os = "linux"
+ vendor = d.getVar('{}_VENDOR'.format(thing))
+ # Default to glibc
+ libc = "-gnu"
+ os = d.getVar('{}_OS'.format(thing))
# This catches ARM targets and appends the necessary hard float bits
if os == "linux-gnueabi" or os == "linux-musleabi":
libc = bb.utils.contains('TUNE_FEATURES', 'callconvention-hard', 'hf', '', d)
+ elif "musl" in os:
+ libc = "-musl"
+ os = "linux"
+
return arch + vendor + '-' + os + libc