Skip to content

Commit 0df5ce6

Browse files
committed
musl: tests workaround
1 parent 4027169 commit 0df5ce6

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

src/tools/compiletest/src/runtest.rs

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1842,7 +1842,10 @@ impl<'test> TestCx<'test> {
18421842
None => {}
18431843
}
18441844

1845-
if self.props.force_host {
1845+
// Musl toolchain is build on linux-gnu host
1846+
// but with proper setup it can behave almost* like native linux-musl.
1847+
// One difference is "cc" which will link to glibc; force musl cc.
1848+
if self.props.force_host && !self.config.target.contains("musl") {
18461849
self.maybe_add_external_args(&mut rustc,
18471850
self.split_maybe_args(&self.config.host_rustcflags));
18481851
} else {
@@ -1855,6 +1858,11 @@ impl<'test> TestCx<'test> {
18551858
}
18561859
}
18571860

1861+
// Use dynamic musl for tests because static doesn't allow creating dylibs
1862+
if self.config.target.contains("musl") {
1863+
rustc.arg("-Ctarget-feature=-crt-static");
1864+
}
1865+
18581866
rustc.args(&self.props.compile_flags);
18591867

18601868
rustc

0 commit comments

Comments
 (0)