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 ERROR since beta 1.65 #102105

Closed
matthiaskrgr opened this issue Sep 21, 2022 · 2 comments
Closed

LLVM ERROR since beta 1.65 #102105

matthiaskrgr opened this issue Sep 21, 2022 · 2 comments
Labels
A-LLVM Area: Code generation parts specific to LLVM. Both correctness bugs and optimization-related issues. C-bug Category: This is a bug. F-rustc_attrs Internal rustc attributes gated on the `#[rustc_attrs]` feature gate. glacier ICE tracked in rust-lang/glacier. I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️ requires-nightly This issue requires a nightly compiler in some way. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.

Comments

@matthiaskrgr
Copy link
Member

Code

#![crate_type = "lib"]
#![feature(rustc_attrs)]

#[rustc_allocator]
pub fn allocator() -> *const i8 {
  std::ptr::null()
}

This code compiles fine with stable 1.63.0 (4b91a6ea7 2022-08-08) but with beta 1.65.0-beta.1 (2a65764f2 2022-09-19) or nightly, you get an llvm error:

Attribute after last parameter!
ptr @_ZN41_0c34bf1b914b0e835c46e4f7f73be047514103529allocator17h7fb349a1bdaf661aE
in function _ZN41_0c34bf1b914b0e835c46e4f7f73be047514103529allocator17h7fb349a1bdaf661aE
LLVM ERROR: Broken function found, compilation aborted!
@matthiaskrgr matthiaskrgr added I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️ T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. C-bug Category: This is a bug. labels Sep 21, 2022
@nikic
Copy link
Contributor

nikic commented Sep 21, 2022

This is because your allocator() method has an invalid signature. For correct signatures, see:

extern "Rust" {
// These are the magic symbols to call the global allocator. rustc generates
// them to call `__rg_alloc` etc. if there is a `#[global_allocator]` attribute
// (the code expanding that attribute macro generates those functions), or to call
// the default implementations in libstd (`__rdl_alloc` etc. in `library/std/src/alloc.rs`)
// otherwise.
// The rustc fork of LLVM 14 and earlier also special-cases these function names to be able to optimize them
// like `malloc`, `realloc`, and `free`, respectively.
#[rustc_allocator]
#[rustc_allocator_nounwind]
fn __rust_alloc(size: usize, align: usize) -> *mut u8;
#[rustc_deallocator]
#[rustc_allocator_nounwind]
fn __rust_dealloc(ptr: *mut u8, size: usize, align: usize);
#[rustc_reallocator]
#[rustc_allocator_nounwind]
fn __rust_realloc(ptr: *mut u8, old_size: usize, align: usize, new_size: usize) -> *mut u8;
#[rustc_allocator_zeroed]
#[rustc_allocator_nounwind]
fn __rust_alloc_zeroed(size: usize, align: usize) -> *mut u8;
}

At best, this is a diagnostics issue, if someone cares to improve diagnostics for an unstable, rustc-internal attribute.

@cuviper cuviper added the requires-nightly This issue requires a nightly compiler in some way. label Sep 22, 2022
@rust-lang-glacier-bot rust-lang-glacier-bot added the glacier ICE tracked in rust-lang/glacier. label Oct 1, 2022
@workingjubilee workingjubilee added the A-LLVM Area: Code generation parts specific to LLVM. Both correctness bugs and optimization-related issues. label Mar 4, 2023
@workingjubilee workingjubilee added the F-rustc_attrs Internal rustc attributes gated on the `#[rustc_attrs]` feature gate. label Mar 14, 2023
@Noratrieb
Copy link
Member

closing as wontfix

@Noratrieb Noratrieb closed this as not planned Won't fix, can't repro, duplicate, stale Aug 27, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-LLVM Area: Code generation parts specific to LLVM. Both correctness bugs and optimization-related issues. C-bug Category: This is a bug. F-rustc_attrs Internal rustc attributes gated on the `#[rustc_attrs]` feature gate. glacier ICE tracked in rust-lang/glacier. I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️ requires-nightly This issue requires a nightly compiler in some way. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.
Projects
None yet
Development

No branches or pull requests

6 participants