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

LLVM assertion: "stdcall" with return value on Android #24958

Closed
tamird opened this issue Apr 29, 2015 · 4 comments
Closed

LLVM assertion: "stdcall" with return value on Android #24958

tamird opened this issue Apr 29, 2015 · 4 comments
Labels
O-android Operating system: Android

Comments

@tamird
Copy link
Contributor

tamird commented Apr 29, 2015

main.rs:

#![crate_type="lib"]

pub extern "stdcall" fn sup(_: isize) -> isize {
    0
}

Triggers an LLVM assertion when targeting Android:

$ x86_64-apple-darwin/stage2/bin/rustc main.rs --target=arm-linux-androideabi
Unsupported calling convention
UNREACHABLE executed at /Users/tamird/src/rust/src/llvm/lib/Target/ARM/ARMISelLowering.cpp:1273!
Abort trap: 6
tamird added a commit to tamird/rust that referenced this issue Apr 29, 2015
The problem here is that this test doesn't even compile for Android.

See rust-lang#24958.
@steveklabnik steveklabnik added the O-android Operating system: Android label Apr 30, 2015
@nagisa
Copy link
Member

nagisa commented May 3, 2015

Something that works on any host (i.e. you needn’t compile libstd for android to repro):

#![feature(no_std,lang_items,fundamental)]
#![no_std]
#![crate_type="lib"]
#[lang="sized"]
#[fundamental]
pub trait Sized {}
#[lang="sync"]
pub unsafe trait Sync {}
#[lang="phantom_data"]
pub struct PhantomData<T:?Sized>;
#[lang="send"]
pub unsafe trait Send {}
#[lang="copy"]
pub trait Copy {}
#[lang="no_copy_bound"]
pub struct NoCopy;

pub extern "stdcall" fn sup(_: isize) -> isize {
    0
}

  * frame #0: 0x00007ffff71514b7 libc.so.6`__GI_raise + 55
    frame #1: 0x00007ffff715288a libc.so.6`__GI_abort + 362
    frame #2: 0x00007ffff34ff65c librustc_llvm-4e7c5e5c.so`llvm::llvm_unreachable_internal(char const*, char const*, unsigned int) + 156
    frame #3: 0x00007ffff284a62d librustc_llvm-4e7c5e5c.so`llvm::ARMTargetLowering::getEffectiveCallingConv(unsigned int, bool) const + 77
    frame #4: 0x00007ffff284a75b librustc_llvm-4e7c5e5c.so`llvm::ARMTargetLowering::CCAssignFnForNode(unsigned int, bool, bool) const + 11
    frame #5: 0x00007ffff284a8a4 librustc_llvm-4e7c5e5c.so`llvm::ARMTargetLowering::CanLowerReturn(unsigned int, llvm::MachineFunction&, bool, llvm::SmallVectorImpl<llvm::ISD::OutputArg> const&, llvm::LLVMContext&) const + 116
    frame #6: 0x00007ffff2b0953c librustc_llvm-4e7c5e5c.so`llvm::FunctionLoweringInfo::set(llvm::Function const&, llvm::MachineFunction&, llvm::SelectionDAG*) + 220
    frame #7: 0x00007ffff2c490a6 librustc_llvm-4e7c5e5c.so`llvm::SelectionDAGISel::runOnMachineFunction(llvm::MachineFunction&) + 534
    frame #8: 0x00007ffff283ee10 librustc_llvm-4e7c5e5c.so`(anonymous namespace)::ARMDAGToDAGISel::runOnMachineFunction(llvm::MachineFunction&) + 48
    frame #9: 0x00007ffff349477f librustc_llvm-4e7c5e5c.so`llvm::FPPassManager::runOnFunction(llvm::Function&) + 623
    frame #10: 0x00007ffff34947bb librustc_llvm-4e7c5e5c.so`llvm::FPPassManager::runOnModule(llvm::Module&) + 43
    frame #11: 0x00007ffff349437f librustc_llvm-4e7c5e5c.so`llvm::legacy::PassManagerImpl::run(llvm::Module&) + 815
    frame #12: 0x00007ffff232662e librustc_llvm-4e7c5e5c.so`LLVMRustWriteOutputFile(Target=0x00007fffe80356a0, PMR=0x00007fffe801b770, M=0x00007fffe8002d30, path=0x00007fffee8242b0, FileType=CGFT_ObjectFile) + 462 at PassWrapper.cpp:210
    frame #13: 0x00007ffff635844b librustc_trans-4e7c5e5c.so`back::write::write_output_file::h67e97df156a1fd13Rac + 187
    frame #14: 0x00007ffff635aea3 librustc_trans-4e7c5e5c.so`back::write::optimize_and_codegen::closure.40104 + 1315
    frame #15: 0x00007ffff6364dd4 librustc_trans-4e7c5e5c.so`back::write::execute_work_item::h565fc52094442fc5Y4c + 6372
    frame #16: 0x00007ffff635cb1d librustc_trans-4e7c5e5c.so`back::write::run_passes::h70fcfd6f6115b442KKc + 6925
    frame #17: 0x00007ffff7b003b8 librustc_driver-4e7c5e5c.so`driver::phase_5_run_llvm_passes::ha70ba0f00d6855749Oa + 328
    frame #18: 0x00007ffff7ad8849 librustc_driver-4e7c5e5c.so`driver::compile_input::h19dbb81f9d079a10Qba + 7849
    frame #19: 0x00007ffff7b90dc2 librustc_driver-4e7c5e5c.so`run_compiler::h6fdcc5ae4819da2c65b + 3826
    frame #20: 0x00007ffff7b8e613 librustc_driver-4e7c5e5c.so`boxed::F.FnBox$LT$A$GT$::call_box::h15867338134671801927 + 451
    frame #21: 0x00007ffff7b8dbda librustc_driver-4e7c5e5c.so`rt::unwind::try::try_fn::h10571205104630549427 + 74
    frame #22: 0x00007ffff76252f9 libstd-4e7c5e5c.so`rust_try_inner + 9
    frame #23: 0x00007ffff76252e6 libstd-4e7c5e5c.so`rust_try + 6
    frame #24: 0x00007ffff7b8de75 librustc_driver-4e7c5e5c.so`boxed::F.FnBox$LT$A$GT$::call_box::h11752498478748955554 + 405
    frame #25: 0x00007ffff75b07c2 libstd-4e7c5e5c.so`sys::thread::Thread::new::thread_start::h9f92b31902592327dAv + 146
    frame #26: 0x00007ffff1663374 libpthread.so.0`start_thread + 196
    frame #27: 0x00007ffff720627d libc.so.6`__clone + 109

