Skip to content

Commit 9e9786f

Browse files
fix(verify-kotlin-consumer): use hw.optional.arm64 for Rosetta-immune arch detect
sysctl -n hw.machine and uname -m both report the *process* arch, not the hardware — so on Apple Silicon under Rosetta, both return x86_64 and the script stages an x86_64 dylib that the native-arm64 JVM can't load (18 JNA tests fail). hw.optional.arm64 returns "1" on Apple Silicon hardware regardless of process arch, which is the actual question.
1 parent 9f76774 commit 9e9786f

1 file changed

Lines changed: 10 additions & 8 deletions

File tree

scripts/verify_kotlin_consumer.sh

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -13,16 +13,18 @@ set -eu
1313

1414
RES=kotlin/lib/src/main/resources
1515

16-
# Hardware arch — immune to Rosetta on macOS (where uname can lie and report
17-
# x86_64 even on an arm64 host whose JVM is the arm64 native build, leaving
18-
# JNA looking at darwin-aarch64/ while we'd've staged to darwin-x86-64/).
16+
# Hardware arch — must be immune to Rosetta on macOS so that an arm64 JVM
17+
# pointed at the staged dylib finds an arm64-built one, even when the shell
18+
# process is running under Rosetta (uname -m and sysctl -n hw.machine BOTH
19+
# report the process arch, not the hardware). hw.optional.arm64 returns "1"
20+
# on Apple Silicon regardless of process arch.
1921
case "$(uname -s)" in
2022
Darwin)
21-
case "$(sysctl -n hw.machine 2>/dev/null)" in
22-
arm64) PLAT=darwin-aarch64 ; CARGO_TARGET=aarch64-apple-darwin ;;
23-
x86_64) PLAT=darwin-x86-64 ; CARGO_TARGET=x86_64-apple-darwin ;;
24-
*) echo "ERROR: unsupported Darwin hw.machine=$(sysctl -n hw.machine)" >&2; exit 1 ;;
25-
esac
23+
if [ "$(sysctl -n hw.optional.arm64 2>/dev/null)" = "1" ]; then
24+
PLAT=darwin-aarch64 ; CARGO_TARGET=aarch64-apple-darwin
25+
else
26+
PLAT=darwin-x86-64 ; CARGO_TARGET=x86_64-apple-darwin
27+
fi
2628
LIB=libiroh_ffi.dylib
2729
;;
2830
Linux)

0 commit comments

Comments
 (0)