Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Lazy Sodium on an M1 mac is not able to load libsodium properly #110

Open
jmspring opened this issue Jul 7, 2021 · 13 comments
Open

Lazy Sodium on an M1 mac is not able to load libsodium properly #110

jmspring opened this issue Jul 7, 2021 · 13 comments

Comments

@jmspring
Copy link

jmspring commented Jul 7, 2021

When attempting to use lazysodium-java on an M1 mac (running MacOS Big Sur), the loading of the library within the jar file is resulting in the following error:

Exception in thread "main" java.lang.UnsatisfiedLinkError: Unable to load library '/var/folders/_d/ft54l_3j5d7c5kfm2xcqw4k40000gn/T/resource-loader8608426943801049570/armv6/libsodium.so':
dlopen(/var/folders/_d/ft54l_3j5d7c5kfm2xcqw4k40000gn/T/resource-loader8608426943801049570/armv6/libsodium.so, 9): no suitable image found.  Did find:
	/var/folders/_d/ft54l_3j5d7c5kfm2xcqw4k40000gn/T/resource-loader8608426943801049570/armv6/libsodium.so: unknown file type, first eight bytes: 0x7F 0x45 0x4C 0x46 0x01 0x01 0x01 0x00
	/var/folders/_d/ft54l_3j5d7c5kfm2xcqw4k40000gn/T/resource-loader8608426943801049570/armv6/libsodium.so: stat() failed with errno=17
dlopen(/var/folders/_d/ft54l_3j5d7c5kfm2xcqw4k40000gn/T/resource-loader8608426943801049570/armv6/libsodium.so, 9): no suitable image found.  Did find:
	/var/folders/_d/ft54l_3j5d7c5kfm2xcqw4k40000gn/T/resource-loader8608426943801049570/armv6/libsodium.so: unknown file type, first eight bytes: 0x7F 0x45 0x4C 0x46 0x01 0x01 0x01 0x00
	/var/folders/_d/ft54l_3j5d7c5kfm2xcqw4k40000gn/T/resource-loader8608426943801049570/armv6/libsodium.so: stat() failed with errno=17
dlopen(/var/folders/_d/ft54l_3j5d7c5kfm2xcqw4k40000gn/T/resource-loader8608426943801049570/armv6/libsodium.so.framework/libsodium.so, 9): image not found
Native library (var/folders/_d/ft54l_3j5d7c5kfm2xcqw4k40000gn/T/resource-loader8608426943801049570/armv6/libsodium.so) not found in resource path (data/apps/CoroConsensusService.jar)
	at com.sun.jna.NativeLibrary.loadLibrary(NativeLibrary.java:301)
	at com.sun.jna.NativeLibrary.getInstance(NativeLibrary.java:461)
	at com.sun.jna.Native.register(Native.java:1746)
	at com.goterl.resourceloader.SharedLibraryLoader.registerLibraryWithClasses(SharedLibraryLoader.java:81)
	at com.goterl.resourceloader.SharedLibraryLoader.load(SharedLibraryLoader.java:58)
	at com.goterl.lazysodium.utils.LibraryLoader.loadBundledLibrary(LibraryLoader.java:134)
	at com.goterl.lazysodium.utils.LibraryLoader.loadLibrary(LibraryLoader.java:95)
	at com.goterl.lazysodium.SodiumJava.<init>(SodiumJava.java:34)
	at com.goterl.lazysodium.SodiumJava.<init>(SodiumJava.java:23)

It looks like a recent checkin was made to handle that. Is there any chance of cutting a new release or patch that would work the the M1 mac?

@mikera
Copy link

mikera commented Jul 20, 2021

I think I am running into the same error. If it's of any use:

% sw_vers
ProductName:    macOS
ProductVersion: 11.4
BuildVersion:   20F71

@KevinRoebert
Copy link
Contributor

KevinRoebert commented Jul 25, 2021

@jmspring @mikera I've added M1 support with PR #107. It is also merged into the master branch. But we have to wait for the next release.

Could you checkout the master branch, compile the project (e.g. gradle install), and check if this works for you?

@KevinRoebert
Copy link
Contributor

@gurpreet- Could you release a new version, so Lazysodium will officially support M1?

@eleleung
Copy link

+1 for this. Would appreciate it as we have come across this issue using the library on an M1 mac.

@gurpreet-
Copy link
Contributor

Release 5.1.0 contains the new M1 enabled binary. Bonus: Libsodium has been upgraded to 1.0.18 too.

If any of you has an M1 mac could you please test this 5.1.0?

@mikera
Copy link

mikera commented Aug 2, 2021

Just upgraded to 5.1.0 and it seems to break on Windows, relevant error:

java.lang.UnsatisfiedLinkError: Unable to load library 'C:\Users\Mike\AppData\Local\Temp\resource-loader1351855501828376432\windows64\libsodium.dll':
The specified module could not be found.

The specified module could not be found.

Native library (win32-x86-64/C:\Users\Mike\AppData\Local\Temp\resource-loader1351855501828376432\windows64\libsodium.dll) not found in resource path ......

I can test on M1 later today if I can get the Windows version working!

@KevinRoebert
Copy link
Contributor

Just upgraded to 5.1.0 and it seems to break on Windows, relevant error

I can confirm, that e0c49d6 breaks the windows version.

@KevinRoebert
Copy link
Contributor

KevinRoebert commented Aug 2, 2021

Tested e0c49d6 on the following systems:

OS Arch Operational
MacOS Intel ✔️
MacOS ARM ✔️
Ubuntu Intel ✔️
Raspbian ARM ✔️
Win x64 Intel

Edit: I compiled the latest https://github.com/jedisct1/libsodium/tree/stable branch of libsodium on Windows 10 x64 myself. The dll unfortunately does not run under Lazysodium either. Is it possible that a new API or similar has been added?

@KevinRoebert
Copy link
Contributor

@gurpreet- Maybe #111 does fix the problem.

@gurpreet-
Copy link
Contributor

Hey @KevinRoebert, Libsodium does indeed publish its stable Windows binaries directly here https://download.libsodium.org/libsodium/releases/.

I have downloaded the binaries again and committed them into Lazysodium. Are you able to test either the latest master branch? Or you can test via the snapshot 5.1.1?

@KevinRoebert
Copy link
Contributor

Hey @KevinRoebert, Libsodium does indeed publish its stable Windows binaries directly here https://download.libsodium.org/libsodium/releases/.

I have downloaded the binaries again and committed them into Lazysodium. Are you able to test either the latest master branch? Or you can test via the snapshot 5.1.1?

The master branch does work under Windows 10 x64. But I would still suggest that the same library versions should be used for the tests and the actual wrapper. Otherwise, the tests will run, but the production code will not.

For this purpose, I have created the MR #112.

@gurpreet-
Copy link
Contributor

Thank you for the PR @KevinRoebert. I've merged it 😄

I've just released version 5.1.1. Everything should work in there.

@KevinRoebert
Copy link
Contributor

Thank you for the PR @KevinRoebert. I've merged it 😄

I've just released version 5.1.1. Everything should work in there.

Tested on the following systems:

OS Arch Operational
MacOS Intel ✔️
MacOS ARM ✔️
Ubuntu Intel ✔️
Raspbian ARM ✔️
Win x64 Intel ✔️

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants