Skip to content

alloc_error_handler does not link using stable rust #148916

@miladfarca

Description

@miladfarca

Hello,
We maintain Node.js runtime and the Chromium V8 JS engine on IBM platforms. V8 has introduced Rust as a dependency in order to support Temporal. Unlike Chromium upstream we do not use nightly versions of Rust and can only rely on stable builds of rustc. So far we have been using version 1.84 and these alloc handlers have been compiling fine for us:
https://chromium.googlesource.com/chromium/src/build/+/refs/heads/main/rust/allocator/lib.rs#111

But since version 1.88 we get these link errors:

ld.lld: error: undefined symbol: __rustc::__rust_alloc_error_handler_should_panic
ld.lld: error: undefined symbol: __rustc::__rust_alloc_error_handler

I'm assuming they are related to this change: #127173
I have tried exporting the symbols it's complaining about as such but it still can't find them:

#[export_name = "__rustc::__rust_alloc_error_handler_should_panic"]
pub extern "C" fn __rust_alloc_error_handler_should_panic() -> u8 {
    oom_should_panic_impl()
}

#[export_name = "__rustc::__rust_alloc_error_handler"]
pub extern "C" fn __rust_alloc_error_handler(_size: usize, _align: usize) {
    unsafe { ffi::alloc_error_handler_impl() }
}

I know the proper way is to use #[rustc_std_internal_symbol] but that's not available in stable rust versions.

Is this a bug? Is there no way we can fix this with stable Rust? I have seen similar issues being reported upstream, i.e bazelbuild/rules_rust#3459

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-linkageArea: linking into static, shared libraries and binariesC-discussionCategory: Discussion or questions that doesn't represent real issues.needs-triageThis issue may need triage. Remove it if it has been sufficiently triaged.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions