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

error: internal compiler error: unexpected failure on resolving external static #13325

Closed
farcaller opened this issue Apr 4, 2014 · 9 comments
Labels
A-codegen Area: Code generation I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️

Comments

@farcaller
Copy link
Contributor

extern {
  static StackBase: *u32;
  fn main();
}

#[link_section=".isr_vector_temp"]
static ISRVectors: &'static [u32] = &'static [
  StackBase as u32,
  main as u32,
];

fails with the following backtrace:

task 'rustc' failed at 'expected item, found foreign item cortex_isr::StackBase::StackBase (id=5)', /private/tmp/rust-7IAC/src/libsyntax/ast_map.rs:256
stack backtrace:
   1:        0x1048ccce4 - rt::backtrace::imp::write::hd10102b8c011e5c0a8b::v0.11.pre
   2:        0x104830716 - rt::unwind::begin_unwind_inner::h2aba2baaa74b26e6EIb::v0.11.pre
   3:        0x10482f8b7 - rt::unwind::begin_unwind_fmt::h09a087409081b5ebOHb::v0.11.pre
   4:        0x10401cbc0 - ast_map::Map::expect_item::h33e65f1cbe4a9690f3v::v0.11.pre
   5:        0x102391110 - middle::check_const::CheckItemRecursionVisitor$LT$$x27a$GT$.Visitor$LT$$LP$$RP$$GT$::visit_expr::ha1037e3d217f65f58Av::v0.11.pre
   6:        0x102391488 - middle::check_const::CheckItemRecursionVisitor$LT$$x27a$GT$.Visitor$LT$$LP$$RP$$GT$::visit_expr::ha1037e3d217f65f58Av::v0.11.pre
   7:        0x102391303 - middle::check_const::CheckItemRecursionVisitor$LT$$x27a$GT$.Visitor$LT$$LP$$RP$$GT$::visit_expr::ha1037e3d217f65f58Av::v0.11.pre
   8:        0x102391294 - middle::check_const::CheckItemRecursionVisitor$LT$$x27a$GT$.Visitor$LT$$LP$$RP$$GT$::visit_expr::ha1037e3d217f65f58Av::v0.11.pre
   9:        0x10238ffc0 - middle::check_const::CheckItemRecursionVisitor$LT$$x27a$GT$.Visitor$LT$$LP$$RP$$GT$::visit_item::hb181d9d02abb2808dAv::v0.11.pre
  10:        0x10238ecbc - middle::check_const::check_item_recursion::h46ce87da219f30a8qzv::v0.11.pre
  11:        0x10238b156 - middle::check_const::check_item::h6a7ac223917469a2kpv::v0.11.pre
  12:        0x10238b841 - middle::check_const::check_item::h6a7ac223917469a2kpv::v0.11.pre
  13:        0x10238e2a1 - middle::check_const::check_crate::h2d887eb065573c56Gov::v0.11.pre
  14:        0x10237103f - util::common::time::h8a9a37f5ab167269hpg::v0.11.pre
  15:        0x1027810e2 - driver::driver::phase_3_run_analysis_passes::ha2daf3ece9edb1f1Ree::v0.11.pre
  16:        0x102787243 - driver::driver::compile_input::hf4855bb3e4401cfdODe::v0.11.pre
  17:        0x1027ab4ce - run_compiler::hc72c45483cbf8cefC5l::v0.11.pre
  18:        0x1027bf0fd - main_args::closure.91691
  19:        0x1027bd912 - monitor::closure.91576
  20:        0x1027b94bb - task::TaskBuilder::try::closure.91351
  21:        0x101f7d78c - task::spawn_opts::closure.7923
  22:        0x1048c8108 - rt::task::Task::run::closure.41788
  23:        0x1048d29fc - rust_try
  24:        0x1048c7f87 - rt::task::Task::run::h83564328e5810a07HB9::v0.11.pre
  25:        0x101f7d60f - task::spawn_opts::closure.7895
  26:        0x1048cb6c6 - rt::thread::thread_start::h66f4963f837dbe56oga::v0.11.pre
  27:     0x7fff8f91f899 - _pthread_body
  28:     0x7fff8f91f72a - _pthread_struct_init

Trying to port the following C code:

__attribute__ ((section(".isr_vector")))
void (* const isr_vector_table[])(void) = {
    &_stack_base,
    main,             // Reset
    ...
}
@alexcrichton
Copy link
Member

Likely related to #9867 and #9866

@huonw
Copy link
Member

huonw commented May 17, 2014

Shouldn't the port from the C be written like

extern {
  static StackBase: u32;
  fn main();
}

#[link_section=".isr_vector_temp"]
static ISRVectors: &'static [u32] = &'static [
  &StackBase as u32,
  main as u32,
];

Or is the external symbol actually a pointer itself?

@Twisol
Copy link

Twisol commented Jan 4, 2015

/cc @eddyb

@steveklabnik
Copy link
Member

I no longer get an ICE:

hello.rs:2:25: 2:26 error: bare raw pointers are no longer allowed, you should likely use `*mut T`, but otherwise `*T` is now known as `*const T`
hello.rs:2       static StackBase: *u32;
                                   ^
hello.rs:7:46: 7:47 error: expected `:`, found `[`
hello.rs:7 static ISRVectors: &'static [u32] = &'static [
                                                        ^

@eddyb
Copy link
Member

eddyb commented Jan 17, 2015

@steveklabnik you need to use *const u32 and remove the 'static in the expression - the syntax errors in the outdates testcase mask anything else.

@tamird
Copy link
Contributor

tamird commented Apr 21, 2015

@farcaller can you refresh your code above to today's syntax? I was not quite able to get the reported error.

@farcaller
Copy link
Contributor Author

The closest I managed to get is

extern {
  static StackBase: *const usize;
  fn main();
}

#[link_section=".isr_vector_temp"]
static ISRVectors: &'static [*const usize] = &[
  StackBase as *const usize,
  main as *const usize,
];

That fails with error: the trait core::marker::Syncis not implemented for the type*const usize``. I'm not sure I know how to fix it for modern rustc.

@steveklabnik
Copy link
Member

Okay, well, in that case, I'll just give this a close, as the ICE probably went away with the old syntax. If anyone can reproduce, let me know!

@eddyb
Copy link
Member

eddyb commented Apr 22, 2015

@farcaller make a wrapper for the pointer(s) and unsafe impl Sync for PtrWrapper {}.

flip1995 pushed a commit to flip1995/rust that referenced this issue Sep 5, 2024
…oc_fix, r=y21

Provide more clear example for `WRONG_SELF_CONVENTION`

Provide more clear example for `WRONG_SELF_CONVENTION`

changelog: none
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-codegen Area: Code generation I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️
Projects
None yet
Development

No branches or pull requests

7 participants