elibensasson / libSTARK

A library for zero knowledge (ZK) scalable transparent argument of knowledge (STARK)
Other
507 stars 90 forks source link

Problems compiling on MacOS #2

Open JustinDrake opened 6 years ago

JustinDrake commented 6 years ago

Awesome to have initial code! This is what I get from running make -j8 on a Mac

Justins-MacBook-Pro:libSTARK justin$ make -j8
/Library/Developer/CommandLineTools/usr/bin/make -C /Users/justin/Desktop/repos/libSTARK/algebra/FFT  BLDDIR=/Users/justin/Desktop/repos/libSTARK/bin/fft
/Library/Developer/CommandLineTools/usr/bin/make -C /Users/justin/Desktop/repos/libSTARK/algebra/algebralib \
    BLDDIR=/Users/justin/Desktop/repos/libSTARK/bin/algebralib FFTINC=/Users/justin/Desktop/repos/libSTARK/algebra/FFT/src
/Library/Developer/CommandLineTools/usr/bin/make -C /Users/justin/Desktop/repos/libSTARK/libstark \
    BLDDIR=/Users/justin/Desktop/repos/libSTARK/bin/libstark \
    FFTINC=/Users/justin/Desktop/repos/libSTARK/algebra/FFT/src     \
    ALGEBRAINC=/Users/justin/Desktop/repos/libSTARK/algebra/algebralib/headers
/Library/Developer/CommandLineTools/usr/bin/make -C /Users/justin/Desktop/repos/libSTARK/tinyram/gadgetlib/gadgetlib                        \
    GADGETINC=/Users/justin/Desktop/repos/libSTARK/tinyram/gadgetlib/gadgetlib/. \
    ALGEBRAINC=/Users/justin/Desktop/repos/libSTARK/algebra/algebralib/headers              \
    ALGEBRALIBLINKDIR=/Users/justin/Desktop/repos/libSTARK/bin/algebralib               \
    FFTLIBLNKDIR=/Users/justin/Desktop/repos/libSTARK/bin/fft   \
    FFTINC=/Users/justin/Desktop/repos/libSTARK/algebra/FFT FFTLIBLNKDIR=/Users/justin/Desktop/repos/libSTARK/bin/fft       \
    BLDDIR=/Users/justin/Desktop/repos/libSTARK/bin/gadgetlib
