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

--emit=metadata,obj produces confusing error #76644

Closed
DusterTheFirst opened this issue Sep 11, 2020 · 3 comments
Closed

--emit=metadata,obj produces confusing error #76644

DusterTheFirst opened this issue Sep 11, 2020 · 3 comments
Labels
A-codegen Area: Code generation A-diagnostics Area: Messages for errors, warnings, and lints T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.

Comments

@DusterTheFirst
Copy link

EDIT ehuss:

With an empty file, foo.rs, the command rustc --emit=metadata,obj --crate-type=lib foo.rs returns a confusing error:

error: failed to build archive: No such file or directory

The error message should at least be a little clearer. I do not know why the combination of metadata+obj causes this error. obj by itself is fine, but for some reason adding metadata causes an error.


Original bug report below:

Original title: Cargo check fails to build the same package that cargo build can with an unhelpful error

Problem

When running cargo check on my project, it errors out with the following error
image
a very unhelpful, cryptic error. Running with verbose gives no more info than i can get from this screenshot alone.

I have been able to notice that it only happens when compiling for the target thumbv7em-none-eabihf and not my native target thumbv7em-none-eabihf

Steps
I have made a minimum example git repo
https://github.com/DusterTheFirst/cargo-check-bug-cfg-if

Possible Solution(s)

More descriptive errors than "No such file or directory" such as information about the file that is missing would help in solving the problem.

Notes
Output of cargo version:
cargo 1.48.0-nightly (875e01232 2020-09-08)
and
cargo 1.46.0 (149022b1d 2020-07-17)

rustup show

Default host: x86_64-unknown-linux-gnu
rustup home:  /home/dusterthefirst/.local/share/rustup

installed toolchains
--------------------

stable-x86_64-unknown-linux-gnu (default)
nightly-x86_64-unknown-linux-gnu

installed targets for active toolchain
--------------------------------------

thumbv7em-none-eabi
thumbv7em-none-eabihf
x86_64-unknown-linux-gnu

active toolchain
----------------

nightly-x86_64-unknown-linux-gnu (overridden by '/home/dusterthefirst/Documents/projects/rockets/avionics/viper/rust-toolchain')
rustc 1.48.0-nightly (a1947b3f9 2020-09-10)
@ehuss ehuss changed the title Cargo check fails to build the same package that cargo build can with an unhelpful error --emit=metadata,obj produces confusing error Sep 12, 2020
@ehuss ehuss transferred this issue from rust-lang/cargo Sep 12, 2020
@ehuss
Copy link
Contributor

ehuss commented Sep 12, 2020

Thanks for the detailed report! I have transferred this to rust-lang/rust, as the issue appears to originate in rustc.

This is caused by the --emit=obj in your config file. I'm uncertain why you have included that, though. Generally, I don't think that should be passed to every compiler invocation. But the compiler also probably shouldn't fail.

@jonas-schievink jonas-schievink added A-codegen Area: Code generation A-diagnostics Area: Messages for errors, warnings, and lints T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. labels Sep 12, 2020
@DusterTheFirst
Copy link
Author

DusterTheFirst commented Sep 12, 2020

the specific use case that I have is using the outputted obj file into a c compiler for embedded development. Namely compiling a rust binary and feeding it into platformio so that it can link to the arduino library

@ehuss
Copy link
Contributor

ehuss commented Jan 26, 2021

I believe this is now fixed via #81118.

@ehuss ehuss closed this as completed Jan 26, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-codegen Area: Code generation A-diagnostics Area: Messages for errors, warnings, and lints 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

3 participants