Skip to content

Commit

Permalink
Disable -Zdual-proc-macros if the target doesn't support proc-macros
Browse files Browse the repository at this point in the history
  • Loading branch information
bjorn3 committed Oct 4, 2024
1 parent 6414d9f commit 68034f8
Showing 1 changed file with 17 additions and 3 deletions.
20 changes: 17 additions & 3 deletions src/bootstrap/src/core/builder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1683,10 +1683,24 @@ impl<'a> Builder<'a> {
match mode {
Mode::Std | Mode::ToolBootstrap | Mode::ToolStd => {}
Mode::Rustc | Mode::Codegen | Mode::ToolRustc => {
// Build proc macros both for the host and the target
// Build proc macros both for the host and the target unless proc-macros are not
// supported by the target.
if target != compiler.host && cmd_kind != Kind::Check {
cargo.arg("-Zdual-proc-macros");
rustflags.arg("-Zdual-proc-macros");
let error = command(self.rustc(compiler))
.arg("--target")
.arg(target.rustc_target_arg())
.arg("--print=file-names")
.arg("--crate-type=proc-macro")
.arg("-")
.run_capture(self)
.stderr();
let not_supported = error
.lines()
.any(|line| line.contains("unsupported crate type `proc-macro`"));
if !not_supported {
cargo.arg("-Zdual-proc-macros");
rustflags.arg("-Zdual-proc-macros");
}
}
}
}
Expand Down

0 comments on commit 68034f8

Please sign in to comment.