g++ -O3 -g -Wall -fmessage-length=0 -fopenmp -mavx -maes -mtune=native  -std=c++14  -I./..  -I/Users/justin/Desktop/repos/libSTARK/algebra/algebralib/headers -I/Users/justin/Desktop/repos/libSTARK/algebra/FFT -I/Users/justin/Desktop/repos/libSTARK/algebra/FFT/.. -I/Users/justin/Desktop/repos/libSTARK/algebra/FFT/src -c -o "/Users/justin/Desktop/repos/libSTARK/bin/gadgetlib/common_use.o" "common_use.cpp"
g++ -O3 -g -Wall -fmessage-length=0 -fopenmp -mavx -maes -mtune=native  -std=c++14  -I./..  -I/Users/justin/Desktop/repos/libSTARK/algebra/algebralib/headers -I/Users/justin/Desktop/repos/libSTARK/algebra/FFT -I/Users/justin/Desktop/repos/libSTARK/algebra/FFT/.. -I/Users/justin/Desktop/repos/libSTARK/algebra/FFT/src -c -o "/Users/justin/Desktop/repos/libSTARK/bin/gadgetlib/constraint.o" "constraint.cpp"
g++ -O3 -g -Wall -fmessage-length=0 -fopenmp -mavx -maes -mtune=native  -std=c++14  -I./..  -I/Users/justin/Desktop/repos/libSTARK/algebra/algebralib/headers -I/Users/justin/Desktop/repos/libSTARK/algebra/FFT -I/Users/justin/Desktop/repos/libSTARK/algebra/FFT/.. -I/Users/justin/Desktop/repos/libSTARK/algebra/FFT/src -c -o "/Users/justin/Desktop/repos/libSTARK/bin/gadgetlib/gadget.o" "gadget.cpp"
g++ -O3 -g -Wall -fmessage-length=0 -fopenmp -mavx -maes -mtune=native -mpclmul -std=c++14 -mpclmul -Isrc -c -o "/Users/justin/Desktop/repos/libSTARK/bin/fft/src/Basis.o" "src/Basis.cpp"
g++ -O3 -g -Wall -fmessage-length=0 -fopenmp -mavx -maes -mtune=native  -std=c++14  -I./..  -I/Users/justin/Desktop/repos/libSTARK/algebra/algebralib/headers -I/Users/justin/Desktop/repos/libSTARK/algebra/FFT -I/Users/justin/Desktop/repos/libSTARK/algebra/FFT/.. -I/Users/justin/Desktop/repos/libSTARK/algebra/FFT/src -c -o "/Users/justin/Desktop/repos/libSTARK/bin/gadgetlib/infrastructure.o" "infrastructure.cpp"
g++ -O3 -g -Wall -fmessage-length=0 -fopenmp -mavx -maes -mtune=native  -std=c++14  -I/Users/justin/Desktop/repos/libSTARK/algebra/FFT/src -Iheaders -c -o "/Users/justin/Desktop/repos/libSTARK/bin/algebralib/src/AffinePolynomial.o" "src/AffinePolynomial.cpp"
g++ -O3 -g -Wall -fmessage-length=0 -fopenmp -mavx -maes -mtune=native -mpclmul -std=c++14 -mpclmul -Isrc -c -o "/Users/justin/Desktop/repos/libSTARK/bin/fft/src/Definitions.o" "src/Definitions.cpp"
for dir in ./src/languages/Acsp ./src/languages/Bair ./src/common/Utils ./src/common/Infrastructure ./src/common/Algebra ./src/reductions/BairToAcsp/Details ./src/reductions/BairToAcsp/Routing ./src/reductions/BairToAcsp ./src/protocols/Fri/verifier_details ./src/protocols/Fri/common ./src/protocols/Fri ./src/protocols/common ./src/protocols/common/CryptoCommitment ./src/protocols ./src/protocols/Ali/common_details ./src/protocols/Ali/verifier_details ./src/protocols/Ali; do mkdir -p /Users/justin/Desktop/repos/libSTARK/bin/libstark/obj/$dir; done
clangclangclangclang: : : : clangclang: : clang: error: unsupported option '-fopenmp'error: unsupported option '-fopenmp'error: errorunsupported option '-fopenmp': unsupported option '-fopenmp'error: error: unsupported option '-fopenmp'
unsupported option '-fopenmp'
error: unsupported option '-fopenmp'

make[1]: *** [/Users/justin/Desktop/repos/libSTARK/bin/gadgetlib/infrastructure.o] Error 1
make[1]: *** Waiting for unfinished jobs....
make[1]: *** [/Users/justin/Desktop/repos/libSTARK/bin/gadgetlib/constraint.o] Error 1
make[1]: *** [/Users/justin/Desktop/repos/libSTARK/bin/algebralib/src/AffinePolynomial.o] Error 1
make[1]: *** Waiting for unfinished jobs....
g++ -O3 -g -Wall -fmessage-length=0 -fopenmp -mavx -maes -mtune=native -std=c++14 -Isrc -I/Users/justin/Desktop/repos/libSTARK/algebra/algebralib/headers -I/Users/justin/Desktop/repos/libSTARK/algebra/FFT/src -c -o "/Users/justin/Desktop/repos/libSTARK/bin/libstark/obj/src/languages/Acsp/AcspWitnessChecker.o" "src/languages/Acsp/AcspWitnessChecker.cpp"
make[1]: *** [/Users/justin/Desktop/repos/libSTARK/bin/gadgetlib/gadget.o] Error 1
make[1]: *** [/Users/justin/Desktop/repos/libSTARK/bin/gadgetlib/common_use.o] Error 1
g++ -O3 -g -Wall -fmessage-length=0 -fopenmp -mavx -maes -mtune=native  -std=c++14  -I/Users/justin/Desktop/repos/libSTARK/algebra/FFT/src -Iheaders -c -o "/Users/justin/Desktop/repos/libSTARK/bin/algebralib/src/AffineSpace.o" "src/AffineSpace.cpp"
make: *** [gadgetlib] Error 2g++ -O3 -g -Wall -fmessage-length=0 -fopenmp -mavx -maes -mtune=native -std=c++14 -Isrc -I/Users/justin/Desktop/repos/libSTARK/algebra/algebralib/headers -I/Users/justin/Desktop/repos/libSTARK/algebra/FFT/src -c -o "/Users/justin/Desktop/repos/libSTARK/bin/libstark/obj/src/languages/Bair/ConstraintsSys.o" "src/languages/Bair/ConstraintsSys.cpp"

