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

libff clang on macOS #4

Closed
kozyilmaz opened this issue Apr 12, 2017 · 3 comments
Closed

libff clang on macOS #4

kozyilmaz opened this issue Apr 12, 2017 · 3 comments

Comments

@kozyilmaz
Copy link

kozyilmaz commented Apr 12, 2017

I am having problems building libff with clang on macOS Sierra. GMP, Boost and OpenSSL are previously compiled in my setup, so here is the output of cmake and make commands. It’s all related to non-type template argument deduction it seems.

bash-3.2$ PKG_CONFIG_PATH=${BSPROOTFS}/lib/pkgconfig cmake -DCMAKE_INSTALL_PREFIX=${BSPROOTFS} -DCURVE=ALT_BN128 -DMULTICORE=OFF -DBINARY_OUTPUT=ON -DMONTGOMERY_OUTPUT=ON -DUSE_PT_COMPRESSION=OFF -DWITH_PROCPS=OFF OPTFLAGS="-O2" .
-- The C compiler identification is AppleClang 8.0.0.8000042
-- The CXX compiler identification is AppleClang 8.0.0.8000042
-- Check for working C compiler: /Library/Developer/CommandLineTools/usr/bin/cc
-- Check for working C compiler: /Library/Developer/CommandLineTools/usr/bin/cc -- works
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Detecting C compile features
-- Detecting C compile features - done
-- Check for working CXX compiler: /Library/Developer/CommandLineTools/usr/bin/c++
-- Check for working CXX compiler: /Library/Developer/CommandLineTools/usr/bin/c++ -- works
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- Found PkgConfig: /Users/loki/Desktop/devel/zcash-apple/tools/o/bin/pkg-config (found version "0.29.1") 
-- Checking for module 'libcrypto'
--   Found libcrypto, version 1.1.0e
-- Boost version: 1.63.0
-- Found the following Boost libraries:
--   program_options
-- Configuring done
-- Generating done
-- Build files have been written to: /Users/loki/Desktop/devel/zcash-apple/libsnark/libff

getting errors from operator<<

bash-3.2$ make
Scanning dependencies of target ff
[  4%] Building CXX object src/CMakeFiles/ff.dir/algebra/curves/alt_bn128/alt_bn128_g1.cpp.o
/Users/loki/Desktop/devel/zcash-apple/libsnark/libff/src/algebra/curves/alt_bn128/alt_bn128_g1.cpp:411:9: fatal error: invalid operands to binary expression
      ('std::ostream' (aka 'basic_ostream<char>') and 'alt_bn128_Fq' (aka 'Fp_model<alt_bn128_q_limbs, alt_bn128_modulus_q>'))
    out << copy.X << OUTPUT_SEPARATOR << copy.Y;
    ~~~ ^  ~~~~~~

/Users/loki/Desktop/devel/zcash-apple/libsnark/libff/src/./algebra/fields/fp.tcc:779:15: note: candidate template ignored: substitution failure [with n = 4]:
      deduced non-type template argument does not have the same type as the its corresponding template parameter ('bigint<alt_bn128_q_limbs>' vs
      'const bigint<4L> &')
std::ostream& operator<<(std::ostream &out, const Fp_model<n, modulus> &p)
              ^

1 error generated.
make[2]: *** [src/CMakeFiles/ff.dir/algebra/curves/alt_bn128/alt_bn128_g1.cpp.o] Error 1
make[1]: *** [src/CMakeFiles/ff.dir/all] Error 2
make: *** [all] Error 2

and operator>>

bash-3.2$ make
Scanning dependencies of target ff
[  4%] Building CXX object src/CMakeFiles/ff.dir/algebra/curves/alt_bn128/alt_bn128_g1.cpp.o
/Users/loki/Desktop/devel/zcash-apple/libsnark/libff/src/algebra/curves/alt_bn128/alt_bn128_g1.cpp:426:19: fatal error: invalid operands to binary expression
      ('basic_istream<char, std::__1::char_traits<char> >' and 'alt_bn128_Fq' (aka 'Fp_model<alt_bn128_q_limbs, alt_bn128_modulus_q>'))
    in >> is_zero >> tX >> tY;
    ~~~~~~~~~~~~~ ^  ~~

/Users/loki/Desktop/devel/zcash-apple/libsnark/libff/src/./algebra/fields/fp.tcc:793:15: note: candidate template ignored: substitution failure [with n = 4]:
      deduced non-type template argument does not have the same type as the its corresponding template parameter ('bigint<alt_bn128_q_limbs>' vs
      'const bigint<4L> &')
