cryptobiu / libscapi

Comprehensive Open Source Library for Secure Multiparty Computation
MIT License
180 stars 66 forks source link

OpenSSL & MacOS Build Process #51

Closed dahadaller closed 5 years ago

dahadaller commented 6 years ago

Are there any plans to update the install instructions for macos Mojave? I recently updated, but now, when I tried to re-compile libscapi with the install instructions listed here, the brew link openssl step returns the following error:

Warning: Refusing to link macOS-provided software: openssl
If you need to have openssl first in your PATH run:
  echo 'export PATH="/usr/local/opt/openssl/bin:$PATH"' >> ~/.bash_profile

For compilers to find openssl you may need to set:
  export LDFLAGS="-L/usr/local/opt/openssl/lib"
  export CPPFLAGS="-I/usr/local/opt/openssl/include"

For pkg-config to find openssl you may need to set:
  export PKG_CONFIG_PATH="/usr/local/opt/openssl/lib/pkgconfig"

I have put each of those export statements in my .bash_profile and I've made sure that /usr/local/opt/openssl/bin comes before all other directories in the PATH.

I've also tried linking manually (according to this stackoverflow page), to no avail:

brew update    
brew install openssl    
ln -s /usr/local/opt/openssl/lib/libcrypto.1.0.0.dylib /usr/local/lib/    
ln -s /usr/local/opt/openssl/lib/libssl.1.0.0.dylib /usr/local/lib/

From what glean off forums, it might be that macos Mojave has it's own ssl library and that brew doesn't have the credentials to make openssl a default (even with the brew link --force option.) If I try to compile libscapi without first linking openssl, the compilation will progress for a while, and then it will terminate with the following error:

