Skip to content

Commit 0471141

Browse files
Rollup merge of #151745 - bjorn3:remove_unnecessary_flags, r=clubby789
Remove a couple of unnecessary flags and env vars in bootstrap
2 parents c7f5f3e + 257ea3b commit 0471141

2 files changed

Lines changed: 5 additions & 53 deletions

File tree

src/bootstrap/src/core/build_steps/compile.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1378,6 +1378,9 @@ pub fn rustc_cargo_env(builder: &Builder<'_>, cargo: &mut Cargo, target: TargetS
13781378
}
13791379
}
13801380

1381+
// The host this new compiler will *run* on.
1382+
cargo.env("CFG_COMPILER_HOST_TRIPLE", target.triple);
1383+
13811384
if builder.config.rust_verify_llvm_ir {
13821385
cargo.env("RUSTC_VERIFY_LLVM_IR", "1");
13831386
}

src/bootstrap/src/core/builder/cargo.rs

Lines changed: 2 additions & 53 deletions
Original file line numberDiff line numberDiff line change
@@ -331,10 +331,6 @@ impl Cargo {
331331
self.rustflags.arg("-Clink-arg=-gz");
332332
}
333333

334-
// Ignore linker warnings for now. These are complicated to fix and don't affect the build.
335-
// FIXME: we should really investigate these...
336-
self.rustflags.arg("-Alinker-messages");
337-
338334
// Throughout the build Cargo can execute a number of build scripts
339335
// compiling C/C++ code and we need to pass compilers, archivers, flags, etc
340336
// obtained previously to those build scripts.
@@ -1256,23 +1252,15 @@ impl Builder<'_> {
12561252
// when compiling the standard library, since this might be linked into the final outputs
12571253
// produced by rustc. Since this mitigation is only available on Windows, only enable it
12581254
// for the standard library in case the compiler is run on a non-Windows platform.
1259-
// This is not needed for stage 0 artifacts because these will only be used for building
1260-
// the stage 1 compiler.
1261-
if cfg!(windows)
1262-
&& mode == Mode::Std
1263-
&& self.config.control_flow_guard
1264-
&& compiler.stage >= 1
1265-
{
1255+
if cfg!(windows) && mode == Mode::Std && self.config.control_flow_guard {
12661256
rustflags.arg("-Ccontrol-flow-guard");
12671257
}
12681258

12691259
// If EHCont Guard is enabled, pass the `-Zehcont-guard` flag to rustc when compiling the
12701260
// standard library, since this might be linked into the final outputs produced by rustc.
12711261
// Since this mitigation is only available on Windows, only enable it for the standard
12721262
// library in case the compiler is run on a non-Windows platform.
1273-
// This is not needed for stage 0 artifacts because these will only be used for building
1274-
// the stage 1 compiler.
1275-
if cfg!(windows) && mode == Mode::Std && self.config.ehcont_guard && compiler.stage >= 1 {
1263+
if cfg!(windows) && mode == Mode::Std && self.config.ehcont_guard {
12761264
rustflags.arg("-Zehcont-guard");
12771265
}
12781266

@@ -1289,52 +1277,13 @@ impl Builder<'_> {
12891277
rustdocflags.arg("--crate-version").arg(&rust_version);
12901278

12911279
// Environment variables *required* throughout the build
1292-
//
1293-
// FIXME: should update code to not require this env var
12941280

1295-
// The host this new compiler will *run* on.
1296-
cargo.env("CFG_COMPILER_HOST_TRIPLE", target.triple);
12971281
// The host this new compiler is being *built* on.
12981282
cargo.env("CFG_COMPILER_BUILD_TRIPLE", compiler.host.triple);
12991283

13001284
// Set this for all builds to make sure doc builds also get it.
13011285
cargo.env("CFG_RELEASE_CHANNEL", &self.config.channel);
13021286

1303-
// This one's a bit tricky. As of the time of this writing the compiler
1304-
// links to the `winapi` crate on crates.io. This crate provides raw
1305-
// bindings to Windows system functions, sort of like libc does for
1306-
// Unix. This crate also, however, provides "import libraries" for the
1307-
// MinGW targets. There's an import library per dll in the windows
1308-
// distribution which is what's linked to. These custom import libraries
1309-
// are used because the winapi crate can reference Windows functions not
1310-
// present in the MinGW import libraries.
1311-
//
1312-
// For example MinGW may ship libdbghelp.a, but it may not have
1313-
// references to all the functions in the dbghelp dll. Instead the
1314-
// custom import library for dbghelp in the winapi crates has all this
1315-
// information.
1316-
//
1317-
// Unfortunately for us though the import libraries are linked by
1318-
// default via `-ldylib=winapi_foo`. That is, they're linked with the
1319-
// `dylib` type with a `winapi_` prefix (so the winapi ones don't
1320-
// conflict with the system MinGW ones). This consequently means that
1321-
// the binaries we ship of things like rustc_codegen_llvm (aka the rustc_codegen_llvm
1322-
// DLL) when linked against *again*, for example with procedural macros
1323-
// or plugins, will trigger the propagation logic of `-ldylib`, passing
1324-
// `-lwinapi_foo` to the linker again. This isn't actually available in
1325-
// our distribution, however, so the link fails.
1326-
//
1327-
// To solve this problem we tell winapi to not use its bundled import
1328-
// libraries. This means that it will link to the system MinGW import
1329-
// libraries by default, and the `-ldylib=foo` directives will still get
1330-
// passed to the final linker, but they'll look like `-lfoo` which can
1331-
// be resolved because MinGW has the import library. The downside is we
1332-
// don't get newer functions from Windows, but we don't use any of them
1333-
// anyway.
1334-
if !mode.is_tool() {
1335-
cargo.env("WINAPI_NO_BUNDLED_LIBRARIES", "1");
1336-
}
1337-
13381287
// verbose cargo output is very noisy, so only enable it with -vv
13391288
for _ in 0..self.verbosity.saturating_sub(1) {
13401289
cargo.arg("--verbose");

0 commit comments

Comments
 (0)