rusqlite
rusqlite copied to clipboard
Segfault on cross compiling to musl
Setup
Versions
- Rust: x86_64-unknown-linux-musl
- Diesel: 1.4
- Database: SQLITE
Feature Flags
- diesel: features = ["sqlite"]
Problem Description
When cross compiling to x86_64-unknown-linux-musl
target diesel segfaults immediately in line: https://github.com/diesel-rs/diesel/blob/bec389a1ea329c161fc7a8fb8df8bea29a3432bf/diesel/src/sqlite/connection/raw.rs#L23
Workaround
In #musl IRC I was given the workaround to add:
libsqlite3-sys = { version = "*", features = ["bundled"] }
to Cargo.toml
solves this issue.
So somehow even when cross compiling the libsqlite3-sys is not bundled but dynamically linked which fails.
What are you trying to accomplish?
I want to use musl builds to have a standalone binary of my actix-web app.
Steps to reproduce
I created a minimal example: https://github.com/enaut/musl-segfault-sample
compile and run on linux with: cargo run --target x86_64-unknown-linux-musl
I confirm the problem. I have got the same.
Im having same issue, but i'm using postgres instead of sqlite. I've not tried the workaround yet.
I think this comes from a dynamic/static C runtime mismatch, but am not 100% certain.
It may be helpful to automagically add the "bundled" feature when compiling for musl target - or a similar condition?
Potentially related: https://github.com/tonarino/innernet/issues/228#issuecomment-1198990309