std::istream& operator>>(std::istream &in, Fp_model<n, modulus> &p)
              ^

1 error generated.
make[2]: *** [src/CMakeFiles/ff.dir/algebra/curves/alt_bn128/alt_bn128_g1.cpp.o] Error 1
make[1]: *** [src/CMakeFiles/ff.dir/all] Error 2
make: *** [all] Error 2

And lastly from operator*

bash-3.2$ make
Scanning dependencies of target ff
[  4%] Building CXX object src/CMakeFiles/ff.dir/algebra/curves/alt_bn128/alt_bn128_g2.cpp.o
/Users/loki/Desktop/devel/zcash-apple/libsnark/libff/src/algebra/curves/alt_bn128/alt_bn128_g2.cpp:440:5: warning: variable 'is_zero' is uninitialized when
      used here [-Wuninitialized]
    is_zero -= '0';
    ^~~~~~~
/Users/loki/Desktop/devel/zcash-apple/libsnark/libff/src/algebra/curves/alt_bn128/alt_bn128_g2.cpp:435:17: note: initialize the variable 'is_zero' to silence
      this warning
    char is_zero;
                ^
                 = '\0'
1 warning generated.
[  8%] Building CXX object src/CMakeFiles/ff.dir/algebra/curves/alt_bn128/alt_bn128_init.cpp.o
/Users/loki/Desktop/devel/zcash-apple/libsnark/libff/src/algebra/curves/alt_bn128/alt_bn128_init.cpp:136:49: fatal error: invalid operands to binary expression
      ('alt_bn128_Fq' (aka 'Fp_model<alt_bn128_q_limbs, alt_bn128_modulus_q>') and 'libff::Fp2_model<4, &libff::alt_bn128_modulus_q>')
    alt_bn128_twist_coeff_b = alt_bn128_coeff_b * alt_bn128_twist.inverse();
                              ~~~~~~~~~~~~~~~~~ ^ ~~~~~~~~~~~~~~~~~~~~~~~~~
/Users/loki/Desktop/devel/zcash-apple/libsnark/libff/src/./algebra/fields/fp.hpp:103:14: note: candidate function not viable: no known conversion from
      'libff::Fp2_model<4, &libff::alt_bn128_modulus_q>' to 'const libff::Fp_model<4, &libff::alt_bn128_modulus_q>' for 1st argument
    Fp_model operator*(const Fp_model& other) const;
             ^
/Users/loki/Desktop/devel/zcash-apple/libsnark/libff/src/./algebra/fields/fp2.tcc:66:23: note: candidate template ignored: substitution failure [with n = 4]:
      deduced non-type template argument does not have the same type as the its corresponding template parameter ('bigint<alt_bn128_q_limbs>' vs
      'const bigint<4L> &')
Fp2_model<n, modulus> operator*(const Fp_model<n, modulus> &lhs, const Fp2_model<n, modulus> &rhs)
                      ^
/Users/loki/Desktop/devel/zcash-apple/libsnark/libff/src/./algebra/curves/alt_bn128/alt_bn128_g1.hpp:81:14: note: candidate template ignored: substitution
      failure [with m = 4]: deduced non-type template argument does not have the same type as the its corresponding template parameter
      ('bigint<alt_bn128_q_limbs>' vs 'const bigint<4L> &')
alt_bn128_G1 operator*(const Fp_model<m,modulus_p> &lhs, const alt_bn128_G1 &rhs)
             ^

/Users/loki/Desktop/devel/zcash-apple/libsnark/libff/src/./algebra/curves/alt_bn128/alt_bn128_g2.hpp:85:14: note: candidate template ignored: substitution
      failure [with m = 4]: deduced non-type template argument does not have the same type as the its corresponding template parameter
      ('bigint<alt_bn128_q_limbs>' vs 'const bigint<4L> &')
alt_bn128_G2 operator*(const Fp_model<m,modulus_p> &lhs, const alt_bn128_G2 &rhs)
             ^
1 error generated.
make[2]: *** [src/CMakeFiles/ff.dir/algebra/curves/alt_bn128/alt_bn128_init.cpp.o] Error 1
make[1]: *** [src/CMakeFiles/ff.dir/all] Error 2
make: *** [all] Error 2
@jason-tilley
Copy link

jason-tilley commented Mar 3, 2018

Just realized I have similar issue on ticket #17

@jason-tilley
Copy link

In case you don't realize this already, a temporary workaround that worked for me was to install ate-pairing and xbyak manually, edit the .hpp files in libff/algebra/curves/bn128/ to just import "bn.h", and compile with gcc7. Far from the ideal solution though.

mobileink added a commit to minatools/libff that referenced this issue Jul 20, 2020
# This is the 1st commit message:

bazel support, initial commit

Signed-off-by: Gregg Reynolds <601396+mobileink@users.noreply.github.com>

# This is the commit message scipr-lab#2:

gitignore .bazelrc, bazel-*

Signed-off-by: Gregg Reynolds <601396+mobileink@users.noreply.github.com>

# This is the commit message scipr-lab#3:

remove sha256 from rule_foreign_cc rule

Signed-off-by: Gregg Reynolds <601396+mobileink@users.noreply.github.com>

# This is the commit message scipr-lab#4:

rename target ff to libff

Signed-off-by: Gregg Reynolds <601396+mobileink@users.noreply.github.com>

# This is the commit message scipr-lab#5:

put curves/mnt/mnt4, 6 in separate packages

Signed-off-by: Gregg Reynolds <601396+mobileink@users.noreply.github.com>

# This is the commit message scipr-lab#6:

bn128: drop "depends" from include prefix, for bazel compatibility

Signed-off-by: Gregg Reynolds <601396+mobileink@users.noreply.github.com>

# This is the commit message scipr-lab#7:

fix refs to targets mnt4, mnt6, libff

Signed-off-by: Gregg Reynolds <601396+mobileink@users.noreply.github.com>

# This is the commit message scipr-lab#8:

fix refs to @ate_pairing//:libgmp

Signed-off-by: Gregg Reynolds <601396+mobileink@users.noreply.github.com>

# This is the commit message scipr-lab#9:

change @// to //

Signed-off-by: Gregg Reynolds <601396+mobileink@users.noreply.github.com>

# This is the commit message scipr-lab#10:

delete obsolete mnt4, mnt6 targets from curves/mnt/BUILD.bazel

Signed-off-by: Gregg Reynolds <601396+mobileink@users.noreply.github.com>

# This is the commit message scipr-lab#11:

add target scalar_multiplication:multiexp_profile

Signed-off-by: Gregg Reynolds <601396+mobileink@users.noreply.github.com>

# This is the commit message scipr-lab#12:

list headers explicitly

Signed-off-by: Gregg Reynolds <601396+mobileink@users.noreply.github.com>

# This is the commit message scipr-lab#13:

dead code elim

Signed-off-by: Gregg Reynolds <601396+mobileink@users.noreply.github.com>

# This is the commit message scipr-lab#14:

dead code elim

Signed-off-by: Gregg Reynolds <601396+mobileink@users.noreply.github.com>

# This is the commit message scipr-lab#15:

BUILD files: explicitate srcs/hdrs, DCE, buildifier reformat

Signed-off-by: Gregg Reynolds <601396+mobileink@users.noreply.github.com>

# This is the commit message scipr-lab#16:

change @ate_pairing//:zm to @ate_pairing//ate-pairing

Signed-off-by: Gregg Reynolds <601396+mobileink@users.noreply.github.com>

# This is the commit message scipr-lab#17:

switch obazl repos from local to git

Signed-off-by: Gregg Reynolds <601396+mobileink@users.noreply.github.com>

# This is the commit message scipr-lab#18:

pin xbyak, ate-pairing repos to versions, to match upstream

Signed-off-by: Gregg Reynolds <601396+mobileink@users.noreply.github.com>

# This is the commit message scipr-lab#19:

delete git submodules, not needed with Bazel

Signed-off-by: Gregg Reynolds <601396+mobileink@users.noreply.github.com>

# This is the commit message scipr-lab#20:

add sha256 for xbyak, ate-pairing external repos

Signed-off-by: Gregg Reynolds <601396+mobileink@users.noreply.github.com>

# This is the commit message scipr-lab#21:

remove xbyak dep - it's included in ate-pairing

Signed-off-by: Gregg Reynolds <601396+mobileink@users.noreply.github.com>

# This is the commit message scipr-lab#22:

restore depends dirs

Signed-off-by: Gregg Reynolds <601396+mobileink@users.noreply.github.com>
@ValarDragon
Copy link
Member

ValarDragon commented Aug 25, 2020

Hrm, does this problem still persist on the latest version of the library? I'm unable to reproduce on Mojave. (Version 10.14.6)

I think some fixes regarding templates have been merged since the issue was created. I'm closing this now due to how long its been, please re-open or start a new issue if the problem on macOS still persists!

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

No branches or pull requests

3 participants