Skip to content

Make rust_stack_exhausted a lang item #11922

Description

@brson

cc #9839. Right now if you don't link to the standard library you get a link error because __morestack expects a symbol called rust_stack_exhausted to exist.

Add a "stack_exhausted" lang item. For every compilation unit, if the lang item doesn't exist, emit the code

extern "rust-intrinsic" { fn abort() -> !; }

#[no_mangle] pub extern "C" fn __rust_stack_exhausted() {
    unsafe { abort() }
}

If it does exist, emit the same function, but call the lang item.

This would work in our current scheme where std defines what happens when the stack runs out, but not if we refactored std like #11828, so that the lowest levels of the crate hierarchy don't know the failure policy.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-runtimeArea: std's runtime and "pre-main" init for handling backtraces, unwinds, stack overflows

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions