Skip to content

Commit e83b13b

Browse files
committed
libsql: fix musl builds failing due to fcntl64
This fixes a build issue with musl based systems that do not have fcntl64 in their libc. This is done by setting `FILE_OFFSET_BITS=32` only for musl targets. This forces the compiler to not convert `fcntl` to `fcntl64`.
1 parent c204f8e commit e83b13b

2 files changed

Lines changed: 19 additions & 2 deletions

File tree

Dockerfile.musl

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
# A dockerfile that can be used to build musl targets
2+
# currently this is setup to run the most basic libsql example
3+
# to force the linker to resolve. This was able to reproduce the
4+
# fcntl64 issues + other issues that require custom flags for musl.
5+
6+
FROM messense/rust-musl-cross:x86_64-musl
7+
RUN rustup target add x86_64-unknown-linux-musl
8+
9+
COPY . .
10+
11+
RUN rm rust-toolchain.toml
12+
13+
ENV LIBSQL_DEV=1
14+
15+
RUN apt-get install -y cmake
16+
17+
RUN cargo run -p libsql --example example --features encryption

libsql-ffi/build.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -349,8 +349,8 @@ fn build_multiple_ciphers(target: &str, out_path: &Path) {
349349
cmake_opts.push("-DCMAKE_POSITION_INDEPENDENT_CODE=ON");
350350

351351
if target.contains("musl") {
352-
cmake_opts.push("-DCMAKE_C_FLAGS=\"-U_FORTIFY_SOURCE\"");
353-
cmake_opts.push("-DCMAKE_CXX_FLAGS=\"-U_FORTIFY_SOURCE\"");
352+
cmake_opts.push("-DCMAKE_C_FLAGS=\"-U_FORTIFY_SOURCE\" -D_FILE_OFFSET_BITS=32");
353+
cmake_opts.push("-DCMAKE_CXX_FLAGS=\"-U_FORTIFY_SOURCE\" -D_FILE_OFFSET_BITS=32");
354354
}
355355

356356
let mut cmake = Command::new("cmake");

0 commit comments

Comments
 (0)