make: *** Waiting for unfinished jobs....
g++ -O3 -g -Wall -fmessage-length=0 -fopenmp -mavx -maes -mtune=native -mpclmul -std=c++14 -mpclmul -Isrc -c -o "/Users/justin/Desktop/repos/libSTARK/bin/fft/src/Element.o" "src/Element.cpp"
g++ -O3 -g -Wall -fmessage-length=0 -fopenmp -mavx -maes -mtune=native -std=c++14 -Isrc -I/Users/justin/Desktop/repos/libSTARK/algebra/algebralib/headers -I/Users/justin/Desktop/repos/libSTARK/algebra/FFT/src -c -o "/Users/justin/Desktop/repos/libSTARK/bin/libstark/obj/src/languages/Bair/BairWitnessChecker.o" "src/languages/Bair/BairWitnessChecker.cpp"
make[1]: *** [/Users/justin/Desktop/repos/libSTARK/bin/fft/src/Definitions.o] Error 1
make[1]: *** Waiting for unfinished jobs....
make[1]: *** [/Users/justin/Desktop/repos/libSTARK/bin/fft/src/Basis.o] Error 1
g++ -O3 -g -Wall -fmessage-length=0 -fopenmp -mavx -maes -mtune=native -std=c++14 -Isrc -I/Users/justin/Desktop/repos/libSTARK/algebra/algebralib/headers -I/Users/justin/Desktop/repos/libSTARK/algebra/FFT/src -c -o "/Users/justin/Desktop/repos/libSTARK/bin/libstark/obj/src/common/Utils/specsPrint.o" "src/common/Utils/specsPrint.cpp"
g++ -O3 -g -Wall -fmessage-length=0 -fopenmp -mavx -maes -mtune=native -std=c++14 -Isrc -I/Users/justin/Desktop/repos/libSTARK/algebra/algebralib/headers -I/Users/justin/Desktop/repos/libSTARK/algebra/FFT/src -c -o "/Users/justin/Desktop/repos/libSTARK/bin/libstark/obj/src/common/Utils/ErrorHandling.o" "src/common/Utils/ErrorHandling.cpp"
g++ -O3 -g -Wall -fmessage-length=0 -fopenmp -mavx -maes -mtune=native -std=c++14 -Isrc -I/Users/justin/Desktop/repos/libSTARK/algebra/algebralib/headers -I/Users/justin/Desktop/repos/libSTARK/algebra/FFT/src -c -o "/Users/justin/Desktop/repos/libSTARK/bin/libstark/obj/src/common/Utils/Timing.o" "src/common/Utils/Timing.cpp"
clang: error: unsupported option '-fopenmp'
clang: error: unsupported option '-fopenmp'
make[1]: *** [/Users/justin/Desktop/repos/libSTARK/bin/libstark/obj/src/common/Utils/ErrorHandling.o] Error 1
make[1]: *** Waiting for unfinished jobs....
make[1]: *** [/Users/justin/Desktop/repos/libSTARK/bin/libstark/obj/src/languages/Bair/BairWitnessChecker.o] Error 1
clang: error: unsupported option '-fopenmp'
make[1]: *** [/Users/justin/Desktop/repos/libSTARK/bin/libstark/obj/src/languages/Bair/ConstraintsSys.o] Error 1
clang: error: unsupported option '-fopenmp'
clang: error: unsupported option '-fopenmp'
make[1]: *** [/Users/justin/Desktop/repos/libSTARK/bin/libstark/obj/src/common/Utils/specsPrint.o] Error 1
make[1]: *** [/Users/justin/Desktop/repos/libSTARK/bin/libstark/obj/src/common/Utils/Timing.o] Error 1
clang: error: unsupported option '-fopenmp'
clang: error: unsupported option '-fopenmp'
make[1]: *** [/Users/justin/Desktop/repos/libSTARK/bin/libstark/obj/src/languages/Acsp/AcspWitnessChecker.o] Error 1
make[1]: *** [/Users/justin/Desktop/repos/libSTARK/bin/algebralib/src/AffineSpace.o] Error 1
make: *** [libstark] Error 2
make: *** [algebralib] Error 2
clang: error: unsupported option '-fopenmp'
make[1]: *** [/Users/justin/Desktop/repos/libSTARK/bin/fft/src/Element.o] Error 1
make: *** [fft] Error 2
riordant commented 6 years ago

