Skip to content

Commit e92f433

Browse files
committed
Fix building proc-macro crates on musl host when --target is specified.
1 parent ba5cca2 commit e92f433

File tree

1 file changed

+10
-1
lines changed

1 file changed

+10
-1
lines changed

src/cargo/core/compiler/build_context/target_info.rs

+10-1
Original file line numberDiff line numberDiff line change
@@ -403,7 +403,16 @@ fn env_args(
403403
// This is probably a build script or plugin and we're
404404
// compiling with --target. In this scenario there are
405405
// no rustflags we can apply.
406-
return Ok(Vec::new());
406+
// However, musl host need this rustflags to compile
407+
// plugin dynamically.
408+
if cfg!(target_env = "musl") {
409+
let mut rustflags = Vec::new();
410+
rustflags.push("-C".into());
411+
rustflags.push("target-feature=-crt-static".into());
412+
return Ok(rustflags);
413+
} else {
414+
return Ok(Vec::new());
415+
}
407416
}
408417

409418
// First try RUSTFLAGS from the environment

0 commit comments

Comments
 (0)