@luqmana
Copy link
Member

luqmana commented May 3, 2015

As the error says, stdcall isn't a supported calling convention for the ARM target in LLVM. Not really much we can do from the rustc side unless we want to error early based on cc/target combinations. In any case, it should not crash.

@infinity0
Copy link
Contributor

I'm hitting this when I tried to run tests for 1.10.0 on arm64 (aarch64-unknown-linux-gnu). The build succeeds otherwise. I'm just adding ignore-arm and ignore-aarch64 to src/test/debuginfo/type-names.rs for the time being.

@Mark-Simulacrum
Copy link
Member

Neither example crashes today. Closing, since I don't see any good opportunity for a test here (it'd have to be something like only-arm and that's probably not worth it).

With arm-linux-androideabi (original example):

$ rustc +nightly --crate-type=lib test.rs --target=arm-linux-androideabi
error[E0570]: The ABI `"stdcall"` is not supported for the current target
 --> test.rs:1:1
  |
1 | / pub extern "stdcall" fn sup(_: isize) -> isize {
2 | |     0
3 | | }
  | |_^

error: aborting due to previous error

Updated @nagisa's example:

#![feature(no_core,lang_items,fundamental)]
#![no_core]
#[lang="sized"]
#[fundamental]
pub trait Sized {}
#[lang="sync"]
pub unsafe trait Sync {}
#[lang="phantom_data"]
pub struct PhantomData<T:?Sized>;
#[lang="send"]
pub unsafe trait Send {}
#[lang="copy"]
pub trait Copy {}

pub extern "stdcall" fn sup(_: isize) -> isize {
    0
}
$ rustc --crate-type=lib test.rs
// no output, compilation successful

ljedrz added a commit to ljedrz/rust-1 that referenced this issue Jul 18, 2018
kennytm added a commit to kennytm/rust that referenced this issue Jul 18, 2018
Cleanup rust-lang#24958

Since rust-lang#24958 was closed we might want to remove the workarounds it introduced for android, arm and aarch64.
bors added a commit that referenced this issue Jul 19, 2018
Rollup of 13 pull requests

Successful merges:

 - #51628 (use checked write in `LineWriter` example)
 - #52116 (Handle array manually in str case conversion methods)
 - #52218 (Amend option.take examples)
 - #52418 (Do not use desugared ident when suggesting adding a type)
 - #52439 (Revert some changes from #51917 to fix custom libdir)
 - #52455 (Fix doc comment: use `?` instead of `.unwrap()`)
 - #52458 (rustc: Fix a suggestion for the `proc_macro` feature)
 - #52464 (Allow clippy to be installed with make install)
 - #52472 (rustc: Enable `use_extern_macros` in 2018 edition)
 - #52477 (Clarify short-circuiting behvaior of Iterator::zip.)
 - #52480 (Cleanup #24958)
 - #52487 (Don't build twice the sanitizers on Linux)
 - #52510 (rustdoc: remove FIXME about macro redirects)

Failed merges:

r? @ghost
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
O-android Operating system: Android
Projects
None yet
Development

No branches or pull requests

6 participants