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

RUSTFLAGS=-Awarnings breaks Cargo for any target with an unsupported crate-type #132632

Closed
omarabid opened this issue Nov 5, 2024 · 5 comments
Closed
Labels
C-bug Category: This is a bug. T-cargo Relevant to the cargo team, which will review and decide on the PR/issue. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.

Comments

@omarabid
Copy link

omarabid commented Nov 5, 2024

cargo build --target wasm32-unknown-unknown

code compiles and warnings are shown.

export RUSTFLAGS="-Awarnings" 
cargo build --target wasm32-unknown-unknown

I expected to see this happen: compilation without warnings

Instead, this happened: compilation failed

Meta

❯ cargo build --target wasm32-unknown-unknown --release --lib
error: output of --print=file-names missing when learning about target-specific information from rustc
command was: `/home/archbox/.rustup/toolchains/1.81-x86_64-unknown-linux-gnu/bin/rustc - --crate-name ___ --print=file-names -Awarnings --target wasm32-unknown-unknown --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
___.wasm
lib___.rlib
___.wasm
lib___.a
/home/archbox/.rustup/toolchains/1.81-x86_64-unknown-linux-gnu
off
___
debug_assertions
panic="abort"
proc_macro
target_abi=""
target_arch="wasm32"
target_endian="little"
target_env=""
target_family="wasm"
target_feature="mutable-globals"
target_feature="sign-ext"
target_has_atomic="16"
target_has_atomic="32"
target_has_atomic="64"
target_has_atomic="8"
target_has_atomic="ptr"
target_os="unknown"
target_pointer_width="32"
target_vendor="unknown"

rustc --version --verbose:

1.81 stable

p.s.: cargo build compiles without warnings.

@omarabid omarabid added the C-bug Category: This is a bug. label Nov 5, 2024
@rustbot rustbot added the needs-triage This issue may need triage. Remove it if it has been sufficiently triaged. label Nov 5, 2024
@jieyouxu
Copy link
Member

jieyouxu commented Nov 5, 2024

Can you provide what's being compiled?

@rustbot label +S-needs-repro

@rustbot rustbot added the S-needs-repro Status: This issue has no reproduction and needs a reproduction to make progress. label Nov 5, 2024
@bjorn3
Copy link
Member

bjorn3 commented Nov 5, 2024

I think what happens is that -Awarnings suppresses the warning about the cdylib and dylib crate types not being supported on wasm32-unknown-unknown, which cargo needs to know about. This then results in the --print=file-names output missing entries for cdylib and dylib entirely rather than having entries that consist of warnings. As a result cargo fails to parse the output. The correct thing to do I think would be to make this warning suppressible when --print=file-names is passed.

@saethlin saethlin added T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. T-cargo Relevant to the cargo 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. S-needs-repro Status: This issue has no reproduction and needs a reproduction to make progress. labels Nov 5, 2024
@saethlin
Copy link
Member

saethlin commented Nov 5, 2024

Can you provide what's being compiled?

Any Cargo project can be used to reproduce this. I've run into this and debugged it to the same root cause as @bjorn3 points out.

I searched the community discord for missing when learning about target-specific information from rustc intending to find my previous debugging effort, and instead found 2 other people who've run into this situation.

The correct thing to do

I'd much prefer if Cargo wasn't relying on parsing rustc's warnings. I think Cargo is doing this because the output of its combination of --print options becomes ambiguous when there are unsupported crate-types. I don't know how we ended up with this strange --print behavior as the API that Cargo uses to get target-specific information, but the fact that this --print API is bad seems to me like the real problem here.

@saethlin saethlin changed the title Disabling Warnings for Wasm Target RUSTFLAGS=-Awarnings breaks Cargo for any target with an unsupported crate-type Nov 5, 2024
@weihanglo
Copy link
Member

Probably a dup of rust-lang/cargo#8010?

@saethlin
Copy link
Member

saethlin commented Nov 5, 2024

Hah, ehuss has already made the same assessment that I posted, but years ago. I agree this is a duplicate.

@saethlin saethlin closed this as not planned Won't fix, can't repro, duplicate, stale Nov 5, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C-bug Category: This is a bug. T-cargo Relevant to the cargo team, which will review and decide on the PR/issue. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.
Projects
None yet
Development

No branches or pull requests

6 participants