From 8804e243a4859b0e36f33d28c2751e128469289b Mon Sep 17 00:00:00 2001 From: Claude Date: Thu, 9 Apr 2026 23:09:17 +0000 Subject: [PATCH] fix: rewrite dylib install name on macOS so rpath resolution works The ACINQ secp256k1-kmp-jni dylib ships with a relative LC_ID_DYLIB ("build/darwin/libsecp256k1-jni.dylib"). macOS dyld resolves this literally, ignoring the -Wl,-rpath passed at link time, causing an immediate abort at launch. Using install_name_tool to rewrite the install name to @rpath/libsecp256k1-jni.dylib lets dyld find the library via the rpath we already set. https://claude.ai/code/session_01WSNE6QKiYM2ZutQD2UihCW --- quartz/benchmarks/run_all.sh | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/quartz/benchmarks/run_all.sh b/quartz/benchmarks/run_all.sh index f91cf4d59..322ba22bd 100755 --- a/quartz/benchmarks/run_all.sh +++ b/quartz/benchmarks/run_all.sh @@ -60,6 +60,14 @@ if [ -z "$SO_FILE" ]; then fi cp "$SO_FILE" "$WORK/" +# On macOS the dylib's LC_ID_DYLIB (install name) is a relative path like +# "build/darwin/libsecp256k1-jni.dylib". dyld resolves it literally, ignoring +# -rpath, so the binary fails at launch. Rewrite the install name to use +# @rpath so the -Wl,-rpath we pass to gcc actually works. +if [ "$OS_NAME" = "Darwin" ]; then + install_name_tool -id "@rpath/$SO_NAME" "$WORK/$SO_NAME" 2>/dev/null || true +fi + if ! gcc -O2 -o "$WORK/bench" "$BENCH_DIR/secp256k1_native_bench.c" \ -L"$WORK" -lsecp256k1-jni -Wl,-rpath,"$WORK" 2>&1; then echo "gcc compilation failed"