intel / cryptography-primitives

Intel® Cryptography Primitives Library is a secure, fast and lightweight library of building blocks for cryptography, highly-optimized for various Intel® CPUs
Apache License 2.0
324 stars 86 forks source link

sources/ippcp/asm_intel64/pcpsm3l9_ni_as.asm fails to build with some configs #85

Open berrange opened 1 month ago

berrange commented 1 month ago

Attempting to build ipp-crypto on a Fedora 40 x86_64 host fails on some of the build variants for sources/ippcp/asm_intel64/pcpsm3l9_ni_as.asm

$ mkdir build
$ cd build
$ cmake .. -DARCH=intel64
-- The C compiler identification is GNU 14.2.1
-- The CXX compiler identification is GNU 14.2.1
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Check for working C compiler: /usr/lib64/ccache/cc - skipped
-- Detecting C compile features
-- Detecting C compile features - done
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Check for working CXX compiler: /usr/lib64/ccache/c++ - skipped
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- CMAKE_BUILD_TYPE is unset, defaulting to Release
-- Found Python: /usr/bin/python3.12 (found version "3.12.5") found components: Interpreter 
-- CMAKE_VERSION ......................... 3.28.2
-- NONPIC_LIB ............................ off
-- PROJECT ............................... Intel® Integrated Performance Primitives Cryptography (Intel® IPP Cryptography)
-- CMAKE_BINARY_DIR ...................... /var/home/berrange/src/virt/sgx/ipp-crypto/build
-- CMAKE_OUTPUT_DIR ...................... /var/home/berrange/src/virt/sgx/ipp-crypto/build/.build
-- CMAKE_SOURCE_DIR ...................... /var/home/berrange/src/virt/sgx/ipp-crypto
-- IPP_CRYPTO_DIR ........................ /var/home/berrange/src/virt/sgx/ipp-crypto
-- CMAKE_GENERATOR ....................... Unix Makefiles
-- CMAKE_C_COMPILER_ID ................... GNU
-- CMAKE_CXX_COMPILER_ID ................. GNU
-- IPP_CRYPTO_INCLUDE_DIR ................ /var/home/berrange/src/virt/sgx/ipp-crypto/include
-- IPP_CRYPTO_SOURCES_INCLUDE_DIR ........ /var/home/berrange/src/virt/sgx/ipp-crypto/sources/include
-- IPP_CRYPTO_SOURCES_DIR ................ /var/home/berrange/src/virt/sgx/ipp-crypto/sources/ippcp
-- ARCH .................................. intel64
-- DYNAMIC_LIB ........................... ON
-- CMAKE_INSTALL_PREFIX .................. /var/home/berrange/intel/ippcp_1.0.0
-- PYTHON_VERSION_STRING ................. 3.12.5
-- MERGED_BLD ............................ on
-- BUILD_EXAMPLES ........................ off
-- BUILD_WITH_SANITIZERS ................. off - use -DBUILD_WITH_SANITIZERS=[memory,address,undefined] with CLANG compiler to enable this option
-- Using compiler options from ........... /var/home/berrange/src/virt/sgx/ipp-crypto/sources/cmake/linux/GNU8.2.0.cmake
-- The ASM_NASM compiler identification is NASM
-- Found assembler: /usr/bin/nasm
-- ASM compiler version .................. /usr/bin/nasm
-- ASM object format ..................... elf64
-- CMAKE_BUILD_TYPE is not set to Debug explicitly, defaulting to Release
-- Found OpenSSL: /usr/lib64/libcrypto.so (found suitable version "3.2.2", minimum required is "3.0.8")  
-- Configuring done (2.1s)
-- Generating done (0.5s)
-- Build files have been written to: /var/home/berrange/src/virt/sgx/ipp-crypto/build

$ make -j 20
...snip...

