diff --git a/.gitea/workflows/build-mips.yml b/.gitea/workflows/build-mips.yml index 124a14e..b8c427a 100644 --- a/.gitea/workflows/build-mips.yml +++ b/.gitea/workflows/build-mips.yml @@ -34,7 +34,9 @@ jobs: env: # Ensure we are building a fully static binary # -C link-self-contained=no: Let Zig (the linker) handle CRT objects (crt1.o, etc.) - RUSTFLAGS: "-C target-feature=+crt-static -C link-self-contained=no" + # --defsym=__atomic_is_lock_free=... Maps the missing symbol to our shim + RUSTFLAGS: "-C target-feature=+crt-static -C link-self-contained=no -C link-arg=-msoft-float -C link-arg=-Wl,--defsym=__atomic_is_lock_free=__atomic_is_lock_free_shim" + CFLAGS_mips_unknown_linux_musl: "-msoft-float" run: | cd backend cargo zigbuild --target mips-unknown-linux-musl --release -Z build-std=std,panic_abort diff --git a/docker/runner/Dockerfile b/docker/runner/Dockerfile index 4af3912..7272259 100644 --- a/docker/runner/Dockerfile +++ b/docker/runner/Dockerfile @@ -46,7 +46,22 @@ RUN ARCH=$(dpkg --print-architecture) && \ mv "zig-linux-$ZIG_ARCH-$ZIG_VER" /root/zig && \ rm zig.tar.xz -# 5. Install Tools (Trunk, cargo-zigbuild, wasm-bindgen protocol aligned) +# 5. Fix: Create libatomic.a shim for MIPS +# MIPS musl static build often misses __atomic_is_lock_free. +# We create a minimal implementation to satisfy the linker. +# We rename the function to avoid builtin conflict and alias it via linker flags later. +RUN . "$HOME/.cargo/env" && \ + echo '#include ' > atomic.c && \ + echo 'bool __atomic_is_lock_free_shim(unsigned int size, const volatile void *ptr) { return size <= 4; }' >> atomic.c && \ + /root/zig/zig cc -target mips-linux-musl -msoft-float -c -o atomic.o atomic.c && \ + /root/zig/zig ar rcs libatomic.a atomic.o && \ + RUST_SYSROOT=$(rustc --print sysroot) && \ + TARGET_LIB_DIR="$RUST_SYSROOT/lib/rustlib/mips-unknown-linux-musl/lib" && \ + mkdir -p "$TARGET_LIB_DIR" && \ + cp libatomic.a "$TARGET_LIB_DIR/" && \ + rm atomic.c atomic.o libatomic.a + +# 6. Install Tools (Trunk, cargo-zigbuild, wasm-bindgen protocol aligned) # We install trunk binary to save time, others via cargo RUN . "$HOME/.cargo/env" && \ # Install cargo-zigbuild