v0.0.10 - Fix ARM64 static release build via buildx/QEMU and arch-aware nostr_core linking

This commit is contained in:
Laan Tungir
2026-05-04 05:57:46 -04:00
parent 1dd6630311
commit 28f50a750f
3 changed files with 51 additions and 24 deletions

View File

@@ -46,7 +46,10 @@ RUN cd /tmp && \
# Copy and build nostr_core_lib from project resources # Copy and build nostr_core_lib from project resources
COPY resources/nostr_core_lib /build/nostr_core_lib/ COPY resources/nostr_core_lib /build/nostr_core_lib/
RUN cd /build/nostr_core_lib && \ RUN if [ "$(uname -m)" = "aarch64" ] && ! command -v aarch64-linux-gnu-gcc >/dev/null 2>&1; then \
ln -s "$(command -v gcc)" /usr/local/bin/aarch64-linux-gnu-gcc; \
fi && \
cd /build/nostr_core_lib && \
chmod +x ./build.sh && \ chmod +x ./build.sh && \
./build.sh --nips=1,4,6,19,44 ./build.sh --nips=1,4,6,19,44
@@ -54,7 +57,14 @@ RUN cd /build/nostr_core_lib && \
COPY src/ /build/src/ COPY src/ /build/src/
# Build nsigner as a fully static binary # Build nsigner as a fully static binary
RUN gcc -static -Os -ffunction-sections -fdata-sections -Wl,--gc-sections -s -Wall -Wextra -std=c99 \ RUN ARCH="$(uname -m)"; \
case "$ARCH" in \
aarch64|arm64) NOSTR_LIB="/build/nostr_core_lib/libnostr_core_arm64.a" ;; \
x86_64|amd64) NOSTR_LIB="/build/nostr_core_lib/libnostr_core_x64.a" ;; \
*) echo "Unsupported build arch: $ARCH"; exit 1 ;; \
esac; \
[ -f "$NOSTR_LIB" ] || { echo "Missing nostr core lib: $NOSTR_LIB"; ls -la /build/nostr_core_lib; exit 1; }; \
gcc -static -Os -ffunction-sections -fdata-sections -Wl,--gc-sections -s -Wall -Wextra -std=c99 \
-I/build/nostr_core_lib \ -I/build/nostr_core_lib \
-I/build/nostr_core_lib/nostr_core \ -I/build/nostr_core_lib/nostr_core \
-I/build/nostr_core_lib/cjson \ -I/build/nostr_core_lib/cjson \
@@ -70,7 +80,7 @@ RUN gcc -static -Os -ffunction-sections -fdata-sections -Wl,--gc-sections -s -Wa
/build/src/transport_frame.c \ /build/src/transport_frame.c \
/build/src/key_store.c \ /build/src/key_store.c \
/build/src/socket_name.c \ /build/src/socket_name.c \
/build/nostr_core_lib/libnostr_core_x64.a \ "$NOSTR_LIB" \
-o /build/nsigner_static \ -o /build/nsigner_static \
$(pkg-config --static --libs libcurl openssl) \ $(pkg-config --static --libs libcurl openssl) \
-lsecp256k1 -lsqlite3 -lz -lpthread -lm -lsecp256k1 -lsqlite3 -lz -lpthread -lm

View File

@@ -105,12 +105,29 @@ echo "Platform: $PLATFORM"
echo "Output: $BUILD_DIR/$OUTPUT_NAME" echo "Output: $BUILD_DIR/$OUTPUT_NAME"
echo "" echo ""
if [ "$ARCH" != "$HOST_ARCH" ]; then
echo "[0/3] Preparing buildx + QEMU for cross-architecture build"
if ! docker buildx inspect >/dev/null 2>&1; then
echo "ERROR: docker buildx is not available"
exit 1
fi
docker run --privileged --rm tonistiigi/binfmt --install all >/dev/null
if ! docker buildx inspect nsigner-builder >/dev/null 2>&1; then
docker buildx create --name nsigner-builder --driver docker-container --use >/dev/null
else
docker buildx use nsigner-builder >/dev/null
fi
docker buildx inspect --bootstrap >/dev/null
fi
echo "[1/3] Building builder stage from project root context" echo "[1/3] Building builder stage from project root context"
docker build \ docker buildx build \
--platform "$PLATFORM" \ --platform "$PLATFORM" \
--target builder \ --target builder \
-f "$DOCKERFILE" \ -f "$DOCKERFILE" \
-t "$IMAGE_TAG" \ -t "$IMAGE_TAG" \
--load \
"$SCRIPT_DIR" "$SCRIPT_DIR"
echo "[2/3] Extracting static binary" echo "[2/3] Extracting static binary"

View File

@@ -451,8 +451,8 @@ int socket_name_random(char *out, size_t out_len);
/* Version information (auto-updated by build/version tooling) */ /* Version information (auto-updated by build/version tooling) */
#define NSIGNER_VERSION_MAJOR 0 #define NSIGNER_VERSION_MAJOR 0
#define NSIGNER_VERSION_MINOR 0 #define NSIGNER_VERSION_MINOR 0
#define NSIGNER_VERSION_PATCH 9 #define NSIGNER_VERSION_PATCH 10
#define NSIGNER_VERSION "v0.0.9" #define NSIGNER_VERSION "v0.0.10"
/* NSIGNER_HEADERLESS_DECLS_END */ /* NSIGNER_HEADERLESS_DECLS_END */