I doubt Mac works without some significant configuration. Do you have access to an Ubuntu VM? I know that at least with libsnark it was not possible on Mac but straightforward on Linux.

radix42 commented 6 years ago

It will probably take changes similar to what was needed for my port of libsnark to Mac, mostly memory model related stuff

MichaelRiabzev commented 6 years ago

It seems the issue is with open-MP over CLang, and maybe the following thread solves the problem: https://stackoverflow.com/questions/39979836/using-openmp-with-c11-on-mac-os](StackOverflow). I've just pushed a version with flags.mk file, where you could change the line CC=g++ to CC=/usr/local/bin/g++-6 (if using the solution from that thread, or something similar). Will be happy to hear if that works (unfortunately, I don't currently have a mac to test that).

kozyilmaz commented 6 years ago

I got a repo that I use to build standalone GNU tools for macOS (mainly for Zcash compilation): https://github.com/kozyilmaz/tools

and here are the precompiled binaries. You can use it by adding the installation path to $PATH https://github.com/kozyilmaz/tools/releases

This is an alternative for brew in any case, only a small patch is needed to make it compile (see below, it is a diff please remove .txt at the end of file name) libstark-macos.patch.txt

I can create a PR if you guys interested (except flags.mk change of course)

MichaelRiabzev commented 6 years ago

Does the solution @kozyilmaz suggests work for all of you? Does it require any package installation on Mac (standard? nonstandard?), or just applying the diff is sufficient?

ghazel commented 6 years ago

I was able to get things compiling and running with clang (Apple LLVM version 9.1.0 (clang-902.0.39.2)) using libomp from brew (as described in https://github.com/elibensasson/libSTARK/issues/2#issuecomment-370237565).

The patch from @kozyilmaz https://github.com/elibensasson/libSTARK/issues/2#issuecomment-370252608 was also needed, and it looks like prover.cpp gained an additional sysinfo() call which I had to ifdef out like the others.

Full diff: https://gist.github.com/ghazel/142c96e3e713d1c8dee4b12625ba6586

siman commented 5 years ago

@ghazel can you please create a pull request with your patch? I also work on mac and cannot compile libSTARK here.

anagnoresis commented 5 years ago

Full diff: https://gist.github.com/ghazel/142c96e3e713d1c8dee4b12625ba6586

from @ghazel was really helpful. Codes got compiled and run with clang(Apple LLVM version 10.0.0 (clang-1000.10.44.2)) just using gcc@7 and libomp from brew.

mrtuborg commented 5 years ago

Guys, if this problem is still has an interest, I have opened the pull request to solve it, please help to review:

https://github.com/elibensasson/libSTARK/pull/20