Skip to content

Remove most of the logic in fake rustc once -Ztarget-applies-to-host=true lands #94556

Open
@jyn514

Description

@jyn514

rust-lang/cargo#10395 made it possible to apply RUSTFLAGS to build scripts and proc-macros. Bootstrap currently special-cases this in fake rustc:

// FIXME(rust-lang/cargo#5754) we shouldn't be using special env vars
// here, but rather Cargo should know what flags to pass rustc itself.
// Override linker if necessary.
if let Ok(host_linker) = env::var("RUSTC_HOST_LINKER") {
cmd.arg(format!("-Clinker={}", host_linker));
}
if env::var_os("RUSTC_HOST_FUSE_LD_LLD").is_some() {
cmd.arg("-Clink-args=-fuse-ld=lld");
}
if let Ok(s) = env::var("RUSTC_HOST_CRT_STATIC") {
if s == "true" {
cmd.arg("-C").arg("target-feature=+crt-static");
}
if s == "false" {
cmd.arg("-C").arg("target-feature=-crt-static");
}
}
if stage == "0" {
// Cargo doesn't pass RUSTFLAGS to proc_macros:
// https://github.com/rust-lang/cargo/issues/4423
// Set `--cfg=bootstrap` explicitly instead.
cmd.arg("--cfg=bootstrap");
}

We should switch to using -Ztarget-applies-to-host=true on the next cargo update.
cc @Mark-Simulacrum @ehuss @jonhoo (thank you again @jonhoo for fixing this! ❤️)

@rustbot label: +A-rustbuild +C-enhancement

Metadata

Metadata

Assignees

No one assigned

    Labels

    C-cleanupCategory: PRs that clean code up or issues documenting cleanup.T-bootstrapRelevant to the bootstrap subteam: Rust's build system (x.py and src/bootstrap)

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions