emp-toolkit / emp-zk

Efficient and Interactive Zero-Knowledge Proofs
Other
77 stars 18 forks source link

Compilation Error on Xcode #13

Open Tabaie opened 3 years ago

Tabaie commented 3 years ago

I can successfully install ot, zk and tool on a macOS, with all the tests passing successfully. However, the following simple program, which only makes a reference to setup_zk_bool won't compile with Xcode.

#include <emp-tool/emp-tool.h>
#include <emp-zk/emp-zk.h>

int main(int argc, const char * argv[]) {
    setup_zk_bool((BoolIO<NetIO>**)nullptr, 0, 0);
    return 0;
}

The errors are the following:

emp-tool/utils/aes_opt.h:12:15: Always_inline function '_mm_aesenclast_si128' requires target feature 'aes', but would be inlined into function 'ks_rounds' that is compiled without support for 'aes'

emp-tool/utils/aes_opt.h:79:13: Always_inline function '_mm_aesenc_si128' requires target feature 'aes', but would be inlined into function 'ParaEnc' that is compiled without support for 'aes'

emp-tool/utils/aes_opt.h:89:12: Always_inline function '_mm_aesenclast_si128' requires target feature 'aes', but would be inlined into function 'ParaEnc' that is compiled without support for 'aes'

Since all the tests pass using the same compiler on the same machine, I suspect that the issue has to do with compiler configurations, with Xcode telling the compiler to be strict and throw errors when it could just give a warning. But I don't know which flags that could be.

A small Xcode project containing the program is available here.

wangxiao1254 commented 3 years ago

Unfortunately, I do not have any knowledge in Xcode. If you compile from the terminal, everything should work as described. I think you should tell Xcode to use cmake for configuration. I'm sure there is a way :)

Tabaie commented 3 years ago

Thank you for the prompt response. I tried the following cmake script:

project(emp_zk_compile_err)

set(CMAKE_CXX_STANDARD 17)

add_executable(emp_zk_compile_err main.cpp)
target_include_directories(emp_zk_compile_err PUBLIC "/path/emp-zk")
target_include_directories(emp_zk_compile_err PUBLIC "/path/emp-tool")
target_include_directories(emp_zk_compile_err PUBLIC "/path/emp-ot")
target_include_directories(emp_zk_compile_err PUBLIC "/usr/local/opt/openssl@1.1/include")

Still got the same errors:

Aryas-MacBook-Pro:build arya$ make
[ 50%] Building CXX object CMakeFiles/emp_zk_compile_err.dir/main.o
In file included from /path/emp-compile-err/emp-compile-err/main.cpp:2:
In file included from /path/emp-tool/emp-tool/emp-tool.h:29:
In file included from /path/emp-tool/emp-tool/utils/mitccrh.h:3:
/path/emp-tool/emp-tool/utils/aes_opt.h:12:15: error: always_inline function '_mm_aesenclast_si128' requires target feature 'aes', but would be inlined into function 'ks_rounds' that is compiled without support for 'aes'
                block aux = _mm_aesenclast_si128 (x2, con);
                            ^
/path/emp-tool/emp-tool/utils/aes_opt.h:79:13: error: always_inline function '_mm_aesenc_si128' requires target feature 'aes', but would be inlined into function 'ParaEnc' that is compiled without support for 'aes'
                                *blks = _mm_aesenc_si128(*blks, K);
                                        ^
/path/emp-tool/emp-tool/utils/aes_opt.h:89:12: error: always_inline function '_mm_aesenclast_si128' requires target feature 'aes', but would be inlined into function 'ParaEnc' that is compiled without support for 'aes'
                        *blks = _mm_aesenclast_si128(*blks, K);
                                ^
/path/emp-tool/emp-tool/utils/aes_opt.h:79:13: error: always_inline function '_mm_aesenc_si128' requires target feature 'aes', but would be inlined into function 'ParaEnc' that is compiled without support for 'aes'
                                *blks = _mm_aesenc_si128(*blks, K);
                                        ^
/path/emp-tool/emp-tool/utils/aes_opt.h:89:12: error: always_inline function '_mm_aesenclast_si128' requires target feature 'aes', but would be inlined into function 'ParaEnc' that is compiled without support for 'aes'
                        *blks = _mm_aesenclast_si128(*blks, K);
                                ^
5 errors generated.
make[2]: *** [CMakeFiles/emp_zk_compile_err.dir/main.o] Error 1
make[1]: *** [CMakeFiles/emp_zk_compile_err.dir/all] Error 2
make: *** [all] Error 2
wangxiao1254 commented 3 years ago

Please use our cmake configuration at https://github.com/emp-toolkit/emp-zk/blob/master/CMakeLists.txt, crucially, this file include https://github.com/emp-toolkit/emp-tool/blob/master/cmake/emp-base.cmake#L50, that enables AES.