Skip to content

rustdoc: save target modifiers #144523

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jul 28, 2025
Merged

Conversation

ojeda
Copy link
Contributor

@ojeda ojeda commented Jul 27, 2025

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:

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:

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().

Cc: @azhogin
Fixes: #144521

@rustbot
Copy link
Collaborator

rustbot commented Jul 27, 2025

r? @GuillaumeGomez

rustbot has assigned @GuillaumeGomez.
They will have a look at your PR within the next two weeks and either review your PR or reassign to another reviewer.

Use r? to explicitly pick a reviewer

@rustbot rustbot added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. T-rustdoc Relevant to the rustdoc team, which will review and decide on the PR/issue. labels Jul 27, 2025
@rustbot

This comment has been minimized.

@ojeda ojeda force-pushed the rustdoc-target-modifiers branch from 3bcb62d to 7eff864 Compare July 27, 2025 02:31
@rustbot rustbot added the A-run-make Area: port run-make Makefiles to rmake.rs label Jul 27, 2025
@rustbot
Copy link
Collaborator

rustbot commented Jul 27, 2025

This PR modifies run-make tests.

cc @jieyouxu

@ojeda
Copy link
Contributor Author

ojeda commented Jul 27, 2025

Added a test and removed the @user.

@rust-log-analyzer

This comment has been minimized.

