Skip to content

Commit 385470b

Browse files
committed
Move handling of -Cprefer-dynamic into builder.rs
This logic is *super* old and can be tweaked and moved into `builder.rs`
1 parent b3f95f4 commit 385470b

File tree

4 files changed

+10
-15
lines changed

4 files changed

+10
-15
lines changed

src/bootstrap/bin/rustc.rs

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -89,13 +89,6 @@ fn main() {
8989
cmd.arg("--sysroot").arg(&sysroot);
9090
}
9191

92-
// When we build Rust dylibs they're all intended for intermediate
93-
// usage, so make sure we pass the -Cprefer-dynamic flag instead of
94-
// linking all deps statically into the dylib.
95-
if env::var_os("RUSTC_NO_PREFER_DYNAMIC").is_none() {
96-
cmd.arg("-Cprefer-dynamic");
97-
}
98-
9992
// If we're compiling specifically the `panic_abort` crate then we pass
10093
// the `-C panic=abort` option. Note that we do not do this for any
10194
// other crate intentionally as this is the only crate for now that we

src/bootstrap/builder.rs

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1227,6 +1227,16 @@ impl<'a> Builder<'a> {
12271227

12281228
self.ci_env.force_coloring_in_ci(&mut cargo);
12291229

1230+
// When we build Rust dylibs they're all intended for intermediate
1231+
// usage, so make sure we pass the -Cprefer-dynamic flag instead of
1232+
// linking all deps statically into the dylib.
1233+
match mode {
1234+
Mode::Std | Mode::Rustc | Mode::Codegen => {
1235+
rustflags.arg("-Cprefer-dynamic");
1236+
}
1237+
_ => {}
1238+
}
1239+
12301240
Cargo {
12311241
command: cargo,
12321242
rustflags,

src/bootstrap/test.rs

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1814,10 +1814,6 @@ impl Step for Crate {
18141814
.expect("nodejs not configured"),
18151815
);
18161816
} else if target.starts_with("wasm32") {
1817-
// On the wasm32-unknown-unknown target we're using LTO which is
1818-
// incompatible with `-C prefer-dynamic`, so disable that here
1819-
cargo.env("RUSTC_NO_PREFER_DYNAMIC", "1");
1820-
18211817
let node = builder
18221818
.config
18231819
.nodejs

src/bootstrap/tool.rs

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -234,10 +234,6 @@ pub fn prepare_tool_cargo(
234234
let dir = builder.src.join(path);
235235
cargo.arg("--manifest-path").arg(dir.join("Cargo.toml"));
236236

237-
// We don't want to build tools dynamically as they'll be running across
238-
// stages and such and it's just easier if they're not dynamically linked.
239-
cargo.env("RUSTC_NO_PREFER_DYNAMIC", "1");
240-
241237
if source_type == SourceType::Submodule {
242238
cargo.env("RUSTC_EXTERNAL_TOOL", "1");
243239
}

0 commit comments

Comments
 (0)