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

error: output of --print=file-names missing when learning about target-specific information from rustc when --target is specified #1068

Open
zjp-CN opened this issue Jan 5, 2025 · 4 comments · May be fixed by #1071
Labels
C-bug Category: doesn't meet expectations

Comments

@zjp-CN
Copy link

zjp-CN commented Jan 5, 2025

Steps to reproduce the bug with the above code

Thanks for this great tool!

I see a bunch of these repos whos semver-checks results on non-host (x86_64-unknown-linux-gnu) targets report as the title shows.
One of the repos is https://github.com/arceos-org/arm_gicv2 . (I can list more if needed.)

Reproducible commands:

# latest hash: https://github.com/arceos-org/arm_gicv2/commit/cf756f7623b6b6af2f6fe423d1da19ebe96e7e1d
git clone https://github.com/arceos-org/arm_gicv2.git 
cd arm_gicv2
rustup target add aarch64-unknown-none-softfloat
cargo semver-checks --target aarch64-unknown-none-softfloat

Actual Behaviour

I got compilation error from rustc.

error: output of --print=file-names missing when learning about target-specific information from rustc
command was: `/root/.cargo/bin/sccache /root/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/bin/rustc - --crate-name ___ --print=file-names --cap-lints=allow --target aarch64-unknown-none-softfloat --crate-type bin --crate-type rlib --crate-type dylib --crate-type cdylib --crate-type staticlib --crate-type proc-macro --print=sysroot --print=split-debuginfo --print=crate-name --print=cfg`

--- stdout
___
lib___.rlib
lib___.a
/root/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu
off
___
debug_assertions
fmt_debug="full"
overflow_checks
panic="abort"
proc_macro
relocation_model="static"
target_abi="softfloat"
target_arch="aarch64"
target_endian="little"
target_env=""
target_has_atomic
target_has_atomic="128"
target_has_atomic="16"
target_has_atomic="32"
target_has_atomic="64"
target_has_atomic="8"
target_has_atomic="ptr"
target_has_atomic_equal_alignment="128"
target_has_atomic_equal_alignment="16"
target_has_atomic_equal_alignment="32"
target_has_atomic_equal_alignment="64"
target_has_atomic_equal_alignment="8"
target_has_atomic_equal_alignment="ptr"
target_has_atomic_load_store
target_has_atomic_load_store="128"
target_has_atomic_load_store="16"
target_has_atomic_load_store="32"
target_has_atomic_load_store="64"
target_has_atomic_load_store="8"
target_has_atomic_load_store="ptr"
target_os="none"
target_pointer_width="64"
target_vendor="unknown"
ub_checks


-----

error: failed to build rustdoc for crate arm_gicv2 v0.1.0
note: this is usually due to a compilation error in the crate,
      and is unlikely to be a bug in cargo-semver-checks
note: the following command can be used to reproduce the compilation error:
      cargo new --lib example &&
          cd example &&
          echo '[workspace]' >> Cargo.toml &&
          cargo add --path /rust/tmp/os-checker/repos/arm_gicv2 &&
          cargo check

error: aborting due to failure to build rustdoc for crate arm_gicv2 v0.1.0

I also run the suggested commands to reproduce the compilation error, and it compiles just fine.

Expected Behaviour

There should be no compilation errors.

Generated System Information

Software version

cargo-semver-checks 0.38.0 (507393d-modified)

Operating system

  • OS: Linux (Ubuntu 24.04)
  • Kernel: 6.8.0-51-generic

Command-line

/root/.cargo/bin/cargo-semver-checks semver-checks --bugreport

cargo version

> cargo -V
cargo 1.85.0-nightly (c86f4b3a1 2024-12-24)

Compile time information

  • Profile: release
  • Target triple: x86_64-unknown-linux-gnu
  • Family: unix
  • OS: linux
  • Architecture: x86_64
  • Pointer width: 64
  • Endian: little
  • CPU features: fxsr,sse,sse2,x87
  • Host: x86_64-unknown-linux-gnu

Cargo build configuration:

[build]
rustc-wrapper = "/root/.cargo/bin/sccache"

Build Configuration

None.

Additional Context

I think it might be a bug with RUSTFLAGS. When I look into the generated cargo doc command from semver-checks, it's like the following

export RUSTC_BOOTSTRAP=1
export RUSTDOCFLAGS="-Z unstable-options --document-private-items --document-hidden-items --output-format=json --cap-lints=allow"
export RUSTFLAGS=--cap-lints=allow
cargo doc --manifest-path target/semver-checks/local-arm_gicv2-0_1_0-01666ec060466c14/Cargo.toml --target-dir arm_gicv2/target/semver-checks/local-arm_gicv2-0_1_0-01666ec060466c14/target --package arm_gicv2@0.1.0 --lib --target aarch64-unknown-none-softfloat --no-deps --color=always