`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: rust-lang#144521
Signed-off-by: Miguel Ojeda <ojeda@kernel.org>
@ojeda ojeda force-pushed the rustdoc-target-modifiers branch from 7eff864 to 558796b Compare July 27, 2025 03:22
ojeda added a commit to ojeda/linux that referenced this pull request Jul 27, 2025
Starting with Rust 1.88.0 (released 2025-06-26), `rustdoc` complains
about a target modifier mismatch in configurations where `-Zfixed-x18`
is passed:

    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

The reason is that `rustdoc` was not passing the target modifiers when
configuring the session options, and thus it would report a mismatch
that did not exist as soon as a target modifier is used in a dependency.

We did not notice it in the kernel until now because `-Zfixed-x18` has
been a target modifier only since 1.88.0 (and it is the only one we use
so far).

The issue has been reported upstream [1] and a fix has been submitted
[2], including a test similar to the kernel case.

Meanwhile, conditionally pass `-Cunsafe-allow-abi-mismatch=fixed-x18`
to workaround the issue on our side.

Reported-by: Konrad Dybcio <konrad.dybcio@oss.qualcomm.com>
Closes: https://lore.kernel.org/rust-for-linux/36cdc798-524f-4910-8b77-d7b9fac08d77@oss.qualcomm.com/
Link: rust-lang/rust#144521 [1]
Link: rust-lang/rust#144523 [2]
Signed-off-by: Miguel Ojeda <ojeda@kernel.org>
ojeda added a commit to ojeda/linux that referenced this pull request Jul 27, 2025
Starting with Rust 1.88.0 (released 2025-06-26), `rustdoc` complains
about a target modifier mismatch in configurations where `-Zfixed-x18`
is passed:

    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

The reason is that `rustdoc` was not passing the target modifiers when
configuring the session options, and thus it would report a mismatch
that did not exist as soon as a target modifier is used in a dependency.

We did not notice it in the kernel until now because `-Zfixed-x18` has
been a target modifier only since 1.88.0 (and it is the only one we use
so far).

The issue has been reported upstream [1] and a fix has been submitted
[2], including a test similar to the kernel case.

Meanwhile, conditionally pass `-Cunsafe-allow-abi-mismatch=fixed-x18`
to workaround the issue on our side.

Reported-by: Konrad Dybcio <konrad.dybcio@oss.qualcomm.com>
Closes: https://lore.kernel.org/rust-for-linux/36cdc798-524f-4910-8b77-d7b9fac08d77@oss.qualcomm.com/
Link: rust-lang/rust#144521 [1]
Link: rust-lang/rust#144523 [2]
Signed-off-by: Miguel Ojeda <ojeda@kernel.org>
@GuillaumeGomez
Copy link
Member

Nice, thanks!

@bors r+ rollup

@bors
Copy link
Collaborator

bors commented Jul 27, 2025

📌 Commit 558796b has been approved by GuillaumeGomez

It is now in the queue for this repository.

@bors bors added S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Jul 27, 2025
intel-lab-lkp pushed a commit to intel-lab-lkp/linux that referenced this pull request Jul 27, 2025
Starting with Rust 1.88.0 (released 2025-06-26), `rustdoc` complains
about a target modifier mismatch in configurations where `-Zfixed-x18`
is passed:

    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

The reason is that `rustdoc` was not passing the target modifiers when
configuring the session options, and thus it would report a mismatch
that did not exist as soon as a target modifier is used in a dependency.

We did not notice it in the kernel until now because `-Zfixed-x18` has
been a target modifier only since 1.88.0 (and it is the only one we use
so far).

The issue has been reported upstream [1] and a fix has been submitted
[2], including a test similar to the kernel case.

Meanwhile, conditionally pass `-Cunsafe-allow-abi-mismatch=fixed-x18`
to workaround the issue on our side.

Reported-by: Konrad Dybcio <konrad.dybcio@oss.qualcomm.com>
Closes: https://lore.kernel.org/rust-for-linux/36cdc798-524f-4910-8b77-d7b9fac08d77@oss.qualcomm.com/
Link: rust-lang/rust#144521 [1]
Link: rust-lang/rust#144523 [2]
Signed-off-by: Miguel Ojeda <ojeda@kernel.org>
jhpratt added a commit to jhpratt/rust that referenced this pull request Jul 27, 2025
…GuillaumeGomez

rustdoc: save target modifiers

`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()`.

Cc: `@azhogin`
Fixes: rust-lang#144521
bors added a commit that referenced this pull request Jul 27, 2025
Rollup of 7 pull requests

Successful merges:

 - #143289 (Remove `[T]::array_chunks(_mut)`)
 - #143607 (Port the proc macro attributes to the new attribute parsing infrastructure)
 - #144471 (Remove `compiler-builtins-{no-asm,mangled-names}`)
 - #144495 (bump cargo_metadata)
 - #144523 (rustdoc: save target modifiers)
 - #144534 (check_static_item: explain should_check_for_sync choices)
 - #144535 (miri: for ABI mismatch errors, say which argument is the problem)

Failed merges:

 - #144536 (miri subtree update)

r? `@ghost`
`@rustbot` modify labels: rollup
bors added a commit that referenced this pull request Jul 28, 2025
Rollup of 6 pull requests

Successful merges:

 - #143607 (Port the proc macro attributes to the new attribute parsing infrastructure)
 - #144471 (Remove `compiler-builtins-{no-asm,mangled-names}`)
 - #144495 (bump cargo_metadata)
 - #144523 (rustdoc: save target modifiers)
 - #144534 (check_static_item: explain should_check_for_sync choices)
 - #144535 (miri: for ABI mismatch errors, say which argument is the problem)

Failed merges:

 - #144536 (miri subtree update)

r? `@ghost`
`@rustbot` modify labels: rollup
@bors bors merged commit d776c5a into rust-lang:master Jul 28, 2025
10 checks passed
@rustbot rustbot added this to the 1.90.0 milestone Jul 28, 2025
rust-timer added a commit that referenced this pull request Jul 28, 2025
Rollup merge of #144523 - ojeda:rustdoc-target-modifiers, r=GuillaumeGomez

rustdoc: save target modifiers

`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()`.

Cc: ``@azhogin``
Fixes: #144521
@ojeda ojeda deleted the rustdoc-target-modifiers branch July 28, 2025 05:54
@ojeda
Copy link
Contributor Author

ojeda commented Jul 28, 2025

Thanks for the quick review!

RalfJung pushed a commit to RalfJung/miri that referenced this pull request Jul 28, 2025
Rollup of 6 pull requests

Successful merges:

 - rust-lang/rust#143607 (Port the proc macro attributes to the new attribute parsing infrastructure)
 - rust-lang/rust#144471 (Remove `compiler-builtins-{no-asm,mangled-names}`)
 - rust-lang/rust#144495 (bump cargo_metadata)
 - rust-lang/rust#144523 (rustdoc: save target modifiers)
 - rust-lang/rust#144534 (check_static_item: explain should_check_for_sync choices)
 - rust-lang/rust#144535 (miri: for ABI mismatch errors, say which argument is the problem)

Failed merges:

 - rust-lang/rust#144536 (miri subtree update)

r? `@ghost`
`@rustbot` modify labels: rollup
github-actions bot pushed a commit to model-checking/verify-rust-std that referenced this pull request Jul 30, 2025
…iaskrgr

Rollup of 6 pull requests

Successful merges:

 - rust-lang#143607 (Port the proc macro attributes to the new attribute parsing infrastructure)
 - rust-lang#144471 (Remove `compiler-builtins-{no-asm,mangled-names}`)
 - rust-lang#144495 (bump cargo_metadata)
 - rust-lang#144523 (rustdoc: save target modifiers)
 - rust-lang#144534 (check_static_item: explain should_check_for_sync choices)
 - rust-lang#144535 (miri: for ABI mismatch errors, say which argument is the problem)

Failed merges:

 - rust-lang#144536 (miri subtree update)

r? `@ghost`
`@rustbot` modify labels: rollup
github-actions bot pushed a commit to rust-lang/stdarch that referenced this pull request Jul 31, 2025
Rollup of 6 pull requests

Successful merges:

 - rust-lang/rust#143607 (Port the proc macro attributes to the new attribute parsing infrastructure)
 - rust-lang/rust#144471 (Remove `compiler-builtins-{no-asm,mangled-names}`)
 - rust-lang/rust#144495 (bump cargo_metadata)
 - rust-lang/rust#144523 (rustdoc: save target modifiers)
 - rust-lang/rust#144534 (check_static_item: explain should_check_for_sync choices)
 - rust-lang/rust#144535 (miri: for ABI mismatch errors, say which argument is the problem)

Failed merges:

 - rust-lang/rust#144536 (miri subtree update)

r? `@ghost`
`@rustbot` modify labels: rollup
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-run-make Area: port run-make Makefiles to rmake.rs S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. T-rustdoc Relevant to the rustdoc team, which will review and decide on the PR/issue.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

rustdoc cannot use dependencies with target modifiers
5 participants