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

Using -Ztrim-paths with -Zbuild-std gives bad version numbers for standard library paths #117839

Closed
Nemo157 opened this issue Nov 12, 2023 · 2 comments · Fixed by rust-lang/cargo#13065
Labels
-Zbuild-std Unstable Cargo option: Compile the standard library yourself. C-bug Category: This is a bug. F-trim-paths Feature: trim-paths T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.

Comments

@Nemo157
Copy link
Member

Nemo157 commented Nov 12, 2023

I tried this code:

> cargo new foo && cd foo
     Created binary (application) `foo` package
> sed -i s/println/panic/ src/main.rs
> RUST_BACKTRACE=1 cargo run --release -Ztrim-paths -Zbuild-std --config=profile.release.debug='"line-tables-only"'
   Compiling foo v0.1.0 (/tmp/tmp.VBGvfipbYa/foo)
    Finished release [optimized + debuginfo] target(s) in 0.63s
     Running `/run/user/1000/cargo-home/target/shared/x86_64-unknown-linux-gnu/release/foo`
thread 'main' panicked at src/main.rs:2:5:
Hello, world!
stack backtrace:
   0: begin_panic_handler
             at std-0.0.0/src/panicking.rs:645:5
   1: panic_fmt
             at core-0.0.0/src/panicking.rs:72:14
   2: main
             at src/main.rs:2:5
   3: call_once<fn(), ()>
             at core-0.0.0/src/ops/function.rs:250:5
note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace.

I expected to see this happen: std/core version numbers matching rustc's version number

Instead, this happened: std/core have version number 0.0.0

This may be a cargo bug, but I assume it's just using the version numbers from the packaged Cargo.toml so would be fixed here.

Meta

rustc --version --verbose:

rustc 1.76.0-nightly (2c1b65ee1 2023-11-11)
binary: rustc
commit-hash: 2c1b65ee1431f8d3fe2142e821eb13c623bbf8a0
commit-date: 2023-11-11
host: x86_64-unknown-linux-gnu
release: 1.76.0-nightly
LLVM version: 17.0.4

cc #111540 (and I can't find a tracking issue for -Zbuild-std)

@Nemo157 Nemo157 added C-bug Category: This is a bug. -Zbuild-std Unstable Cargo option: Compile the standard library yourself. F-trim-paths Feature: trim-paths labels Nov 12, 2023
@rustbot rustbot added the needs-triage This issue may need triage. Remove it if it has been sufficiently triaged. label Nov 12, 2023
@Nemo157
Copy link
Member Author

Nemo157 commented Nov 12, 2023

Using -v I see it is actually trying to use the /rustc/<commit hash> path, but also adds the crate path overriding it:

--remap-path-prefix=[toolchain]/lib/rustlib/src/rust=/rustc/2c1b65ee1431f8d3fe2142e821eb13c623bbf8a0
--remap-path-prefix=[toolchain]/lib/rustlib/src/rust/library/core=core-0.0.0

If that path is preferred then this looks more like a cargo bug around flag order, cc @weihanglo you seem likely to have more context about the preferred result.

@saethlin saethlin added T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. and removed needs-triage This issue may need triage. Remove it if it has been sufficiently triaged. labels Nov 13, 2023
@weihanglo
Copy link
Member

Interactions with -Zbuild-std are out of scope of RFC 3127, but agree with that showing 0.0.0 doesn't make any sense. Just posted a PR for this rust-lang/cargo#13065

I expect the following remap is better and meet what people want?

thread 'main' panicked at src/main.rs:2:5:
Hello, world!
stack backtrace:
   0: begin_panic_handler
             at /rustc/49b3924bd4a34d3cf9c37b74120fba78d9712ab8/library/std/src/panicking.rs:645:5
   1: panic_fmt
             at /rustc/49b3924bd4a34d3cf9c37b74120fba78d9712ab8/library/core/src/panicking.rs:72:14
   2: main
             at src/main.rs:2:5
   3: call_once<fn(), ()>
             at /rustc/49b3924bd4a34d3cf9c37b74120fba78d9712ab8/library/core/src/ops/function.rs:250:5
note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
-Zbuild-std Unstable Cargo option: Compile the standard library yourself. C-bug Category: This is a bug. F-trim-paths Feature: trim-paths T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants