Skip to content

Commit d34ad5d

Browse files
authored
Rollup merge of #129957 - chenx97:lint-docs-linker-opt, r=albertlarsan68
forward linker option to lint-docs This fixes an error found when building the doc for a cross-built toolchain. ``` warning: the code example in lint `unstable_syntax_pre_expansion` in /buildroots/chenx97/rustc-1.80.1-src/compiler/rustc_lint_defs/src/builtin.rs failed to generate the expected output: did not find lint `unstable_syntax_p re_expansion` in output of example, got: error: linking with `cc` failed: exit status: 1 ... ``` Closes: #129956
2 parents a0ab808 + 4df28b8 commit d34ad5d

File tree

3 files changed

+16
-0
lines changed

3 files changed

+16
-0
lines changed

Diff for: src/bootstrap/src/core/build_steps/doc.rs

+3
Original file line numberDiff line numberDiff line change
@@ -1186,6 +1186,9 @@ impl Step for RustcBook {
11861186
cmd.arg("--rustc");
11871187
cmd.arg(&rustc);
11881188
cmd.arg("--rustc-target").arg(self.target.rustc_target_arg());
1189+
if let Some(target_linker) = builder.linker(self.target) {
1190+
cmd.arg("--rustc-linker").arg(target_linker);
1191+
}
11891192
if builder.is_verbose() {
11901193
cmd.arg("--verbose");
11911194
}

Diff for: src/tools/lint-docs/src/lib.rs

+5
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,8 @@ pub struct LintExtractor<'a> {
5656
pub rustc_path: &'a Path,
5757
/// The target arch to build the docs for.
5858
pub rustc_target: &'a str,
59+
/// The target linker overriding `rustc`'s default
60+
pub rustc_linker: Option<&'a str>,
5961
/// Verbose output.
6062
pub verbose: bool,
6163
/// Validate the style and the code example.
@@ -459,6 +461,9 @@ impl<'a> LintExtractor<'a> {
459461
}
460462
cmd.arg("--error-format=json");
461463
cmd.arg("--target").arg(self.rustc_target);
464+
if let Some(target_linker) = self.rustc_linker {
465+
cmd.arg(format!("-Clinker={target_linker}"));
466+
}
462467
if options.contains(&"test") {
463468
cmd.arg("--test");
464469
}

Diff for: src/tools/lint-docs/src/main.rs

+8
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ fn doit() -> Result<(), Box<dyn Error>> {
2727
let mut out_path = None;
2828
let mut rustc_path = None;
2929
let mut rustc_target = None;
30+
let mut rustc_linker = None;
3031
let mut verbose = false;
3132
let mut validate = false;
3233
while let Some(arg) = args.next() {
@@ -55,6 +56,12 @@ fn doit() -> Result<(), Box<dyn Error>> {
5556
None => return Err("--rustc-target requires a value".into()),
5657
};
5758
}
59+
"--rustc-linker" => {
60+
rustc_linker = match args.next() {
61+
Some(s) => Some(s),
62+
None => return Err("--rustc-linker requires a value".into()),
63+
};
64+
}
5865
"-v" | "--verbose" => verbose = true,
5966
"--validate" => validate = true,
6067
s => return Err(format!("unexpected argument `{}`", s).into()),
@@ -77,6 +84,7 @@ fn doit() -> Result<(), Box<dyn Error>> {
7784
out_path: &out_path.unwrap(),
7885
rustc_path: &rustc_path.unwrap(),
7986
rustc_target: &rustc_target.unwrap(),
87+
rustc_linker: rustc_linker.as_deref(),
8088
verbose,
8189
validate,
8290
};

0 commit comments

Comments
 (0)