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

Empty enum breaks --target=asmjs-unknown-emscripten #46730

Closed
therustmonk opened this issue Dec 14, 2017 · 5 comments
Closed

Empty enum breaks --target=asmjs-unknown-emscripten #46730

therustmonk opened this issue Dec 14, 2017 · 5 comments
Labels
A-codegen Area: Code generation C-bug Category: This is a bug. I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️ O-asmjs Target: asm.js - http://asmjs.org/ O-emscripten Target: 50% off wasm32-unknown-musl. the savings come out of stdio.h, but hey, you get SDL!

Comments

@therustmonk
Copy link
Contributor

This code breaks compiler (when enum doesn't have any variant):

extern crate domafic;

use domafic::{DomNode, KeyIter};
use domafic::web_render::{run, JsIo};
use domafic::tags::*;

struct State { }

impl State {
    fn new() -> Self { State { } }
}

enum Msg {
    //RemoveItToGetCompilerFail,
}

fn main() {
    let update = |state: &mut State, msg: Msg, keys: KeyIter, _: &JsIo<Msg>| { };
    let render = |state: &State| {  div(())  };
    run("body", update, render, State::new());
}

https://github.com/DenisKolodin/emcc-fail/blob/master/src/main.rs#L17

error: internal compiler error: /checkout/src/librustc_trans/mir/block.rs:631: trans_argument: OperandRef(Immediate(({ %"domafic::web_render::private::JsIo<Msg>"*, {}* }:{ %"domafic::web_render::private::JsIo<Msg>"*, {}* } undef)) @ TyLayout { ty: &domafic::web_render::JsIo<Msg>, details: LayoutDetails { variants: Single { index: 0 }, fields: Arbitrary { offsets: [Size { raw: 0 }, Size { raw: 4 }], memory_index: [0, 1] }, abi: ScalarPair(Scalar { value: Pointer, valid_range: 1..=4294967295 }, Scalar { value: Pointer, valid_range: 1..=4294967295 }), align: Align { abi: 2, pref: 3 }, size: Size { raw: 8 } } }) invalid for pair arugment

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: rustc 1.24.0-nightly (f8af59d95 2017-12-13) running on x86_64-unknown-linux-gnu

note: run with `RUST_BACKTRACE=1` for a backtrace

thread 'rustc' panicked at 'Box<Any>', /checkout/src/librustc_errors/lib.rs:501:8
note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace.
stack backtrace:
   0: std::sys::unix::backtrace::tracing::imp::unwind_backtrace
             at /checkout/src/libstd/sys/unix/backtrace/tracing/gcc_s.rs:49
   1: std::sys_common::backtrace::print
             at /checkout/src/libstd/sys_common/backtrace.rs:68
             at /checkout/src/libstd/sys_common/backtrace.rs:57
   2: std::panicking::default_hook::{{closure}}
             at /checkout/src/libstd/panicking.rs:381
   3: std::panicking::default_hook
             at /checkout/src/libstd/panicking.rs:391
   4: std::panicking::rust_panic_with_hook
             at /checkout/src/libstd/panicking.rs:577
   5: std::panicking::begin_panic
   6: rustc_errors::Handler::bug
   7: <std::thread::local::LocalKey<T>>::with
   8: rustc::ty::context::tls::with_opt
   9: rustc::session::opt_span_bug_fmt
  10: rustc::session::bug_fmt
  11: rustc_trans::mir::block::<impl rustc_trans::mir::MirContext<'a, 'tcx>>::trans_argument
  12: rustc_trans::mir::block::<impl rustc_trans::mir::MirContext<'a, 'tcx>>::trans_terminator
  13: rustc_trans::mir::trans_mir
  14: rustc_trans::base::trans_instance
  15: rustc_trans::trans_item::TransItemExt::define
  16: rustc_trans::base::compile_codegen_unit
  17: rustc::ty::maps::<impl rustc::ty::maps::queries::compile_codegen_unit<'tcx>>::compute_result
  18: rustc::dep_graph::graph::DepGraph::with_task_impl
  19: rustc_errors::Handler::track_diagnostics
  20: rustc::ty::maps::plumbing::<impl rustc::ty::context::TyCtxt<'a, 'gcx, 'tcx>>::cycle_check
  21: rustc::ty::maps::<impl rustc::ty::maps::queries::compile_codegen_unit<'tcx>>::force
  22: rustc::ty::maps::<impl rustc::ty::maps::queries::compile_codegen_unit<'tcx>>::try_get
  23: rustc::ty::maps::TyCtxtAt::compile_codegen_unit
  24: rustc::ty::maps::<impl rustc::ty::context::TyCtxt<'a, 'tcx, 'lcx>>::compile_codegen_unit
  25: rustc_trans::base::trans_crate
  26: <rustc_trans::LlvmTransCrate as rustc_trans_utils::trans_crate::TransCrate>::trans_crate
  27: rustc::util::common::time
  28: rustc_driver::driver::phase_4_translate_to_llvm
  29: rustc_driver::driver::compile_input::{{closure}}
  30: <std::thread::local::LocalKey<T>>::with
  31: <std::thread::local::LocalKey<T>>::with
  32: rustc::ty::context::TyCtxt::create_and_enter
  33: rustc_driver::driver::compile_input
  34: rustc_driver::run_compiler

error: Could not compile `emcc-fail`.

I use:
latest nightly: rustc 1.24.0-nightly (f8af59d 2017-12-13) running on x86_64-unknown-linux-gnu
cargo web: cargo-web 0.3.4 (koute/cargo-web@2bd88e8)
Emscripten: system change: 1.37.21|/usr/bin|4.0 vs 1.37.21

@kennytm kennytm added A-codegen Area: Code generation I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️ O-asmjs Target: asm.js - http://asmjs.org/ C-bug Category: This is a bug. labels Dec 14, 2017
@glandium
Copy link
Contributor

glandium commented Mar 9, 2018

I got a similar crash while targetting x86-64 linux (not emscripten) in #48873, that went away after I filled my empty enums.

@lqd
Copy link
Member

lqd commented Apr 23, 2018

As @glandium mentions, this issue is not limited to asmjs, it also happens in another non-emscripten "duplicate" issue #50153.

@eddyb
Copy link
Member

eddyb commented Apr 26, 2018

This will hopefully go away when #49298 is fixed.

@tlively
Copy link
Contributor

tlively commented Jan 10, 2020

@alexcrichton It sounds like this was not an Emscripten-specific bug after all, so it should probably be closed, especially now that #49298 is closed.

@alexcrichton
Copy link
Member

👍

@workingjubilee workingjubilee added the O-emscripten Target: 50% off wasm32-unknown-musl. the savings come out of stdio.h, but hey, you get SDL! label Oct 11, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-codegen Area: Code generation C-bug Category: This is a bug. I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️ O-asmjs Target: asm.js - http://asmjs.org/ O-emscripten Target: 50% off wasm32-unknown-musl. the savings come out of stdio.h, but hey, you get SDL!
Projects
None yet
Development

No branches or pull requests

8 participants