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

WIP: Graal native-image build of Java Schnorr Example #29

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

msgilligan
Copy link
Member

@msgilligan msgilligan commented Mar 20, 2024

To build native image use:

./gradlew secp256k1-examples-java:nativeCompile

Build currently fails on macOS with:

Error: Support for the Foreign Function and Memory API is currently available only on the AMD64 architecture

Note: the implementation of FF&M (Panama) in native-image is incomplete. See: oracle/graal#8113

@msgilligan
Copy link
Member Author

msgilligan commented Mar 20, 2024

It also looks like some additional build configuration will be required:
https://github.com/oracle/graal/blob/master/docs/reference-manual/native-image/ForeignInterface.md

Update: The PR now includes this work (a somewhat rushed job of it, I must admit) but should build and run on AMD64 machines.

@schildbach
Copy link
Member

As already mentioned elsewhere, I was able to build and run this successfully:

$ LD_LIBRARY_PATH=/nix/store/1c403w3lffz5p21lqqcvryh56ib0i28q-secp256k1-0.4.1/lib time -v secp256k1-examples-java/build/schnorrRunning secp256k1-jdk Schnorr example...
Is the signature valid? true
Secret Key: c6bf161b6530f588451b3790140722eb6de756164efc49baa1387f16b9089dac
Public Key (as ECPoint): 70176dcf4283032d089003785fce826ed7fa8e58c6a6a82ac27db4378d46ce50
Signature: 7ec2637314505842493670018a2e9b67ac0f63faf207640da4c206c2b2e89dcdaf0349608d40bec4c9f18ea2028eee70defd2e5bae1b7cada886ae88cfa7badd
	Command being timed: "secp256k1-examples-java/build/schnorr"
	User time (seconds): 0.00
	System time (seconds): 0.00
	Percent of CPU this job got: 100%
	Elapsed (wall clock) time (h:mm:ss or m:ss): 0:00.00
	Average shared text size (kbytes): 0
	Average unshared data size (kbytes): 0
	Average stack size (kbytes): 0
	Average total size (kbytes): 0
	Maximum resident set size (kbytes): 19520
	Average resident set size (kbytes): 0
	Major (requiring I/O) page faults: 0
	Minor (reclaiming a frame) page faults: 1225
	Voluntary context switches: 12
	Involuntary context switches: 1
	Swaps: 0
	File system inputs: 0
	File system outputs: 0
	Socket messages sent: 0
	Socket messages received: 0
	Signals delivered: 0
	Page size (bytes): 4096
	Exit status: 0

To build native image use:

./gradlew secp256k1-examples-java:nativeCompile

Build currently fails on macOS with:

Error: Support for the Foreign Function and Memory API is currently available only on the AMD64 architecture

Note: the Arena.ofConfined() change should probably not be merged to `master`,
but is currently necessary to work with native-image.
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

Successfully merging this pull request may close these issues.

2 participants