Description
When I upgraded my compiler to the most recent nightly, I found that my project no longer compiles. Instead, rustc panics, producing this error:
$ RUST_BACKTRACE=1 rustc --target i686-unknown-none-gnu -Z no-landing-pads -C no-redzone -C opt-level=1 -A dead_code -L . -L src rust/src/libcore/lib.rs
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
note: run with `RUST_BACKTRACE=1` for a backtrace
thread 'rustc' panicked at 'Field data-layout in target specification is required', ../src/librustc_back/target/mod.rs:370
stack backtrace:
1: 0x7f16d61a1d10 - std::sys::backtrace::tracing::imp::write::h9fb600083204ae7f
2: 0x7f16d61af58b - std::panicking::default_hook::_$u7b$$u7b$closure$u7d$$u7d$::hca543c34f11229ac
3: 0x7f16d61af12c - std::panicking::default_hook::hc2c969e7453d080c
4: 0x7f16d61748cf - std::sys_common::unwind::begin_unwind_inner::h30e12d15ce2b2e25
5: 0x7f16d61769b8 - std::sys_common::unwind::begin_unwind_fmt::hb2de8a9968d38523
6: 0x7f16d213b0ca - rustc_back::target::Target::from_json::h0865f3d0efe9d5a8
7: 0x7f16d213d2bf - rustc_back::target::Target::search::load_file::h10b754eb1c29e7bb
8: 0x7f16d213ca4a - rustc_back::target::Target::search::h5d24d442a2ed9dcf
9: 0x7f16d2a39e71 - rustc::session::config::build_target_config::h59bc6d485b6e9271
10: 0x7f16d2a37f6d - rustc::session::build_session_::h6f9ae75b9cc92e18
11: 0x7f16d2a365a3 - rustc::session::build_session_with_codemap::h0045b7130fdfbb5c
12: 0x7f16d66b0367 - rustc_driver::run_compiler::h8902aebf8b1849a8
13: 0x7f16d66ad7bd - std::sys_common::unwind::try::try_fn::h4c74456035d0fcc7
14: 0x7f16d619f4eb - __rust_try
15: 0x7f16d619f47d - std::sys_common::unwind::inner_try::h47a4d9cd4a369dcd
16: 0x7f16d66ae1ea - _<F as std..boxed..FnBox<A>>::call_box::h27f542a39f1d61ef
17: 0x7f16d61ad6f4 - std::sys::thread::Thread::new::thread_start::h6f266e069bf4ec2b
18: 0x7f16cdf226f9 - start_thread
19: 0x7f16d5e02b5c - clone
20: 0x0 - <unknown>
As the panic message indicates, the target I was supplying was missing the 'data-layout' field:
$ cat i686-unknown-none-gnu.json
{
"llvm-target": "i686-unknown-none-gnu",
"target-endian": "little",
"target-pointer-width": "32",
"os": "none",
"arch": "x86",
"target-env": "gnu",
"pre-link-args": [ "-m32" ],
"features": "-mmx,-sse,-sse2,-sse3,-ssse3,-sse4.1,-sse4.2,-3dnow,-3dnowa,-avx,-avx2",
"disable-redzone": true,
"eliminate-frame-pointer": true,
"linker-is-gnu": true,
"no-compiler-rt": true,
"archive-format": "gnu"
}
I added "data-layout": "e-m:e-p:32:32-f64:32:64-f80:32-n8:16:32-S128"
to the target, and everything builds once again. The requirement that this field be present apparently is caused by a change in LLVM, according to this issue: #31367. It looks like this was fixed for all of the targets rust uses internally by this change: #32939.
Since targets can be supplied by the user, as in the case above, panicking doesn't really seem warranted. Panicking implies there is a bug in the compiler, whereas the problem might be in the user's input. If the problem is in the user's input, it would be nice for the error to indicate this, to prevent confusion.
$ rustc --version --verbose
rustc 1.10.0-nightly (62e2b2fb7 2016-05-06)
binary: rustc
commit-hash: 62e2b2fb7acf5f8331781cd7128c754ed1b66c4f
commit-date: 2016-05-06
host: x86_64-unknown-linux-gnu
release: 1.10.0-nightly