deleted file mode 100644
@@ -1,3 +0,0 @@
-fn main() {
- println!("static-musl-ok");
-}
similarity index 58%
rename from meta-selftest/recipes-devtools/rust/rust-static-musl-test/Cargo.lock
rename to meta-selftest/recipes-devtools/rust/rust-static-test/Cargo.lock
@@ -1,5 +1,5 @@
version = 3
[[package]]
-name = "rust-static-musl-test"
+name = "rust-static-test"
version = "0.1.0"
similarity index 59%
rename from meta-selftest/recipes-devtools/rust/rust-static-musl-test/Cargo.toml
rename to meta-selftest/recipes-devtools/rust/rust-static-test/Cargo.toml
@@ -1,4 +1,4 @@
[package]
-name = "rust-static-musl-test"
+name = "rust-static-test"
version = "0.1.0"
edition = "2021"
new file mode 100644
@@ -0,0 +1,3 @@
+fn main() {
+ println!("static-ok");
+}
similarity index 66%
rename from meta-selftest/recipes-devtools/rust/rust-static-musl-test_0.1.bb
rename to meta-selftest/recipes-devtools/rust/rust-static-test_0.1.bb
@@ -1,7 +1,7 @@
# SPDX-License-Identifier: MIT
-# Minimal Rust binary to test static musl linking (bug 16076)
+# Minimal Rust binary to test static musl (bug 16076) and glibc linking
-SUMMARY = "Minimal Rust binary for static musl linking regression test"
+SUMMARY = "Minimal Rust binary for static linking regression test"
LICENSE = "MIT"
LIC_FILES_CHKSUM = "file://${COMMON_LICENSE_DIR}/MIT;md5=0835ade698e0bcf8506ecda2f7b4f302"
@@ -15,6 +15,4 @@ CARGO_SRC_DIR = ""
inherit cargo
-COMPATIBLE_HOST = ".*-musl.*"
-
SSTATE_SKIP_CREATION = "1"
@@ -438,7 +438,9 @@ def rust_gen_target(d, thing, wd, arch):
tspec['has-thread-local'] = True
tspec['position-independent-executables'] = True
tspec['panic-strategy'] = d.getVar("RUST_PANIC_STRATEGY")
- if "musl" in tspec['llvm-target']:
+ # Like upstream rustc's base Linux target, honour -C target-feature=+crt-static
+ # for both glibc and musl
+ if tspec['os'] == "linux":
tspec['crt-static-respected'] = True
# AArch64 AAPCS64 requires non-leaf frame pointers per
# https://github.com/ARM-software/abi-aa/blob/main/aapcs64/aapcs64.rst#the-frame-pointer
@@ -152,22 +152,20 @@ class RustSelfTestSystemEmulated(OESelftestTestCase, OEPTestResultTestCase):
for test in test_results:
self.ptest_result(ptestsuite, test, test_results[test])
-# Regression test for bug 16076 - verify static linking with TCLIBC=musl
-class RustStaticMuslTest(OESelftestTestCase):
+# Regression test for bug 16076 - verify static linking with TCLIBC=musl and glibc
+class RustStaticTest(OESelftestTestCase):
- RECIPE = "rust-static-musl-test"
+ RECIPE = "rust-static-test"
- def setUp(self):
- super().setUp()
+ def check_static_linking(self, tclibc):
self.write_config(
- 'TCLIBC = "musl"\n'
- 'RUSTFLAGS:append:pn-%s = " -C target-feature=+crt-static"\n' % self.RECIPE
+ 'TCLIBC = "%s"\n'
+ 'RUSTFLAGS:append:pn-%s = " -C target-feature=+crt-static"\n' % (tclibc, self.RECIPE)
)
result = bitbake(self.RECIPE, ignore_status=True)
self.assertEqual(result.status, 0,
msg="bitbake %s failed:\n%s" % (self.RECIPE, result.output))
- def test_static_musl_linking(self):
workdir = get_bb_var("WORKDIR", self.RECIPE)
cargo_target_subdir = get_bb_var("CARGO_TARGET_SUBDIR", self.RECIPE)
pn = get_bb_var("PN", self.RECIPE)
@@ -180,3 +178,9 @@ class RustStaticMuslTest(OESelftestTestCase):
self.assertIn("statically linked", result.output,
msg="Binary is not statically linked. Regression of bug 16076.\n"
"file output: %s" % result.output)
+
+ def test_static_glibc_linking(self):
+ self.check_static_linking("glibc")
+
+ def test_static_musl_linking(self):
+ self.check_static_linking("musl")