-
Notifications
You must be signed in to change notification settings - Fork 148
Open
Milestone
Description
Need to add mac aarch64 support.
I was able to build native multiarch library by "make osx" with changing
osx: export CFLAGS += -I$(JAVA_HOME)/include/darwin -arch x86_64
osx: export LDFLAGS := -arch x86_64 -dynamiclib -framework JavaVM -framework IOKit -framework CoreFoundation
to this:
osx: export CFLAGS += -I$(JAVA_HOME)/include/darwin -arch x86_64 -arch arm64
osx: export LDFLAGS := -arch x86_64 -arch arm64 -dynamiclib -framework IOKit -framework CoreFoundation
(also note removing JavaVM framework because it will cause error if official Apple Java 1.8 x86_64 is not installed)
So "file" utils shows next info:
% file build/resources/main/native/osx/libNRJavaSerial.jnilib
build/resources/main/native/osx/libNRJavaSerial.jnilib: Mach-O universal binary with 2 architectures: [x86_64:Mach-O 64-bit dynamically linked shared library x86_64] [arm64:Mach-O 64-bit dynamically linked shared library arm64]
build/resources/main/native/osx/libNRJavaSerial.jnilib (for architecture x86_64): Mach-O 64-bit dynamically linked shared library x86_64
build/resources/main/native/osx/libNRJavaSerial.jnilib (for architecture arm64): Mach-O 64-bit dynamically linked shared library arm64
But this is not usable on Apple Silicon by default because it's arm, and loader requires native library to be named "libNRJavaSerialv8" or "libNRJavaSerial_legacy" for loading.
Replacing
if(OSUtil.isARM()) {
to
if(OSUtil.isARM() && !OSUtil.isOSX()) {
in NativeResource.java:107 fixes the issue and the library work well natively on M1 mac.
Metadata
Metadata
Assignees
Labels
No labels