Skip to content

Commit

Permalink
fix platform detection logic on MacOS
Browse files Browse the repository at this point in the history
This was tested on an M1 MacBook; it reports the machine type as
``arm64``, not ``aarch64``. The full ``uname -a`` output is:

    Darwin <NAME-REDACTED>-MBP14.local 22.2.0 Darwin Kernel Version 22.2.0: Fri Nov 11 02:03:51 PST 2022; root:xnu-8792.61.2~4/RELEASE_ARM64_T6000 arm64

This diverges from what ``System.getProperty("os.arch")`` reports
as the architecture.

Signed-off-by: Philipp Gesang <[email protected]>
  • Loading branch information
phi-gamma committed Feb 10, 2023
1 parent c1db53b commit 56ef3dc
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
7 changes: 6 additions & 1 deletion BuildNative
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,11 @@ export DYNCALL_HOME=$BASE_DIR/dyncall

DYNCALL_DIFF=$BASE_DIR/src/main/cpp/bridj/dyncall.diff

function failed() {
echo "$@"
exit 1
}

if [[ ! -d "$DYNCALL_HOME" ]]
then
$BASE_DIR/admin/checkout_and_patch_dyncall.sh $DYNCALL_DIFF || failed "Failed to checkout and patch dyncall"
Expand Down Expand Up @@ -40,7 +45,7 @@ function get_arch() {
x86_64|amd64)
echo x64
;;
aarch64)
aarch64|arm64)
echo arm64
;;
arm*)
Expand Down
3 changes: 3 additions & 0 deletions src/main/java/org/bridj/Platform.java
Original file line number Diff line number Diff line change
Expand Up @@ -525,6 +525,9 @@ public static String getMachine() {
return "i386"; // we are running a 32 bits JVM on a 64 bits platform
}
}
if (isMacOSX() && arch.equals("aarch64")) {
return "arm64";
}
return arch;
}

Expand Down

0 comments on commit 56ef3dc

Please sign in to comment.