rusqlite icon indicating copy to clipboard operation
rusqlite copied to clipboard

Segfault on cross compiling to musl

Open enaut opened this issue 3 years ago • 5 comments

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

enaut avatar Mar 08 '21 20:03 enaut

I confirm the problem. I have got the same.

avkonst avatar Mar 15 '21 02:03 avkonst

Im having same issue, but i'm using postgres instead of sqlite. I've not tried the workaround yet.

jbsiddall avatar Apr 13 '21 09:04 jbsiddall

I think this comes from a dynamic/static C runtime mismatch, but am not 100% certain.

thomcc avatar Jun 02 '21 22:06 thomcc

It may be helpful to automagically add the "bundled" feature when compiling for musl target - or a similar condition?

enaut avatar Jun 06 '21 16:06 enaut

Potentially related: https://github.com/tonarino/innernet/issues/228#issuecomment-1198990309

hellerbarde avatar Jul 30 '22 18:07 hellerbarde