mirror of
https://github.com/rust-lang/rust.git
synced 2025-10-02 18:27:37 +00:00

`rustdoc` was filling a `target_modifiers` variable, but it was not using the result. In turn, that means that trying to use a dependency that set a target modifier fails. For instance, running: ```sh RUSTC_BOOTSTRAP=1 rustc --edition=2024 --target=aarch64-unknown-none-softfloat --sysroot=/dev/null --emit=metadata -Zfixed-x18 --crate-type rlib --crate-name core $(rustc --print sysroot)/lib/rustlib/src/rust/library/core/src/lib.rs echo '#![allow(internal_features)] ' | RUSTC_BOOTSTRAP=1 rustdoc --edition=2021 --target=aarch64-unknown-none-softfloat --sysroot=/dev/null -Zfixed-x18 --extern core=libcore.rmeta - ``` will fail with: ```text error: mixing `-Zfixed-x18` will cause an ABI mismatch in crate `rust_out` | = help: the `-Zfixed-x18` flag modifies the ABI so Rust crates compiled with different values of this flag cannot be used together safely = note: unset `-Zfixed-x18` in this crate is incompatible with `-Zfixed-x18=` in dependency `core` = help: set `-Zfixed-x18=` in this crate or unset `-Zfixed-x18` in `core` = help: if you are sure this will not cause problems, you may use `-Cunsafe-allow-abi-mismatch=fixed-x18` to silence this error ``` Thus save the targets modifiers in `Options` to then pass it to the session options, so that eventually the diff can be performed as expected in `report_incompatible_target_modifiers()`. Fixes: https://github.com/rust-lang/rust/issues/144521 Signed-off-by: Miguel Ojeda <ojeda@kernel.org>
29 lines
765 B
Rust
29 lines
765 B
Rust
//! Test that target modifiers are taken into account by `rustdoc`.
|
|
//!
|
|
//! Otherwise, `rustdoc` errors when trying to generate documentation
|
|
//! using dependencies (e.g. `core`) that set a target modifier.
|
|
//!
|
|
//! Please see https://github.com/rust-lang/rust/issues/144521.
|
|
|
|
use run_make_support::{rustc, rustdoc};
|
|
|
|
fn main() {
|
|
rustc()
|
|
.input("d.rs")
|
|
.edition("2024")
|
|
.crate_type("rlib")
|
|
.emit("metadata")
|
|
.sysroot("/dev/null")
|
|
.target("aarch64-unknown-none-softfloat")
|
|
.arg("-Zfixed-x18")
|
|
.run();
|
|
|
|
rustdoc()
|
|
.input("c.rs")
|
|
.crate_type("rlib")
|
|
.extern_("d", "libd.rmeta")
|
|
.target("aarch64-unknown-none-softfloat")
|
|
.arg("-Zfixed-x18")
|
|
.run();
|
|
}
|