scipr-lab / libff

C++ library for Finite Fields and Elliptic Curves
Other
149 stars 82 forks source link

Issue with compiling ate-pairing dependency #104

Open AHaliq opened 2 years ago

AHaliq commented 2 years ago

My machine:

ProductName:    Mac OS X
ProductVersion: 10.14.6
BuildVersion:   18G9027

I'm compiling libff with emscripten targetting webassembly and I'm getting the following error upon running make

zm2.cpp:3644:22: fatal error: use of undeclared identifier 'Xbyak'
                static std::vector<Xbyak::uint8> buf;

Inspecting zm2.cpp, we can see this only happens if MIE_USE_X64ASM is set to false

you can view my full project here to reproduce the issue: https://github.com/AHaliq/WebAssemblyReact emscripten call starts at scripts/cryptoutils.sh line 49 cryptoutils adds libff at deps/cryptoutils/src/CMakeLists.txt line 14

AHaliq commented 2 years ago

I've made some progress investigating this issue,

in zm2.cpp line 8, Xbyak is only included if MIE_USE_X64ASM is set in zm.h line 68, MIE_USE_X64ASM is unset when __x86_64__ is unset

In emscripten's faq site it says

Emscripten automatically unsets the following #define values, as these are commonly set in projects to enable platform dependent code (inline assembly): #undef __i386__ #undef __x86_64__

in zm.h since there is a case for without __x86_64__ does that mean there is an alternative ways to build the project or is that case unhandled and cannot build the project?

malturki commented 2 years ago

I'm having the same problem. My machine:

macOS Monterey -- version 12.1 (21C52)
Apple M1 Max

@AHaliq Have you managed to figure out a solution to this? Are you using an Apple Silicon machine?

AHaliq commented 2 years ago

@malturki libff uses ate-pairing and xbyak which contains inline assembly thus cant be compiled by emscripten. You should look for alternatives or fork this project and use other dependencies such as mcl

I havent tried it myself. The project i was working on has been handed over to someone else.

malturki commented 2 years ago

Thanks @AHaliq for the prompt response. I will probably look into alternatives.

It would have been helpful to have a list of supported (or unsupported) architectures given up front in the README.