pq-crystals/kyber

Hit error when running `make` under `avx2` (related to issue #14)

zhangl64 opened this issue · 6 comments

I guess this issue is related to my previous question---issue #14 (which has been solved), I hit the error when running make under the folder of avx2:

In file included from kem.c:6:
./symmetric.h:10:10: fatal error: 'openssl/sha.h' file not found
#include <openssl/sha.h>
         ^~~~~~~~~~~~~~~
1 error generated.
In file included from indcpa.c:9:
./symmetric.h:10:10: fatal error: 'openssl/sha.h' file not found
#include <openssl/sha.h>
         ^~~~~~~~~~~~~~~
1 error generated.
In file included from poly.c:9:
./symmetric.h:10:10: fatal error: 'openssl/sha.h' file not found
#include <openssl/sha.h>
         ^~~~~~~~~~~~~~~
1 error generated.
make: *** [test_kyber512-90s] Error 1

Many thanks.

In the avx2 code the 90s variant of Kyber needs openssl, not just the NIST KAT program. Therefore you also have to add the openssl directory to CFLAGS, not just NISTFLAGS:

export LDFLAGS="-L/usr/local/opt/openssl@1.1/lib"
export CFLAGS="-I/usr/local/opt/openssl@1.1/include"
export NISTFLAGS="-I/usr/local/opt/openssl@1.1/include"

Thanks again @gregorseiler , this problem has been solved, but the make still throws some errors:

cc -I/usr/local/opt/openssl@1.1/include -Wall -Wextra -Wpedantic -Wmissing-prototypes -Wredundant-decls -Wshadow -Wpointer-arith -mavx2 -mbmi -mpopcnt -maes -march=native -mtune=native -O3 -fomit-frame-pointer -D KYBER_90S -DKYBER_K=2 kem.c indcpa.c polyvec.c poly.c fq.S shuffle.S ntt.S invntt.S basemul.S consts.c rejsample.c cbd.c verify.c aes256ctr.c randombytes.c test_kyber.c -o test_kyber512-90s -lcrypto
ld: library not found for -lcrypto
clang: error: linker command failed with exit code 1 (use -v to see invocation)

Is this related to my gcc? I work on Mac, the gcc version is:

Configured with: --prefix=/Applications/Xcode.app/Contents/Developer/usr --with-gxx-include-dir=/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.13.sdk/usr/include/c++/4.2.1
Apple LLVM version 9.0.0 (clang-900.0.38)
Target: x86_64-apple-darwin18.7.0
Thread model: posix
InstalledDir: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin

Many thanks!

@zhangl64 Your linker fails: The -L parameter as suggested by @gregorseiler apparently has not been passed to cc. Did you set LDFLAGS?

Yes @baentsch , at least I guess so, here is the test of the variable:

echo $LDFLAGS
-L/usr/local/opt/openssl@1.1/lib

@zhangl64 Are you using the latest code (git pull)? The LDFLAGS have been added only recently.

Good advice @baentsch , I just saw that @gregorseiler pushed a new commit 5 hours ago, I pulled the latest changes, and problem solved. Thanks guys~~!