ecp_nistp224.c:43:9: error: unknown type name '__uint128_t'
typedef __uint128_t uint128_t;  /* nonstandard; implemented by gcc on 64-bit
        ^
ecp_nistp224.c:460:33: warning: overflow in expression; result is -2147483648 with type 'int' [-Winteger-overflow]
        (((widelimb) 1) << 104) - (((widelimb) 1) << 64);
                                ^
ecp_nistp224.c:456:51: warning: shift count >= width of type [-Wshift-count-overflow]
    static const widelimb two120 = ((widelimb) 1) << 120;
                                                  ^  ~~~
ecp_nistp224.c:457:55: warning: shift count >= width of type [-Wshift-count-overflow]
    static const widelimb two120m64 = (((widelimb) 1) << 120) -
                                                      ^  ~~~
ecp_nistp224.c:458:25: warning: shift count >= width of type [-Wshift-count-overflow]
        (((widelimb) 1) << 64);
                        ^  ~~
ecp_nistp224.c:459:59: warning: shift count >= width of type [-Wshift-count-overflow]
    static const widelimb two120m104m64 = (((widelimb) 1) << 120) -
                                                          ^  ~~~
ecp_nistp224.c:460:25: warning: shift count >= width of type [-Wshift-count-overflow]
        (((widelimb) 1) << 104) - (((widelimb) 1) << 64);
                        ^  ~~~
ecp_nistp224.c:460:51: warning: shift count >= width of type [-Wshift-count-overflow]
        (((widelimb) 1) << 104) - (((widelimb) 1) << 64);
                                                  ^  ~~
ecp_nistp224.c:486:60: warning: overflow in expression; result is 2147483392 with type 'int' [-Winteger-overflow]
    static const widelimb two64m8 = (((widelimb) 1) << 64) -
                                                           ^
ecp_nistp224.c:484:53: warning: shift count >= width of type [-Wshift-count-overflow]
    static const widelimb two64p8 = (((widelimb) 1) << 64) +
                                                    ^  ~~
ecp_nistp224.c:486:53: warning: shift count >= width of type [-Wshift-count-overflow]
    static const widelimb two64m8 = (((widelimb) 1) << 64) -
                                                    ^  ~~
ecp_nistp224.c:488:56: warning: shift count >= width of type [-Wshift-count-overflow]
    static const widelimb two64m48m8 = (((widelimb) 1) << 64) -
                                                       ^  ~~
ecp_nistp224.c:489:25: warning: shift count >= width of type [-Wshift-count-overflow]
        (((widelimb) 1) << 48) - (((widelimb) 1) << 8);
                        ^  ~~
ecp_nistp224.c:572:32: warning: overflow in expression; result is -2147483648 with type 'int' [-Winteger-overflow]
        (((widelimb) 1) << 71) - (((widelimb) 1) << 55);
                               ^
ecp_nistp224.c:567:55: warning: shift count >= width of type [-Wshift-count-overflow]
    static const widelimb two127p15 = (((widelimb) 1) << 127) +
                                                      ^  ~~~
ecp_nistp224.c:569:55: warning: shift count >= width of type [-Wshift-count-overflow]
    static const widelimb two127m71 = (((widelimb) 1) << 127) -
                                                      ^  ~~~
ecp_nistp224.c:570:25: warning: shift count >= width of type [-Wshift-count-overflow]
        (((widelimb) 1) << 71);
                        ^  ~~
ecp_nistp224.c:571:58: warning: shift count >= width of type [-Wshift-count-overflow]
    static const widelimb two127m71m55 = (((widelimb) 1) << 127) -
                                                         ^  ~~~
ecp_nistp224.c:572:25: warning: shift count >= width of type [-Wshift-count-overflow]
        (((widelimb) 1) << 71) - (((widelimb) 1) << 55);
                        ^  ~~
ecp_nistp224.c:572:50: warning: shift count >= width of type [-Wshift-count-overflow]
        (((widelimb) 1) << 71) - (((widelimb) 1) << 55);
                                                 ^  ~~
ecp_nistp224.c:584:35: warning: shift count >= width of type [-Wshift-count-overflow]
    output[3] += (in[6] & 0xffff) << 40;
                                  ^  ~~
ecp_nistp224.c:588:35: warning: shift count >= width of type [-Wshift-count-overflow]
    output[2] += (in[5] & 0xffff) << 40;
                                  ^  ~~
ecp_nistp224.c:592:39: warning: shift count >= width of type [-Wshift-count-overflow]
    output[1] += (output[4] & 0xffff) << 40;
                                      ^  ~~
ecp_nistp224.c:596:28: warning: shift count >= width of type [-Wshift-count-overflow]
    output[3] += output[2] >> 56;
                           ^  ~~
ecp_nistp224.c:599:27: warning: shift count >= width of type [-Wshift-count-overflow]
    output[4] = output[3] >> 56;
                          ^  ~~
ecp_nistp224.c:607:39: warning: shift count >= width of type [-Wshift-count-overflow]
    output[1] += (output[4] & 0xffff) << 40;
                                      ^  ~~
ecp_nistp224.c:611:28: warning: shift count >= width of type [-Wshift-count-overflow]
    output[1] += output[0] >> 56;
                           ^  ~~
ecp_nistp224.c:614:28: warning: shift count >= width of type [-Wshift-count-overflow]
    output[2] += output[1] >> 56;
                           ^  ~~
ecp_nistp224.c:617:28: warning: shift count >= width of type [-Wshift-count-overflow]
    output[3] += output[2] >> 56;
                           ^  ~~
28 warnings and 1 error generated.
make[3]: *** [ecp_nistp224.o] Error 1
make[2]: *** [subdirs] Error 1
make[1]: *** [build_crypto] Error 1
make: *** [compile-openssl] Error 2

How could I remedy this? Any help at all would be much appreciated.

bonliu commented 5 years ago

Same problem here.

liorko87 commented 5 years ago

Hello,

Which compiler you are using?

liorko87 commented 5 years ago

I noticed right now that you are using the latest Macos version. Currently we are supporting only High Sierra 10.13.

dahadaller commented 5 years ago

I have also replicated this same problem in a colleague's (Bon, who is also on this thread) computer on High Sierra 10.13, too. My computer has Mojave. The compiler used on High Sierra computer was clang.

Bons-MacBook-Pro:~ bon$ ls -l $(which cc)
lrwxr-xr-x  1 root  wheel  5 Oct 26 21:22 /usr/bin/cc -> clang

Bons-MacBook-Pro:libscapi bon$ ls -l $(which g++)
-rwxr-xr-x  1 root  wheel  18288 Sep 21 00:17 /usr/bin/g++

Bons-MacBook-Pro:libscapi bon$ g++ --version
Configured with: --prefix=/Applications/Xcode.app/Contents/Developer/usr --with-gxx-include-dir=/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.14.sdk/usr/include/c++/4.2.1
Apple LLVM version 10.0.0 (clang-1000.11.45.5)
Target: x86_64-apple-darwin18.0.0
Thread model: posix
InstalledDir: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin