Skip to content

Commit fdaf594

Browse files
committed
Auto merge of #63834 - andjo403:rustdoc-linker-remove, r=Mark-Simulacrum
remove the unstable rustdoc parameter --linker use the code generation parameter -Clinker (same parameter as rustc) to control what linker to use for building the rustdoc test executables. closes: #63816
2 parents dfd43f0 + f0b30c7 commit fdaf594

File tree

7 files changed

+6
-31
lines changed

7 files changed

+6
-31
lines changed

src/bootstrap/bin/rustdoc.rs

+4-1
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
use std::env;
66
use std::process::Command;
77
use std::path::PathBuf;
8+
use std::ffi::OsString;
89

910
fn main() {
1011
let args = env::args_os().skip(1).collect::<Vec<_>>();
@@ -44,7 +45,9 @@ fn main() {
4445
cmd.arg("-Z").arg("force-unstable-if-unmarked");
4546
}
4647
if let Some(linker) = env::var_os("RUSTC_TARGET_LINKER") {
47-
cmd.arg("--linker").arg(linker).arg("-Z").arg("unstable-options");
48+
let mut arg = OsString::from("-Clinker=");
49+
arg.push(&linker);
50+
cmd.arg(arg);
4851
}
4952

5053
// Bootstrap's Cargo-command builder sets this variable to the current Rust version; let's pick

src/doc/rustdoc/src/unstable-features.md

-13
Original file line numberDiff line numberDiff line change
@@ -311,19 +311,6 @@ When `rustdoc` receives this flag, it will print an extra "Version (version)" in
311311
the crate root's docs. You can use this flag to differentiate between different versions of your
312312
library's documentation.
313313

314-
### `--linker`: control the linker used for documentation tests
315-
316-
Using this flag looks like this:
317-
318-
```bash
319-
$ rustdoc --test src/lib.rs -Z unstable-options --linker foo
320-
$ rustdoc --test README.md -Z unstable-options --linker foo
321-
```
322-
323-
When `rustdoc` runs your documentation tests, it needs to compile and link the tests as executables
324-
before running them. This flag can be used to change the linker used on these executables. It's
325-
equivalent to passing `-C linker=foo` to `rustc`.
326-
327314
### `--sort-modules-by-appearance`: control how items on module pages are sorted
328315

329316
Using this flag looks like this:

src/librustdoc/config.rs

-5
Original file line numberDiff line numberDiff line change
@@ -60,8 +60,6 @@ pub struct Options {
6060
pub edition: Edition,
6161
/// The path to the sysroot. Used during the compilation process.
6262
pub maybe_sysroot: Option<PathBuf>,
63-
/// Linker to use when building doctests.
64-
pub linker: Option<PathBuf>,
6563
/// Lint information passed over the command-line.
6664
pub lint_opts: Vec<(String, Level)>,
6765
/// Whether to ask rustc to describe the lints it knows. Practically speaking, this will not be
@@ -130,7 +128,6 @@ impl fmt::Debug for Options {
130128
.field("target", &self.target)
131129
.field("edition", &self.edition)
132130
.field("maybe_sysroot", &self.maybe_sysroot)
133-
.field("linker", &self.linker)
134131
.field("lint_opts", &self.lint_opts)
135132
.field("describe_lints", &self.describe_lints)
136133
.field("lint_cap", &self.lint_cap)
@@ -454,7 +451,6 @@ impl Options {
454451
let playground_url = matches.opt_str("playground-url");
455452
let maybe_sysroot = matches.opt_str("sysroot").map(PathBuf::from);
456453
let display_warnings = matches.opt_present("display-warnings");
457-
let linker = matches.opt_str("linker").map(PathBuf::from);
458454
let sort_modules_alphabetically = !matches.opt_present("sort-modules-by-appearance");
459455
let resource_suffix = matches.opt_str("resource-suffix").unwrap_or_default();
460456
let enable_minification = !matches.opt_present("disable-minification");
@@ -489,7 +485,6 @@ impl Options {
489485
target,
490486
edition,
491487
maybe_sysroot,
492-
linker,
493488
lint_opts,
494489
describe_lints,
495490
lint_cap,

src/librustdoc/lib.rs

-3
Original file line numberDiff line numberDiff line change
@@ -242,9 +242,6 @@ fn opts() -> Vec<RustcOptGroup> {
242242
unstable("crate-version", |o| {
243243
o.optopt("", "crate-version", "crate version to print into documentation", "VERSION")
244244
}),
245-
unstable("linker", |o| {
246-
o.optopt("", "linker", "linker used for building executable test code", "PATH")
247-
}),
248245
unstable("sort-modules-by-appearance", |o| {
249246
o.optflag("", "sort-modules-by-appearance", "sort modules by where they appear in the \
250247
program, rather than alphabetically")

src/librustdoc/test.rs

-3
Original file line numberDiff line numberDiff line change
@@ -267,9 +267,6 @@ fn run_test(
267267
for codegen_options_str in &options.codegen_options_strs {
268268
compiler.arg("-C").arg(&codegen_options_str);
269269
}
270-
if let Some(linker) = options.linker {
271-
compiler.arg(&format!("-C linker={:?}", linker));
272-
}
273270
if no_run {
274271
compiler.arg("--emit=metadata");
275272
}

src/test/run-make-fulldeps/tools.mk

+1-1
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ RUSTC := $(BARE_RUSTC) --out-dir $(TMPDIR) -L $(TMPDIR) $(RUSTFLAGS)
1212
RUSTDOC := $(BARE_RUSTDOC) -L $(TARGET_RPATH_DIR)
1313
ifdef RUSTC_LINKER
1414
RUSTC := $(RUSTC) -Clinker=$(RUSTC_LINKER)
15-
RUSTDOC := $(RUSTDOC) --linker $(RUSTC_LINKER) -Z unstable-options
15+
RUSTDOC := $(RUSTDOC) -Clinker=$(RUSTC_LINKER)
1616
endif
1717
#CC := $(CC) -L $(TMPDIR)
1818
HTMLDOCCK := $(PYTHON) $(S)/src/etc/htmldocck.py

src/tools/compiletest/src/runtest.rs

+1-5
Original file line numberDiff line numberDiff line change
@@ -1603,11 +1603,7 @@ impl<'test> TestCx<'test> {
16031603
.args(&self.props.compile_flags);
16041604

16051605
if let Some(ref linker) = self.config.linker {
1606-
rustdoc
1607-
.arg("--linker")
1608-
.arg(linker)
1609-
.arg("-Z")
1610-
.arg("unstable-options");
1606+
rustdoc.arg(format!("-Clinker={}", linker));
16111607
}
16121608

16131609
self.compose_and_run_compiler(rustdoc, None)

0 commit comments

Comments
 (0)