From 4df28b8bf1c3e9dade6ab29358effc99010f594b Mon Sep 17 00:00:00 2001 From: chenx97 Date: Wed, 4 Sep 2024 14:44:23 +0800 Subject: [PATCH] forward linker option to lint-docs --- src/bootstrap/src/core/build_steps/doc.rs | 3 +++ src/tools/lint-docs/src/lib.rs | 5 +++++ src/tools/lint-docs/src/main.rs | 8 ++++++++ 3 files changed, 16 insertions(+) diff --git a/src/bootstrap/src/core/build_steps/doc.rs b/src/bootstrap/src/core/build_steps/doc.rs index ffb617c642baf..ac68bbf805092 100644 --- a/src/bootstrap/src/core/build_steps/doc.rs +++ b/src/bootstrap/src/core/build_steps/doc.rs @@ -1186,6 +1186,9 @@ impl Step for RustcBook { cmd.arg("--rustc"); cmd.arg(&rustc); cmd.arg("--rustc-target").arg(self.target.rustc_target_arg()); + if let Some(target_linker) = builder.linker(self.target) { + cmd.arg("--rustc-linker").arg(target_linker); + } if builder.is_verbose() { cmd.arg("--verbose"); } diff --git a/src/tools/lint-docs/src/lib.rs b/src/tools/lint-docs/src/lib.rs index 72bb9db7e7414..532a27b22aa6f 100644 --- a/src/tools/lint-docs/src/lib.rs +++ b/src/tools/lint-docs/src/lib.rs @@ -56,6 +56,8 @@ pub struct LintExtractor<'a> { pub rustc_path: &'a Path, /// The target arch to build the docs for. pub rustc_target: &'a str, + /// The target linker overriding `rustc`'s default + pub rustc_linker: Option<&'a str>, /// Verbose output. pub verbose: bool, /// Validate the style and the code example. @@ -459,6 +461,9 @@ impl<'a> LintExtractor<'a> { } cmd.arg("--error-format=json"); cmd.arg("--target").arg(self.rustc_target); + if let Some(target_linker) = self.rustc_linker { + cmd.arg(format!("-Clinker={target_linker}")); + } if options.contains(&"test") { cmd.arg("--test"); } diff --git a/src/tools/lint-docs/src/main.rs b/src/tools/lint-docs/src/main.rs index 2055fed2b480c..e377283b1a453 100644 --- a/src/tools/lint-docs/src/main.rs +++ b/src/tools/lint-docs/src/main.rs @@ -27,6 +27,7 @@ fn doit() -> Result<(), Box> { let mut out_path = None; let mut rustc_path = None; let mut rustc_target = None; + let mut rustc_linker = None; let mut verbose = false; let mut validate = false; while let Some(arg) = args.next() { @@ -55,6 +56,12 @@ fn doit() -> Result<(), Box> { None => return Err("--rustc-target requires a value".into()), }; } + "--rustc-linker" => { + rustc_linker = match args.next() { + Some(s) => Some(s), + None => return Err("--rustc-linker requires a value".into()), + }; + } "-v" | "--verbose" => verbose = true, "--validate" => validate = true, s => return Err(format!("unexpected argument `{}`", s).into()), @@ -77,6 +84,7 @@ fn doit() -> Result<(), Box> { out_path: &out_path.unwrap(), rustc_path: &rustc_path.unwrap(), rustc_target: &rustc_target.unwrap(), + rustc_linker: rustc_linker.as_deref(), verbose, validate, };