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

ICE: empty struct + extern function on 32-bit OS #16441

Closed
klutzy opened this issue Aug 12, 2014 · 2 comments · Fixed by #16484
Closed

ICE: empty struct + extern function on 32-bit OS #16441

klutzy opened this issue Aug 12, 2014 · 2 comments · Fixed by #16484
Labels
I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️ O-x86_32 Target: x86 processors, 32 bit (like i686-*)

Comments

@klutzy
Copy link
Contributor

klutzy commented Aug 12, 2014

#![crate_type = "lib"]
#![no_std]

struct Empty;
extern "C" fn ice(_a: Empty) {}

with --target=i686-unknown-linux-gnu or --target=i686-pc-mingw32:

task 'rustc' failed at 'assertion failed: index < LLVMCountParams(llfn)',
/path/to/rust/src/librustc_llvm/lib.rs:2041

stack backtrace:
   1:     0x7f0ae672fe70 - rt::backtrace::imp::write::h43dac5486f5e7461t9p
   2:     0x7f0ae6732f10 - failure::on_fail::h1e234ec252bd138bGuq
   3:     0x7f0ae6ef5a60 - unwind::begin_unwind_inner::h84cc9a0765812e46M8d
   4:     0x7f0ae6ef5750 - unwind::begin_unwind_fmt::h5294fb1154f645ceh6d
   5:     0x7f0ae3604670 - get_param::h6626c97fe8bc39e4rnc
   6:     0x7f0ae7698af0 - middle::trans::foreign::trans_rust_fn_with_foreign_abi::hc91c30d50c9f14e9nil
   7:     0x7f0ae7689820 - middle::trans::base::trans_item::h5d5ded2b8a3e87b4Fhd
   8:     0x7f0ae7755770 - middle::trans::base::trans_crate::h4ac87b78eadb9f067be
   9:     0x7f0ae7b6c440 - driver::driver::phase_4_translate_to_llvm::hacd93d74c4c452e1wCw
...

This causes #15811. (cc jeremyletang/rgtk#26)

@huonw huonw added the I-ICE label Aug 12, 2014
@luqmana luqmana added the A-x86 label Aug 12, 2014
@luqmana
Copy link
Member

luqmana commented Aug 12, 2014

The reason for this seems to be that we mark zero-sized structs as Ignore in middle::trans::cabi_x86 and thus when we create the foreign wrapper function it doesn't have as many arguments as we expected. Whereas with x86_64 we never mark any arguments as Ignore. I'm not sure as to whether we want to go one way or the other.

cc @dotdash any opinions on this?

@dotdash
Copy link
Contributor

dotdash commented Aug 13, 2014

I just checked with clang, and it always ignores empty structs (tried i686, x86_64, mips and arm targets), though it doesn't seem to affect the generated asm whether or not the argument is present, as long as it's passed as a direct argument (only tried on i686 and x86_64). The problem we had before, which was resolved by introducing the "Ignore" arg kind by @klutzy was that like all structs, the empty struct was passed as an indirect argument on x86. And that messed up the ffi since it used stack space.

It's a bit sad, since it complicates things, but I guess we should be doing the same as clang here and simply ignore empty structs. Maybe it can be done a bit easier if we make it so that it's not platform specific but done for all foreign functions?

@Nilstrieb Nilstrieb added O-x86_32 Target: x86 processors, 32 bit (like i686-*) and removed O-x86-all labels Oct 25, 2023
matthiaskrgr pushed a commit to matthiaskrgr/rust that referenced this issue Feb 5, 2024
…kril

feat: enable excluding refs search results in test

## Change

Here I introduce a new `ReferenceCategory::Test` type to indicate whether the function where this reference is located is marked as `#[test]`, and expose an config item (`rust-analyzer.references.excludeTests`) to client.

I also changed the signature of `ReferenceCategory::new`, adding a `sema: &Semantics<'_, RootDatabase>` param to do some hir analysis. Hope the current implementation is good to go.

## Demo

`"rust-analyzer.references.excludeTests": false`

![include](https://github.com/rust-lang/rust-analyzer/assets/71162630/9f1176d4-7b41-4f49-ac79-55d25a42d5d1)

`"rust-analyzer.references.excludeTests": true`

![exclude](https://github.com/rust-lang/rust-analyzer/assets/71162630/2938b44b-9e5b-48de-a049-453f5bbc09d0)

close rust-lang/rust-analyzer#14530
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️ O-x86_32 Target: x86 processors, 32 bit (like i686-*)
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants