about summary refs log tree commit diff
diff options
context:
space:
mode:
authorJens Reidel <adrian@travitia.xyz>2025-07-21 02:01:42 +0200
committerJens Reidel <adrian@travitia.xyz>2025-07-21 02:14:01 +0200
commita546a7cb255da0c4ea4fbfa918d786890bde928e (patch)
tree589e25a0f26bc7d6d0f1b91476f6af8c10163dc7
parent0864097cd31ee30f5081ba588a5c9820c2c6fc71 (diff)
downloadrust-a546a7cb255da0c4ea4fbfa918d786890bde928e.tar.gz
rust-a546a7cb255da0c4ea4fbfa918d786890bde928e.zip
Fix run-make tests on musl hosts
On musl hosts, we already set -Ctarget-feature=-crt-static and
IS_MUSL_HOST=1 in compiletest. However, in order for the run-make tests
to compile fine on musl hosts, we need to propagate this flag in our
rustc invocations to ensure we can generate cdylibs.

Signed-off-by: Jens Reidel <adrian@travitia.xyz>
-rw-r--r--src/tools/run-make-support/src/external_deps/rustc.rs9
1 files changed, 8 insertions, 1 deletions
diff --git a/src/tools/run-make-support/src/external_deps/rustc.rs b/src/tools/run-make-support/src/external_deps/rustc.rs
index 1ea549ca7ea..08ba1388dc1 100644
--- a/src/tools/run-make-support/src/external_deps/rustc.rs
+++ b/src/tools/run-make-support/src/external_deps/rustc.rs
@@ -52,13 +52,20 @@ impl Rustc {
     // `rustc` invocation constructor methods
 
     /// Construct a new `rustc` invocation. This will automatically set the library
-    /// search path as `-L cwd()` and also the compilation target.
+    /// search path as `-L cwd()`, configure the compilation target and enable
+    /// dynamic linkage by default on musl hosts.
     /// Use [`bare_rustc`] to avoid this.
     #[track_caller]
     pub fn new() -> Self {
         let mut cmd = setup_common();
         cmd.arg("-L").arg(cwd());
 
+        // FIXME: On musl hosts, we currently default to static linkage, while
+        // for running run-make tests, we rely on dynamic linkage by default
+        if std::env::var("IS_MUSL_HOST").is_ok_and(|i| i == "1") {
+            cmd.arg("-Ctarget-feature=-crt-static");
+        }
+
         // Automatically default to cross-compilation
         Self { cmd, target: Some(target()) }
     }