[ 61%] Building ASM_NASM object sources/ippcp/CMakeFiles/ippcp_s_l9-asmobjs.dir/__/__/asm_sources/l9/asm_intel64/l9_pcpsm3l9_ni_as.asm.o
/var/home/berrange/src/virt/sgx/ipp-crypto/build/asm_sources/l9/asm_intel64/l9_pcpsm3l9_ni_as.asm:143: error: parser: instruction expected
/var/home/berrange/src/virt/sgx/ipp-crypto/build/asm_sources/l9/asm_intel64/l9_pcpsm3l9_ni_as.asm:61: ... from macro `SM3MSG' defined here
/var/home/berrange/src/virt/sgx/ipp-crypto/build/asm_sources/l9/asm_intel64/l9_pcpsm3l9_ni_as.asm:143: error: parser: instruction expected
/var/home/berrange/src/virt/sgx/ipp-crypto/build/asm_sources/l9/asm_intel64/l9_pcpsm3l9_ni_as.asm:64: ... from macro `SM3MSG' defined here
/var/home/berrange/src/virt/sgx/ipp-crypto/build/asm_sources/l9/asm_intel64/l9_pcpsm3l9_ni_as.asm:144: error: parser: instruction expected
/var/home/berrange/src/virt/sgx/ipp-crypto/build/asm_sources/l9/asm_intel64/l9_pcpsm3l9_ni_as.asm:81: ... from macro `SM3ROUNDS4' defined here
/var/home/berrange/src/virt/sgx/ipp-crypto/build/asm_sources/l9/asm_intel64/l9_pcpsm3l9_ni_as.asm:144: error: label `vsm3rnds2' inconsistently redefined
/var/home/berrange/src/virt/sgx/ipp-crypto/build/asm_sources/l9/asm_intel64/l9_pcpsm3l9_ni_as.asm:83: ... from macro `SM3ROUNDS4' defined here
/var/home/berrange/src/virt/sgx/ipp-crypto/build/asm_sources/l9/asm_intel64/l9_pcpsm3l9_ni_as.asm:144: info: label `vsm3rnds2' originally defined here
/var/home/berrange/src/virt/sgx/ipp-crypto/build/asm_sources/l9/asm_intel64/l9_pcpsm3l9_ni_as.asm:144: error: parser: instruction expected
/var/home/berrange/src/virt/sgx/ipp-crypto/build/asm_sources/l9/asm_intel64/l9_pcpsm3l9_ni_as.asm:83: ... from macro `SM3ROUNDS4' defined here
/var/home/berrange/src/virt/sgx/ipp-crypto/build/asm_sources/l9/asm_intel64/l9_pcpsm3l9_ni_as.asm:147: error: label `vsm3msg1' inconsistently redefined
/var/home/berrange/src/virt/sgx/ipp-crypto/build/asm_sources/l9/asm_intel64/l9_pcpsm3l9_ni_as.asm:61: ... from macro `SM3MSG' defined here
/var/home/berrange/src/virt/sgx/ipp-crypto/build/asm_sources/l9/asm_intel64/l9_pcpsm3l9_ni_as.asm:147: info: label `vsm3msg1' originally defined here
/var/home/berrange/src/virt/sgx/ipp-crypto/build/asm_sources/l9/asm_intel64/l9_pcpsm3l9_ni_as.asm:147: error: parser: instruction expected
/var/home/berrange/src/virt/sgx/ipp-crypto/build/asm_sources/l9/asm_intel64/l9_pcpsm3l9_ni_as.asm:61: ... from macro `SM3MSG' defined here

This seems to affect these three variants:

asm_sources/l9/asm_intel64/l9_pcpsm3l9_ni_as.asm
asm_sources/k0/asm_intel64/k0_pcpsm3l9_ni_as.asm
asm_sources/k1/asm_intel64/k1_pcpsm3l9_ni_as.asm

I have

$ nasm -v
NASM version 2.16.01 compiled on Jan 25 2024

but I've also seen it hit with NASM 2.15.03, which is ipp-crypto's declared minimum version

paveldyakov commented 1 month ago

Hi @berrange, thank you for reporting the issue. Could you please try to use newer NASM 2.16.02 version? We are preparing the updates for the sources as well as for the required tools.

berrange commented 1 month ago

Hi @berrange, thank you for reporting the issue. Could you please try to use newer NASM 2.16.02 version? We are preparing the updates for the sources as well as for the required tools.

I don't have builds of 2.16.02 available, but the 2.16.03 version from Fedora 41 successfully builds the code.

Bumping the min required NASM to such a new version means ipp-crypto won't be compilable on the majority on Linux distros that are released today, without users building their own NASM :-(

paveldyakov commented 1 month ago

Yes, I understand Unfortunately updating the minimal supported version of NASM is required in case we would like to enable the modern instructions sets