Skip to content
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

Regression build script output collision when using unstable target-applies-to-host and debug=0 #14394

Closed
erikjohnston opened this issue Aug 13, 2024 · 2 comments
Labels
C-bug Category: bug S-triage Status: This issue is waiting on initial triage. Z-target-applies-to-host Nightly: target-applies-to-host

Comments

@erikjohnston
Copy link

erikjohnston commented Aug 13, 2024

Problem

cargo check and co. fail to build the project with the error below. It does not fail with older nightlies.

thread '<unnamed>' panicked at src/cargo/core/compiler/custom_build.rs:1266:39:yn, anyhow(build), memchr                        
build script output collision for anyhow v1.0.86/4f7f6ef5a5e5df20
old=BuildOutput { library_paths: [], library_links: [], linker_args: [], cfgs: ["std_backtrace", "error_generic_member_access"], check_cfgs: ["cfg(anyhow_nightly_testing)", "cfg(anyhow_no_fmt_arguments_as_str)", "cfg(anyhow_no_ptr_addr_of)", "cfg(anyhow_no_unsafe_op_in_unsafe_fn_lint)", "cfg(doc_cfg)", "cfg(error_generic_member_access)", "cfg(std_backtrace)"], env: [], metadata: [], rerun_if_changed: ["build/probe.rs"], rerun_if_env_changed: [], warnings: [] }
new=BuildOutput { library_paths: [], library_links: [], linker_args: [], cfgs: ["std_backtrace", "error_generic_member_access"], check_cfgs: ["cfg(anyhow_nightly_testing)", "cfg(anyhow_no_fmt_arguments_as_str)", "cfg(anyhow_no_ptr_addr_of)", "cfg(anyhow_no_unsafe_op_in_unsafe_fn_lint)", "cfg(doc_cfg)", "cfg(error_generic_member_access)", "cfg(std_backtrace)"], env: [], metadata: [], rerun_if_changed: ["build/probe.rs"], rerun_if_env_changed: [], warnings: [] }
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
thread 'main' panicked at src/cargo/core/compiler/job_queue/mod.rs:971:64:
called `Result::unwrap()` on an `Err` value: PoisonError { .. }

Steps

  1. Checkout https://github.com/erikjohnston/cargo-regression-repro
  2. Use a nightly version (e.g. nightly 2024-08-09)
  3. Run cargo check

That is a minimum example, I ran into this error while trying to compile matrix-org/matrix-rust-sdk@5954ee1

Possible Solution(s)

No response

Notes

This regressed in toolchain nightly-2024-07-08, and rustc commit rust-lang/rust@20ae37c. This PR got pulled in, which touches target-applies-to-host: #13900, though I haven't actually checked it is that PR.

I don't really understand what target-applies-to-host is doing, so this may just be a silly combination of flags 🤷

Version

cargo 1.82.0-nightly (0d8d22f83 2024-08-08)
release: 1.82.0-nightly
commit-hash: 0d8d22f83b066503f6b2b755925197e959e58b4f
commit-date: 2024-08-08
host: x86_64-unknown-linux-gnu
libgit2: 1.8.1 (sys:0.19.0 vendored)
libcurl: 8.9.0-DEV (sys:0.4.74+curl-8.9.0 vendored ssl:OpenSSL/3.3.1)
ssl: OpenSSL 3.3.1 4 Jun 2024
os: Ubuntu 22.4.0 (jammy) [64-bit]
@erikjohnston erikjohnston added C-bug Category: bug S-triage Status: This issue is waiting on initial triage. labels Aug 13, 2024
@erikjohnston
Copy link
Author

Studying the build plans (generated via cargo +nightly build --build-plan -Z unstable-options) and diffing between a good and bad version, it appears that the anyhow build script gets run twice. It looks like the difference between the two build steps is CARGO_ENCODED_RUSTFLAGS.

It looks like in the bad plan the dependency tree is:

<crate> -> anyhow build -> anyhow run build script \
                                               anyhow build build script
prost-derive -> anyhow build -> anyhow run build script /

where the top has 'CARGO_ENCODED_RUSTFLAGS': '-Wrust_2018_idioms' set in the run build script, whereas the bottom has 'CARGO_ENCODED_RUSTFLAGS': '' set.

In the good plan both the crate and prost depend on the same anyhow build

The build plans:
good_output.json
bad_output.json

@erikjohnston erikjohnston changed the title Regression build script output collision when using target-applies-to-host and debug=0 Regression build script output collision when using unstable target-applies-to-host and debug=0 Aug 13, 2024
@weihanglo
Copy link
Member

Thanks for setting up the reproduction example!

I believe this is an identified regression in #14253. If you remove [profile.dev] debug = 0 it will all be gone.

Close in favor of that.

@weihanglo weihanglo closed this as not planned Won't fix, can't repro, duplicate, stale Aug 13, 2024
@weihanglo weihanglo added the Z-target-applies-to-host Nightly: target-applies-to-host label Aug 13, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C-bug Category: bug S-triage Status: This issue is waiting on initial triage. Z-target-applies-to-host Nightly: target-applies-to-host
Projects
None yet
Development

No branches or pull requests

2 participants