open-quantum-safe / liboqs

C library for prototyping and experimenting with quantum-resistant cryptography
https://openquantumsafe.org/
Other
1.92k stars 466 forks source link

-DOQS_MINIMAL_BUILD="OQS_ENABLE_KEM_kyber_512" doesn't build #1979

Closed azmur8 closed 3 weeks ago

azmur8 commented 3 weeks ago

Hello, trying to build a library with only one algo, this is current main branch, however it doesn't build:

[1/39] Building C object src/CMakeFiles/oqs.dir/kem/kem.c.o FAILED: src/CMakeFiles/oqs.dir/kem/kem.c.o /usr/bin/musl-gcc -I/home/dr/liboqs/build/include -I/home/dr/liboqs/src -Os -DNDEBUG -fPIC -fvisibility=hidden -Wa,--noexecstack -O3 -fomit-frame-pointer -fdata-sections -ffunction-sections -Wl,--gc-sections -std=gnu11 -MD -MT src/CMakeFiles/oqs.dir/kem/kem.c.o -MF src/CMakeFiles/oqs.dir/kem/kem.c.o.d -o src/CMakeFiles/oqs.dir/kem/kem.c.o -c /home/dr/liboqs/src/kem/kem.c /home/dr/liboqs/src/kem/kem.c: In function ‘OQS_KEM_new’: /home/dr/liboqs/src/kem/kem.c:380:24: error: implicit declaration of function ‘OQS_KEM_kyber_512_new’ [-Wimplicit-function-declaration] 380 | return OQS_KEM_kyber_512_new(); | ^~~~~ /home/dr/liboqs/src/kem/kem.c:380:24: error: returning ‘int’ from a function with return type ‘OQS_KEM *’ makes pointer from integer without a cast [-Wint-conversion] 380 | return OQS_KEM_kyber_512_new(); | ^~~~~~~ [10/39] Building C object src/common/CMakeFiles/common.dir/sha2/sha2_c.c.o ninja: build stopped: subcommand failed.

it seems there are few problems here:

  1. OQS_KEM_kyber_512_new is defined in kem_kyber.h which shall be included via kem.h with the following macro:

    ifdef OQS_ENABLE_KEM_KYBER

    include <oqs/kem_kyber.h>

    endif / OQS_ENABLE_KEM_KYBER /

  2. i couldn't find a proper way how to put OQS_ENABLE_KEM_KYBER together with OQS_MINIMAL_BUILD="OQS_ENABLE_KEM_kyber_512", i tried -DOQS_ENABLE_KEM_KYBER=ON but it doesn't compile
  3. even if i add inclusion kem_kyber.h of explicitly into kem.c it still doesn't link (looks like kem_kyber_512.c is not compiled, so kem.c is not able to compile OQS_KEM_kyber_512_new)
SWilson4 commented 3 weeks ago

Hi @azmur8, thanks for your interest in liboqs! The correct syntax is -DOQS_MINIMAL_BUILD="KEM_kyber_512", without the OQS_ENABLE_ prefix, as documented in CONFIGURE.md.