osu-crypto / libOTe

A fast, portable, and easy to use Oblivious Transfer Library
Other
428 stars 107 forks source link

First build always fails on macOS #142

Closed elimbaum closed 1 week ago

elimbaum commented 1 month ago

I'm on an M1 Mac, macOS 14.5. Whenever I run the build script, the first time, it always fails. After that, it works fine.

The error I get is

$ python3 build.py --all --boost --sodium -DENABLE_SSE=false
...
checking for gcc... /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/cc
checking whether the C compiler works... no
configure: error: in '/Users/eli/localdoc/research/secrecy-private/build/libOTe/out/libsodium':
configure: error: C compiler cannot create executables
See 'config.log' for more details
CMake Error at cryptoTools/thirdparty/fetch.cmake:21 (message):
  Configure failed (77).
Call Stack (most recent call first):
  cryptoTools/thirdparty/getSodium.cmake:76 (run)
  cryptoTools/cmake/cryptoToolsDepHelper.cmake:141 (include)
  cryptoTools/CMakeLists.txt:46 (include)

At the end of config.log I see

configure:4395: checking whether the C compiler works
configure:4417: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/cc    conftest.c  >&5
ld: library 'System' not found
clang: error: linker command failed with exit code 1 (use -v to see invocation)
configure:4421: $? = 1
configure:4462: result: no
configure: failed program was:
| /* confdefs.h */
| #define PACKAGE_NAME "libsodium"
| #define PACKAGE_TARNAME "libsodium"
| #define PACKAGE_VERSION "1.0.18"
| #define PACKAGE_STRING "libsodium 1.0.18"
| #define PACKAGE_BUGREPORT "https://github.com/jedisct1/libsodium/issues"
| #define PACKAGE_URL "https://libsodium.org"
| #define PACKAGE "libsodium"
| #define VERSION "1.0.18"
| /* end confdefs.h.  */
| 
| int
| main (void)
| {
| 
|   ;
|   return 0;
| }
configure:4467: error: in '/Users/eli/localdoc/research/secrecy-private/build/libOTe/out/libsodium':
configure:4469: error: C compiler cannot create executables

On all subsequent runs, there is no issue:

configure:4395: checking whether the C compiler works
configure:4417: gcc    conftest.c  >&5
configure:4421: $? = 0
configure:4472: result: yes

At first, I thought the compiler has changed, from XCode's cc, to my local gcc. However:

# first time
$ /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/cc --version
Apple clang version 15.0.0 (clang-1500.3.9.4)
Target: arm64-apple-darwin23.5.0
Thread model: posix
InstalledDir: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin
# second time
$ which gcc
/usr/bin/gcc
$ gcc --version
Apple clang version 15.0.0 (clang-1500.3.9.4)
Target: arm64-apple-darwin23.5.0
Thread model: posix
InstalledDir: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin

In fact, the Xcode cc is a symlink to /usr/bin/clang, which is hard linked to gcc. Not even sure if any of this is relevant. Let me know if it'd be useful to see any other debug info. I do not observe issue on Linux.

ladnir commented 1 month ago

This looks like just as issue with sodium or how we are calling it's build. Not sure, I'm also going on vacation for 3 weeks so it might be a bit before I get back to this.

ladnir commented 2 weeks ago

looked into this and not totally sure what the issue is. somehow sodium's build is getting confused. For now you can just use relic. I updated relic and it should be working correctly on mac.

elimbaum commented 1 week ago

Thanks for looking into it, I'll try that. This doesn't cause any issues after installation, and we've not seen this issue on our main Linux testing machines, so going to close the issue.