Consensys / jblst

MIT License
8 stars 12 forks source link

Add support for Apple M1 arch #13

Closed Nashatyrev closed 2 years ago

Nashatyrev commented 3 years ago

Would be nice to add a build for arm64v8/libjblst.dylib for M1 powered MacOS

ajsutton commented 3 years ago

Agreed. CircleCI doesn't currently have M1 Macs available (or didn't last I checked). But we could probably cross compile - just not sure how to do that on a Mac.

ajsutton commented 3 years ago

@Nashatyrev Can you try the build from #15 (https://712-282229760-gh.circle-artifacts.com/0/build/libs/jblst-develop.jar) on an M1 Mac to see if it really does work please? file output suggests that it is in fact a multi-arch build but would be good to actually test it out.

I can confirm it works on an x86 Mac (I just replaced the existing jblst jar in a Teku distribution with this one and checked it still ran).

Note: Neither leveldb nor rocksdb are going to be supported on Mac/ARM yet though so teku won't get far, might need to write a bit of custom test code for jblst.

Nashatyrev commented 3 years ago

@ajsutton TBH, I have no M1 device an no one nearby has. I filed this issue just as a reminder. Just thought that performance of blst may significantly decrease in x86 emulation mode on M1 and the overall UX would be weird. Sorry if misled you regarding severity of this issue

ajsutton commented 3 years ago

Ah all good. I saw @garyschulte put up an issue for the besu native libs and stole his approach. Had to give up on it in actual work time when I hit a few bumps but it was too interesting to put down for long. :)

Hey @garyschulte - not urgent, but could you do me a favour and download https://712-282229760-gh.circle-artifacts.com/0/build/libs/jblst-develop.jar then create TestBlst.java in the same dir containing:

import supranational.blst.*;

public class TestBlst {

    public static void main(String[] args) {
        blstJNI.main(args);
        P2 p2 = new P2();
        System.out.println("Created a P2 successfully: " + p2);
    }
}

and run with:

javac -cp jblst-develop.jar TestBlst.java && java -cp .:jblst-develop.jar TestBlst

And let me know what it outputs on your M1 Mac please?