signalapp / libsignal

Home to the Signal Protocol as well as other cryptographic primitives which make Signal possible.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

[Feature Request] Enable static builds of `libsignal_jni`

m-ueberall opened this issue · comments

It would be nice to be able to create static binaries of applications that use libsignal_jni. For this to work, the library itself needs to be static:

# cargo build --target x86_64-unknown-linux-musl --release --verbose -p libsignal-jni
error: cannot produce cdylib for `libsignal-jni v0.26.0 (/build/libsignal/rust/bridge/jni)` as the target `x86_64-unknown-linux-musl` does not support these crate types

You're welcome to do so, and we'd probably take a patch to add a flag to build_jni.sh and the Makefile, but it's not a need Signal has ourselves, so we probably won't publish official artifacts. (I didn't realize there were statically-linked JVMs, either.)

Just found this one via AsamK/signal-cli#1453 ...

Just tried building with RUSTFLAGS="-C link-arg=-s -C target-feature=-crt-static" and it at least the buildchain completes....however i have not tested the artifact with musl graalvm native image though.

Running in docker using rust:alpine

apk add build-base ccache clang cmake g++ gcc git protobuf-dev clang-dev
export PATH="/usr/lib/ccache/bin/:$PATH"
export CCACHE_DIR="${CCACHE_DIR:-/tmp/ccache}"
export RUSTC_WRAPPER=/usr/bin/ccache
mkdir -p "$CCACHE_DIR"
export RUSTFLAGS="-C link-arg=-s -C target-feature=-crt-static"
git clone -b v0.40.1 https://github.com/signalapp/libsignal-client /tmp/libsignal-client
cd /tmp/libsignal-client
cargo build --release --verbose -p libsignal-jni

I've attached the final build asset if you want to try.

libsignal_jni.so.tgz

Hi,

just a heads-up here for the build artefact posted by @morph027.
It works as intended on an AMD64/OpenWRT/musl/zulu17.48.15-ca-jre17.0.10-linux_musl_x64/OpenHAB/Signal plugin environment.
As the Signal plugin author @dalgwen uses exquo/signal-libs-build I have asked there to include it to the list of platforms @exquo is providing binaries for.

Cheers!