Skip to content

Commit 5d920a3

Browse files
committed
update bootstrap mcp510 handling
now that it's been stabilized, beta and stage1 need to use different flags (-C vs -Z)
1 parent d988376 commit 5d920a3

File tree

4 files changed

+43
-17
lines changed

4 files changed

+43
-17
lines changed

src/bootstrap/src/core/build_steps/test.rs

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -261,7 +261,13 @@ impl Step for Cargotest {
261261
.args(builder.config.test_args())
262262
.env("RUSTC", builder.rustc(compiler))
263263
.env("RUSTDOC", builder.rustdoc(compiler));
264-
add_rustdoc_cargo_linker_args(&mut cmd, builder, compiler.host, LldThreads::No);
264+
add_rustdoc_cargo_linker_args(
265+
&mut cmd,
266+
builder,
267+
compiler.host,
268+
LldThreads::No,
269+
compiler.stage,
270+
);
265271
cmd.delay_failure().run(builder);
266272
}
267273
}
@@ -839,7 +845,7 @@ impl Step for RustdocTheme {
839845
.env("CFG_RELEASE_CHANNEL", &builder.config.channel)
840846
.env("RUSTDOC_REAL", builder.rustdoc(self.compiler))
841847
.env("RUSTC_BOOTSTRAP", "1");
842-
cmd.args(linker_args(builder, self.compiler.host, LldThreads::No));
848+
cmd.args(linker_args(builder, self.compiler.host, LldThreads::No, self.compiler.stage));
843849

844850
cmd.delay_failure().run(builder);
845851
}
@@ -1015,7 +1021,13 @@ impl Step for RustdocGUI {
10151021
cmd.env("RUSTDOC", builder.rustdoc(self.compiler))
10161022
.env("RUSTC", builder.rustc(self.compiler));
10171023

1018-
add_rustdoc_cargo_linker_args(&mut cmd, builder, self.compiler.host, LldThreads::No);
1024+
add_rustdoc_cargo_linker_args(
1025+
&mut cmd,
1026+
builder,
1027+
self.compiler.host,
1028+
LldThreads::No,
1029+
self.compiler.stage,
1030+
);
10191031

10201032
for path in &builder.paths {
10211033
if let Some(p) = helpers::is_valid_test_suite_arg(path, "tests/rustdoc-gui", builder) {
@@ -1784,7 +1796,7 @@ NOTE: if you're sure you want to do this, please open an issue as to why. In the
17841796
}
17851797

17861798
let mut hostflags = flags.clone();
1787-
hostflags.extend(linker_flags(builder, compiler.host, LldThreads::No));
1799+
hostflags.extend(linker_flags(builder, compiler.host, LldThreads::No, compiler.stage));
17881800

17891801
let mut targetflags = flags;
17901802

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -260,7 +260,7 @@ impl Cargo {
260260
}
261261
}
262262

263-
for arg in linker_args(builder, compiler.host, LldThreads::Yes) {
263+
for arg in linker_args(builder, compiler.host, LldThreads::Yes, 0) {
264264
self.hostflags.arg(&arg);
265265
}
266266

@@ -270,10 +270,10 @@ impl Cargo {
270270
}
271271
// We want to set -Clinker using Cargo, therefore we only call `linker_flags` and not
272272
// `linker_args` here.
273-
for flag in linker_flags(builder, target, LldThreads::Yes) {
273+
for flag in linker_flags(builder, target, LldThreads::Yes, compiler.stage) {
274274
self.rustflags.arg(&flag);
275275
}
276-
for arg in linker_args(builder, target, LldThreads::Yes) {
276+
for arg in linker_args(builder, target, LldThreads::Yes, compiler.stage) {
277277
self.rustdocflags.arg(&arg);
278278
}
279279

src/bootstrap/src/core/builder/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1479,7 +1479,7 @@ impl<'a> Builder<'a> {
14791479
cmd.arg("-Dwarnings");
14801480
}
14811481
cmd.arg("-Znormalize-docs");
1482-
cmd.args(linker_args(self, compiler.host, LldThreads::Yes));
1482+
cmd.args(linker_args(self, compiler.host, LldThreads::Yes, compiler.stage));
14831483
cmd
14841484
}
14851485

src/bootstrap/src/utils/helpers.rs

Lines changed: 23 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -445,8 +445,9 @@ pub fn linker_args(
445445
builder: &Builder<'_>,
446446
target: TargetSelection,
447447
lld_threads: LldThreads,
448+
stage: u32,
448449
) -> Vec<String> {
449-
let mut args = linker_flags(builder, target, lld_threads);
450+
let mut args = linker_flags(builder, target, lld_threads, stage);
450451

451452
if let Some(linker) = builder.linker(target) {
452453
args.push(format!("-Clinker={}", linker.display()));
@@ -461,20 +462,32 @@ pub fn linker_flags(
461462
builder: &Builder<'_>,
462463
target: TargetSelection,
463464
lld_threads: LldThreads,
465+
stage: u32,
464466
) -> Vec<String> {
465467
let mut args = vec![];
466468
if !builder.is_lld_direct_linker(target) && builder.config.lld_mode.is_used() {
467469
match builder.config.lld_mode {
468470
LldMode::External => {
469-
args.push("-Zlinker-features=+lld".to_string());
470-
// FIXME(kobzol): remove this flag once MCP510 gets stabilized
471-
args.push("-Zunstable-options".to_string());
471+
// cfg(bootstrap) - remove the stage 0 check after updating the bootstrap compiler:
472+
// `-Clinker-features` has been stabilized.
473+
if stage == 0 {
474+
args.push("-Zlinker-features=+lld".to_string());
475+
args.push("-Zunstable-options".to_string());
476+
} else {
477+
args.push("-Clinker-features=+lld".to_string());
478+
}
472479
}
473480
LldMode::SelfContained => {
474-
args.push("-Zlinker-features=+lld".to_string());
475-
args.push("-Clink-self-contained=+linker".to_string());
476-
// FIXME(kobzol): remove this flag once MCP510 gets stabilized
477-
args.push("-Zunstable-options".to_string());
481+
// cfg(bootstrap) - remove the stage 0 check after updating the bootstrap compiler:
482+
// `-Clinker-features` and `-Clink-self-contained=+linker` have been stabilized.
483+
if stage == 0 {
484+
args.push("-Zlinker-features=+lld".to_string());
485+
args.push("-Clink-self-contained=+linker".to_string());
486+
args.push("-Zunstable-options".to_string());
487+
} else {
488+
args.push("-Clinker-features=+lld".to_string());
489+
args.push("-Clink-self-contained=+linker".to_string());
490+
}
478491
}
479492
LldMode::Unused => unreachable!(),
480493
};
@@ -494,8 +507,9 @@ pub fn add_rustdoc_cargo_linker_args(
494507
builder: &Builder<'_>,
495508
target: TargetSelection,
496509
lld_threads: LldThreads,
510+
stage: u32,
497511
) {
498-
let args = linker_args(builder, target, lld_threads);
512+
let args = linker_args(builder, target, lld_threads, stage);
499513
let mut flags = cmd
500514
.get_envs()
501515
.find_map(|(k, v)| if k == OsStr::new("RUSTDOCFLAGS") { v } else { None })

0 commit comments

Comments
 (0)