Skip to content

Commit 5f518ad

Browse files
committed
compiletest: Don't force dylibs on musl
MUSL support is currently only with static builds, so building a dylib will always fail.
1 parent 6c04872 commit 5f518ad

File tree

1 file changed

+14
-1
lines changed

1 file changed

+14
-1
lines changed

src/compiletest/runtest.rs

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1233,7 +1233,20 @@ fn compose_and_run_compiler(config: &Config, props: &TestProps,
12331233
let mut crate_type = if aux_props.no_prefer_dynamic {
12341234
Vec::new()
12351235
} else {
1236-
vec!("--crate-type=dylib".to_string())
1236+
// We primarily compile all auxiliary libraries as dynamic libraries
1237+
// to avoid code size bloat and large binaries as much as possible
1238+
// for the test suite (otherwise including libstd statically in all
1239+
// executables takes up quite a bit of space).
1240+
//
1241+
// For targets like MUSL, however, there is no support for dynamic
1242+
// libraries so we just go back to building a normal library. Note,
1243+
// however, that if the library is built with `force_host` then it's
1244+
// ok to be a dylib as the host should always support dylibs.
1245+
if config.target.contains("musl") && !aux_props.force_host {
1246+
vec!("--crate-type=lib".to_string())
1247+
} else {
1248+
vec!("--crate-type=dylib".to_string())
1249+
}
12371250
};
12381251
crate_type.extend(extra_link_args.clone().into_iter());
12391252
let aux_args =

0 commit comments

Comments
 (0)