nip/BUILD_BLOCKER.md

2.4 KiB

Critical Blocker: ARM64 NIP Static Build

Root Cause Analysis

The nim c command compiles all source files to ARM64 object files successfully, but the final link step is silently failing.

Evidence:

  1. All .c.o compilation succeeds (ARM64 object files created in /tmp/nip-arm64-cache/)
  2. Linker command executes but lacks -o flag specifying output path
  3. Build returns exit code 0 (success) but no binary produced
  4. -o:build/arm64/nip argument to nim c is being ignored or not passed to linker

Linker Command (from diagnostic output):

aarch64-linux-gnu-gcc [hundreds of .o files] \
  -pthread -lm -lrt \
  -L/path/to/zstd-1.5.5/lib \
  -L/path/to/libressl-3.8.2/ssl/.libs \
  -L/path/to/libressl-3.8.2/crypto/.libs \
  -L/path/to/libressl-3.8.2/tls/.libs \
  -static -lssl -lcrypto -ltls -lzstd -lpthread -ldl -lm -lresolv \
  -Wl,-O1 -Wl,--sort-common -Wl,--as-needed -Wl,-z,relro -Wl,-z,now -Wl,-z,pack-relative-relocs

MISSING: -o /path/to/output/binary

Attempted Solutions

  1. Built LibreSSL 3.8.2 static (16MB crypto + 3.5MB ssl + 550KB tls) for ARM64
  2. Built Zstd 1.5.5 static (1.2MB) for ARM64
  3. Created GCC wrapper to filter x86 flags (-mpclmul, etc.)
  4. Used --dynlibOverride:ssl --dynlibOverride:crypto to prevent dlopen()
  5. Multiple output path specifications (-o:, --out:) all ignored
  6. Force rebuild with -f - still no output
  7. Absolute paths - still no output

Hypothesis

Nim's ARM64 cross-compilation may have a bug where the -o flag isn't being passed through to the final linker invocation when using --gcc.linkerexe:aarch64-linux-gnu-gcc.

Option A: Manual Link (Immediate)

  1. Use the object files already compiled in /tmp/nip-arm64-cache/
  2. Manually invoke aarch64-linux-gnu-gcc with proper -o flag
  3. Create binary directly

Option B: Different Nim Output Strategy

  1. Try --compileOnly to generate C code
  2. Use custom Makefile for linking phase
  3. Bypass Nim's linker invocation entirely

Option C: Investigate Nim Bug

  1. Check if this is a known Nim cross-compilation issue
  2. Try older/newer Nim version
  3. Report bug to Nim if not known

Current Time Impact: ~3 hours spent debugging LibreSSL/Zstd static linking - successfully resolved. ~1 hour on output path issue - unresolved.