bevyengine / bevyengine/bevy

Dynamically linked Bevy (bevy_dylib) doesn't work in panic = "abort" programs

Open
#24,300 0 comments 0 reactions 0 assignees View on GitHub
A-Cross-Cutting C-Feature D-Complex I-Compile-Failure S-Needs-Investigation
Dominant language
Rust
Stars
48.2k
Forks
4.8k
Avg merge
3d 16h
Merged PRs (30d)
171

Description

## What problem does this solve or what need does it fill?

Currently it is not possible to compile with `panic = "abort"` and also dynamically link Bevy. It fails with

> ```
> Compiling bevy_dylib v0.18.1
> error: the linked panic runtime `panic_unwind` is not compiled with this crate's panic strategy `abort`
> ```

## What solution would you like?

Maybe some feature flag, or some other way to still use Bevy with dynamic linking (maybe through another crate `bevy_dylib_nounwind`? not sure about the details) on projects that set `panic = "abort"`.

## What alternative(s) have you considered?

Maybe locally patching Bevy to make it compile the dylib with `panic = "abort"` rather than `panic = "unwind"`? I'm currently investigating that

## Additional context

Aborting on panic makes the compiler have less work to perform and also makes binaries smaller. Not sure if this translates to meaningful gains on either compile time or `target/` dir size, but it should not harm anything (I don't want to run destructors on panic, panic hooks are sufficient).

Here I'm supposing that there is no part of Bevy that will not work without stack unwinding.

Contributor guide

Open the contributing guide

Research direction

Start by reproducing the panic-runtime error when compiling bevy_dylib in a project configured with panic = "abort". Inspect the bevy_dylib crate and compare it with the project's panic strategy; done means dynamically linking Bevy succeeds for panic-abort projects without the panic_unwind mismatch.

Written by the indexing model from the issue text.

Assessment

Tech stack
rust
Domain
build-system
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Quiet
Clarity
Mostly clear
Newbie friendliness
48/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.