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

Misleading error caused by incorrect target specification #34806

Closed
whitequark opened this issue Jul 13, 2016 · 9 comments
Closed

Misleading error caused by incorrect target specification #34806

whitequark opened this issue Jul 13, 2016 · 9 comments

Comments

@whitequark
Copy link
Member

Using rustc 1.10.0-dev (cfcb716 2016-07-03), and the following specification (it's incomplete, but that's irrelevant):

{
  "llvm-target": "or1k-unknown-none",
  "target-endian": "little",
  "target-pointer-width": 32
}

This is the error I get:

error: internal compiler error: unexpected panic
note: the compiler unexpectedly panicked. this is a bug.
note: we would appreciate a bug report: https://github.com/rust-lang/rust/blob/master/CONTRIBUTING.md#bug-reports
thread 'rustc' panicked at 'Field target-pointer-width in target specification is required', ../src/librustc_back/target/mod.rs:377
note: Run with `RUST_BACKTRACE=1` for a backtrace.

It's an ICE, which is a bit more scary than it ought to be, but that's fine. What's not fine is that it says there's no target-pointer-width but really what it doesn't like is that the value is not a string. Took me a while.

@cardoe
Copy link
Contributor

cardoe commented Jul 27, 2016

This should likely improve with #34980.

@cardoe
Copy link
Contributor

cardoe commented Nov 29, 2016

With #34980 (which is part of Rust 1.12.0) the error becomes:

$ rustc --target test.json
error: Error loading target specification: Field target-pointer-width in target specification is required
  |
  = help: Use `--print target-list` for a list of built-in targets

While its still not reporting that the field is present but of the wrong type I'm not sure if there's anything we can do to improve this while the compiler still uses rustc-serialize for its JSON handling.

@whitequark
Copy link
Member Author

That's not really much better, as per my original report.

@cardoe
Copy link
Contributor

cardoe commented Nov 29, 2016

Its at least not an ICE but instead a message saying it was unable to load the target specification. But like I said, you're correct that its incorrectly reporting the field missing when the actual issue is the data type is wrong.

@whitequark
Copy link
Member Author

I have lost over a hour again due to this issue, now because "min-atomic-width": "32" is not valid and is silently ignored, whereas "min-atomic-width": 32 is valid. This is notwithstanding that "target-pointer-width": "32" is still the correct form. Consistency, who needs it?

@cardoe
Copy link
Contributor

cardoe commented Jan 3, 2017

I recommend round tripping your config through --print target-spec-json. See #38338 for when its going to be available in stable.

@cardoe
Copy link
Contributor

cardoe commented Jan 3, 2017

Worth noting that you currently have to do this on the nightly and append -Z unstable-options to the command line.

@japaric
Copy link
Member

japaric commented Jan 3, 2017

@whitequark Had a similar experience recently. I was wondering why this:

"pre-link-args": "-nostartfiles",

was not passing that argument to the linker. Turns out that the value has to be an array ...

The compiler should at least be printing warnings about this instead of simply ignoring the invalid values.

@Mark-Simulacrum
Copy link
Member

Closing in favor of #24384.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants