herumi / mcl

a portable and fast pairing-based cryptography library
BSD 3-Clause "New" or "Revised" License
450 stars 152 forks source link

How to enable ASM on cross compile binaries #102

Closed mxaddict closed 3 years ago

mxaddict commented 3 years ago

We are building with MCL using a cross compile build on a x86_64 linux host

We get some compile errors when enabling ASM support on anything other than the native system build

Do you happen to know what we would need to change to support ASM on osx, arm, aarch, windows (mingw) builds from a linux host build?

herumi commented 3 years ago

I can get the arm64 binary of bin/bn_test.exe as the following steps:

Install

make src/gen # src/gen is for host program
make bin/bn_test.exe PRE=aarch64-linux-gnu- CC=gcc-10 CXX=g++-10 ARCH=aarch64 UPDATE_ASM=1 LLVM_VER=-11 MCL_USE_GMP=0
herumi commented 3 years ago

I think that you can get arm binary like that, but macOS is necessary to build osx. I don't test asm for windows binary. Xbyak version is faster than x64-86 asm for recent CPU.

aguycalled commented 3 years ago

is xbyak faster than asm for every os or only windows? what is the faster for each os?

herumi commented 3 years ago

The xbyak version is faster on all x86-64 OS. mcl uses

If you can use clang for cross-compile, then to compile src/base64.ll directly without generating *.s. cf. https://github.com/herumi/bls-eth-go-binary/blob/master/Makefile