Community
Participate
Working Groups
I have been developing with SWT 4.20 since it was released. My dev machine is an M1 Macbook, and I have been using Rosetta to run an x86_64 JVM and use all x86_64 native dependencies. Today, for the first time, I downloaded the `aarch64` build of SWT and tried to use that. At runtime, I got the error message `mach-o, but wrong architecture`. After some googling, I ran the following command: ``` user@machine> lipo ~/.swt/lib/macosx/aarch64/libswt-cocoa-4944r26.jnilib Non-fat file: /Users/user/.swt/lib/macosx/aarch64/libswt-cocoa-4944r26.jnilib is architecture: x86_64 ``` I backed-up the .swt directory (`mv ~/.swt ~/.swt-backup`) and then it worked. Now: ``` user@machine> lipo ~/.swt/lib/macosx/aarch64/libswt-cocoa-4944r26.jnilib Non-fat file: /Users/ntwigg/.swt/lib/macosx/aarch64/libswt-cocoa-4944r26.jnilib is architecture: arm64 ``` I think what's happening is that the SWT jar is unpacking itself based on the *native* architecture, rather than the *running* architecture. So if you run the x86_64 SWT jar under Rosetta on an M1 macbook, it will extract itself to the `aarch64` directory and now you can't use `aarch64` on that machine until you delete the `.swt` directory. Fwiw, one way to detect the native architecture is this: https://github.com/diffplug/durian-swt/blob/5ad2dbb8e980065baff53eb1399b62c6fb12a646/durian-swt.os/src/main/java/com/diffplug/common/swt/os/OS.java#L110-L116 As distinct from the running architecture: https://github.com/diffplug/durian-swt/blob/5ad2dbb8e980065baff53eb1399b62c6fb12a646/durian-swt.os/src/main/java/com/diffplug/common/swt/os/OS.java#L177-L178
(In reply to Ned Twigg from comment #0)`` > > I think what's happening is that the SWT jar is unpacking itself based on > the *native* architecture, rather than the *running* architecture. So if you > run the x86_64 SWT jar under Rosetta on an M1 macbook, it will extract > itself to the `aarch64` directory and now you can't use `aarch64` on that > machine until you delete the `.swt` directory. > SWT gets the running architecture and not the native architecture using System.getProperty("os.arch") similar to your example. Please see the code here --> https://git.eclipse.org/c/platform/eclipse.platform.swt.git/tree/bundles/org.eclipse.swt/Eclipse%20SWT%20PI/common/org/eclipse/swt/internal/Library.java#n67 So, running with a native aarch64 JVM is expected to return aarch64 and x86_64 JVM should return x86_64. Is it not working as expected? I don't have access to an arm64 machine now to verify the exact use case which is not working.
Works for me: We have verified this problem and it doesn't happen when correct JVM and SWT jar combination is used. Problem happens when there is a mis-match architecture of JRE and SWT used: for example when you are using aarch64 JRE with X86_64 SWT library combination, which causes this error. Closing this bug for now, can you please verify this your side ?
Thanks Ned for providing the machine for testing.