Skip to content

Commit 68034f8

Browse files
committed
Disable -Zdual-proc-macros if the target doesn't support proc-macros
1 parent 6414d9f commit 68034f8

File tree

1 file changed

+17
-3
lines changed

1 file changed

+17
-3
lines changed

src/bootstrap/src/core/builder.rs

+17-3
Original file line numberDiff line numberDiff line change
@@ -1683,10 +1683,24 @@ impl<'a> Builder<'a> {
16831683
match mode {
16841684
Mode::Std | Mode::ToolBootstrap | Mode::ToolStd => {}
16851685
Mode::Rustc | Mode::Codegen | Mode::ToolRustc => {
1686-
// Build proc macros both for the host and the target
1686+
// Build proc macros both for the host and the target unless proc-macros are not
1687+
// supported by the target.
16871688
if target != compiler.host && cmd_kind != Kind::Check {
1688-
cargo.arg("-Zdual-proc-macros");
1689-
rustflags.arg("-Zdual-proc-macros");
1689+
let error = command(self.rustc(compiler))
1690+
.arg("--target")
1691+
.arg(target.rustc_target_arg())
1692+
.arg("--print=file-names")
1693+
.arg("--crate-type=proc-macro")
1694+
.arg("-")
1695+
.run_capture(self)
1696+
.stderr();
1697+
let not_supported = error
1698+
.lines()
1699+
.any(|line| line.contains("unsupported crate type `proc-macro`"));
1700+
if !not_supported {
1701+
cargo.arg("-Zdual-proc-macros");
1702+
rustflags.arg("-Zdual-proc-macros");
1703+
}
16901704
}
16911705
}
16921706
}

0 commit comments

Comments
 (0)