This just results in the exact same error report as above. (I'm not sure if the hash string in path is the same for your local testing.)

And when RUSTFLAGS=--cap-lints=allow is not included, it compiles and successfully generates the doc.

So I try removing RUSTFLAGS from run_cargo_doc fn, install it locally, and run cargo semver-checks --target aarch64-unknown-none-softfloat agian, semver-checks just works.

    Building arm_gicv2 v0.1.0 (current)
       Built [   0.733s] (current)
     Parsing arm_gicv2 v0.1.0 (current)
      Parsed [   0.002s] (current)
    Building arm_gicv2 v0.1.0 (baseline)
        Built [   0.558s] (baseline)
      Parsing arm_gicv2 v0.1.0 (baseline)
       Parsed [   0.002s] (baseline)
     Checking arm_gicv2 v0.1.0 -> v0.1.0 (no change)
      Checked [   0.020s] 120 checks: 120 pass, 0 skip
      Summary no semver update required
     Finished [   3.697s] arm_gicv2
@obi1kenobi
Copy link
Owner

Sorry for the delay, I was travelling and only just got home.

As far as I can tell, this is a bug upstream, likely in rustc or rustdoc 😮 --cap-lints=allow means "please don't error out on lints". It has no effect on the compiled code or anything related to the target, so specifying that flag should never cause code to not compile. What you've found is quite shocking to me!

Would you mind making a bug report issue in https://github.com/rust-lang/rust and linking it to this one?

If you'd prefer not to, I can also open the issue upstream. But since you already did all the work to narrow down the source of the bug, I didn't want to appear to take credit for your work by opening the upstream issue :)

@zjp-CN
Copy link
Author

zjp-CN commented Jan 8, 2025

😄 I'd like to open one on rust-lang repo. I'll try to make reproducible code that can be run without cargo-semver-checks.

@zjp-CN
Copy link
Author

zjp-CN commented Jan 8, 2025

I've submitted it: rust-lang/rust#135233

zjp-CN added a commit to os-checker/cargo-semver-checks that referenced this issue Jan 8, 2025
close obi1kenobi#1068

Cargo relies on warning diagnostics to find information,
--cap-lints=allow eliminates the warnings, so set the value to
warn level to keep it.
@zjp-CN zjp-CN linked a pull request Jan 8, 2025 that will close this issue
@weihanglo
Copy link

I believe rust-lang/cargo#15036 should fix this. It will get into the main rust-lang/rust repo on Friday, so expect to see it on nightly in the weekend!

zjp-CN added a commit to os-checker/cargo-semver-checks that referenced this issue Jan 10, 2025
Both testcases require `rustup target add x86_64-unknown-linux-gnu`.

But currently, cargo has a bug for learning target info:

command=`CARGO_BUILD_TARGET="aarch64-unknown-none" "/home/zjp/rust/cargo-semver-checks/target/debug/cargo-semver-checks" "semver-checks" "check-release" "--manifest-path=t
est_crates/template/new" "--baseline-root=test_crates/template/old"`
code=1
stdout=""
stderr=```
    Building template v0.1.0 (current)
error: running cargo-doc on crate \'template\' failed with output:
-----
error: output of --print=file-names missing when learning about target-specific information from rustc
command was: `/home/zjp/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/bin/rustc - --crate-name ___ --print=file-names --cap-lints=allow --target aarch64-unknown-none
 --crate-type bin --crate-type rlib --crate-type dylib --crate-type cdylib --crate-type staticlib --crate-type proc-macro --print=sysroot --print=split-debuginfo --print=c
rate-name --print=cfg`

--- stdout
___
lib___.rlib
lib___.a
/home/zjp/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu
off
___
debug_assertions
fmt_debug=\"full\"
overflow_checks
panic=\"abort\"
proc_macro
relocation_model=\"static\"
target_abi=\"\"
target_arch=\"aarch64\"
target_endian=\"little\"
target_env=\"\"
target_feature=\"neon\"
target_has_atomic
target_has_atomic=\"128\"
target_has_atomic=\"16\"
target_has_atomic=\"32\"
target_has_atomic=\"64\"
target_has_atomic=\"8\"
target_has_atomic=\"ptr\"
target_has_atomic_equal_alignment=\"128\"
target_has_atomic_equal_alignment=\"16\"
target_has_atomic_equal_alignment=\"32\"
target_has_atomic_equal_alignment=\"64\"
target_has_atomic_equal_alignment=\"8\"
target_has_atomic_equal_alignment=\"ptr\"
target_has_atomic_load_store
target_has_atomic_load_store=\"128\"
target_has_atomic_load_store=\"16\"
target_has_atomic_load_store=\"32\"
target_has_atomic_load_store=\"64\"
target_has_atomic_load_store=\"8\"
target_has_atomic_load_store=\"ptr\"
target_os=\"none\"
target_pointer_width=\"64\"
target_vendor=\"unknown\"
ub_checks

Hopefully, the fix from cargo will land in weekend.
Ref obi1kenobi#1068 (comment)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C-bug Category: doesn't meet expectations
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants