Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[package] cryptopp/8.9.0: Building with MSVC for ARM attempts to compile the intel only file rdrand.asm #26205

Open
alanb-sony opened this issue Dec 16, 2024 · 4 comments · May be fixed by #26208
Assignees
Labels
bug Something isn't working

Comments

@alanb-sony
Copy link

Description

Building for crypto++ for MSVC ARM64 doesn't work when building with ninja without this fix abdes/cryptopp-cmake@1940cc0

Package and Environment Details

  • Package Name/Version: cryptopp/8.9.0
  • Operating System+version: Windows 10
  • Compiler+version: MSVC 19.42.34435.0
  • Conan version: conan 2.10.2
  • Python version: Python 3.11.12

Conan profile

Profile host:
[settings]
arch=armv8
build_type=Debug
compiler=msvc
compiler.cppstd=14
compiler.runtime=dynamic
compiler.runtime_type=Debug
compiler.version=194
os=Windows
[conf]
tools.cmake.cmaketoolchain:generator=Ninja
tools.microsoft.msbuild:vs_version=17

Profile build:
[settings]
arch=x86_64
build_type=Release
compiler=msvc
compiler.cppstd=14
compiler.runtime=dynamic
compiler.runtime_type=Release
compiler.version=194
os=Windows

Steps to reproduce

conan install -r conancenter --requires cryptopp/8.9.0 --settings=arch=armv8 --build=missing --conf=tools.cmake.cmaketoolchain:generator=Ninja

Logs

Click to expand log
======== Input profiles ========
Profile host:
[settings]
arch=armv8
build_type=Release
compiler=msvc
compiler.cppstd=14
compiler.runtime=dynamic
compiler.runtime_type=Release
compiler.version=194
os=Windows
[conf]
tools.cmake.cmaketoolchain:generator=Ninja

Profile build:
[settings]
arch=x86_64
build_type=Release
compiler=msvc
compiler.cppstd=14
compiler.runtime=dynamic
compiler.runtime_type=Release
compiler.version=194
os=Windows


======== Computing dependency graph ========
Graph root
    cli
Requirements
    cryptopp/8.9.0#9a70820db60f71a3a7333fb12f432592 - Cache
Build requirements
    cmake/3.28.1#92f79424d7b65b12a84a2180866c3a78 - Cache
Resolved version ranges
    cmake/[>=3.20 <4]: cmake/3.28.1

======== Computing necessary packages ========
cryptopp/8.9.0: Main binary package '178761a61a8a0d586b569b7f49e5bd91016a50ce' missing
cryptopp/8.9.0: Checking 7 compatible configurations
cryptopp/8.9.0: Compatible configurations not found in cache, checking servers
cryptopp/8.9.0: 'ff8c094faf026bbdd913813c842acbcdaff2368b': compiler.cppstd=17
cryptopp/8.9.0: '219b0d261524d8d26f3f9232bffc8982a87a7668': compiler.cppstd=20
cryptopp/8.9.0: 'b00b87769295d6103f2f0e323519816194ab2e7e': compiler.cppstd=23
cryptopp/8.9.0: '94cb4bb25d64f2598a7dec974b5e13052d7d6b49': compiler.version=193
cryptopp/8.9.0: 'd7a0b98367877dc897e1afd915bef602a8b0c3e6': compiler.cppstd=17, compiler.version=193
cryptopp/8.9.0: 'a9273f7e9ee9fe1726dd9f4cadf0c781fa1d3a61': compiler.cppstd=20, compiler.version=193
cryptopp/8.9.0: 'b00da3f1d5c73a3d7ca6a77ec91a51ba941bfe2e': compiler.cppstd=23, compiler.version=193
Requirements
    cryptopp/8.9.0#9a70820db60f71a3a7333fb12f432592:178761a61a8a0d586b569b7f49e5bd91016a50ce - Build
Build requirements
    cmake/3.28.1#92f79424d7b65b12a84a2180866c3a78:522dcea5982a3f8a5b624c16477e47195da2f84f#29e6903b5006c2b2f81003c9ebf7551b - Cache

======== Installing packages ========
cmake/3.28.1: Already installed! (1 of 2)
cmake/3.28.1: Appending PATH environment variable: C:\Users\gbbirtla\.conan2\p\cmake615d6e26ece18\p\bin

-------- Installing package cryptopp/8.9.0 (2 of 2) --------
cryptopp/8.9.0: Building from source
cryptopp/8.9.0: Package cryptopp/8.9.0:178761a61a8a0d586b569b7f49e5bd91016a50ce
cryptopp/8.9.0: Copying sources to build folder
cryptopp/8.9.0: Building your package in C:\Users\gbbirtla\.conan2\p\b\crypt226a74bbb8c40\b
cryptopp/8.9.0: Calling generate()
cryptopp/8.9.0: Generators folder: C:\Users\gbbirtla\.conan2\p\b\crypt226a74bbb8c40\b\build\Release\generators
cryptopp/8.9.0: CMakeToolchain generated: conan_toolchain.cmake
cryptopp/8.9.0: CMakeToolchain generated: C:\Users\gbbirtla\.conan2\p\b\crypt226a74bbb8c40\b\build\Release\generators\CMakePresets.json
cryptopp/8.9.0: Generating aggregated env files
cryptopp/8.9.0: Generated aggregated env files: ['conanbuild.bat', 'conanrun.bat']
cryptopp/8.9.0: Calling build()
cryptopp/8.9.0: Apply patch (vulnerability): Validate PolynomialMod2 coefficients (CVE-2023-50980)
cryptopp/8.9.0: Running CMake.configure()
cryptopp/8.9.0: RUN: cmake -G "Ninja" -DCMAKE_TOOLCHAIN_FILE="generators/conan_toolchain.cmake" -DCMAKE_INSTALL_PREFIX="C:/Users/gbbirtla/.conan2/p/b/crypt226a74bbb8c40/p" -DCRYPTOPP_SOURCES="C:/Users/gbbirtla/.conan2/p/b/crypt226a74bbb8c40/b/src" -DCRYPTOPP_BUILD_TESTING="OFF" -DCRYPTOPP_BUILD_DOCUMENTATION="OFF" -DCRYPTOPP_USE_INTERMEDIATE_OBJECTS_TARGET="OFF" -DCMAKE_DISABLE_FIND_PACKAGE_Git="ON" -DCMAKE_POLICY_DEFAULT_CMP0091="NEW" -DCMAKE_BUILD_TYPE="Release" "C:/Users/gbbirtla/.conan2/p/b/crypt226a74bbb8c40/b/src/cryptopp-cmake"
conanvcvars.bat: Activating environment Visual Studio 17 - amd64_arm64 - winsdk_version=None - vcvars_ver=14.4
[vcvarsall.bat] Environment initialized for: 'x64_arm64'
-- Using Conan toolchain: C:/Users/gbbirtla/.conan2/p/b/crypt226a74bbb8c40/b/build/Release/generators/conan_toolchain.cmake
-- Conan toolchain: Setting CMAKE_MSVC_RUNTIME_LIBRARY=$<$<CONFIG:Release>:MultiThreadedDLL>
-- Conan toolchain: C++ Standard 14 with extensions OFF
-- Conan toolchain: Setting BUILD_SHARED_LIBS = OFF
-- The CXX compiler identification is MSVC 19.42.34435.0
-- The C compiler identification is MSVC 19.42.34435.0
-- The ASM compiler identification is MSVC
-- Found assembler: C:/Program Files/Microsoft Visual Studio/2022/Professional/VC/Tools/MSVC/14.42.34433/bin/Hostx64/arm64/cl.exe
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Check for working CXX compiler: C:/Program Files/Microsoft Visual Studio/2022/Professional/VC/Tools/MSVC/14.42.34433/bin/Hostx64/arm64/cl.exe - skipped
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Check for working C compiler: C:/Program Files/Microsoft Visual Studio/2022/Professional/VC/Tools/MSVC/14.42.34433/bin/Hostx64/arm64/cl.exe - skipped
-- Detecting C compile features
-- Detecting C compile features - done
=> Project : cryptopp-cmake v8.9.0
-- Crypto++ from user-specified location at: C:/Users/gbbirtla/.conan2/p/b/crypt226a74bbb8c40/b/src
-- Using branch master for tests
=> Module : cryptopp
-- [cryptopp] CMake version 3.28.1
-- [cryptopp] System Windows
-- [cryptopp] Processor ARM64
-- [cryptopp] CMAKE_HOST_SYSTEM_PROCESSOR : AMD64
-- [cryptopp]      CMAKE_SYSTEM_PROCESSOR : ARM64
-- [cryptopp] Target architecture detected as: arm64 -> CRYPTOPP_ARMV8
-- Looking for C++ include winapifamily.h
-- Looking for C++ include winapifamily.h - found
-- [cryptopp] Performing Test CRYPTOPP_ARM_NEON_HEADER
-- [cryptopp] Performing Test CRYPTOPP_ARM_NEON_HEADER - Success
-- [cryptopp] Performing Test CRYPTOPP_ARM_ACLE_HEADER
-- [cryptopp] Performing Test CRYPTOPP_ARM_ACLE_HEADER - Failed
-- [cryptopp] Performing Test CRYPTOPP_ARM_SIMD
-- [cryptopp] Performing Test CRYPTOPP_ARM_SIMD - Success
-- [cryptopp] Performing Test CRYPTOPP_HAVE_ARM_CRC32
-- [cryptopp] Performing Test CRYPTOPP_HAVE_ARM_CRC32 - Failed
-- [cryptopp] Performing Test CRYPTOPP_HAVE_ARM_AES
-- [cryptopp] Performing Test CRYPTOPP_HAVE_ARM_AES - Success
-- [cryptopp] Performing Test CRYPTOPP_HAVE_ARM_PMULL
-- [cryptopp] Performing Test CRYPTOPP_HAVE_ARM_PMULL - Failed
-- [cryptopp] Performing Test CRYPTOPP_HAVE_ARM_SHA1
-- [cryptopp] Performing Test CRYPTOPP_HAVE_ARM_SHA1 - Success
-- [cryptopp] Performing Test CRYPTOPP_HAVE_ARM_SHA2
-- [cryptopp] Performing Test CRYPTOPP_HAVE_ARM_SHA2 - Success
-- [cryptopp] Performing Test CRYPTOPP_HAVE_ARM_SM3
-- [cryptopp] Performing Test CRYPTOPP_HAVE_ARM_SM3 - Success
-- [cryptopp] Performing Test CRYPTOPP_HAVE_ARM_SHA3
-- [cryptopp] Performing Test CRYPTOPP_HAVE_ARM_SHA3 - Failed
-- [cryptopp] Performing Test CRYPTOPP_HAVE_ARM_SHA512
-- [cryptopp] Performing Test CRYPTOPP_HAVE_ARM_SHA512 - Failed
-- The ASM_MASM compiler identification is unknown
-- Found assembler: ml
-- Performing Test CMAKE_HAVE_LIBC_PTHREAD
-- Performing Test CMAKE_HAVE_LIBC_PTHREAD - Failed
-- Looking for pthread_create in pthreads
-- Looking for pthread_create in pthreads - not found
-- Looking for pthread_create in pthread
-- Looking for pthread_create in pthread - not found
-- Found Threads: TRUE
-- [cryptopp] Generating cmake package config files
-- [cryptopp] Generating pkgconfig files
-- [cryptopp] Platform: ARMv8
-- [cryptopp] Compiler definitions:  CRYPTOPP_ARM_NEON_HEADER=1;CRYPTOPP_DISABLE_ARM_CRC32=1;CRYPTOPP_DISABLE_ARM_PMULL=1
-- [cryptopp] Compiler options: /DWIN32 /D_WINDOWS /EHsc  /FIwinapifamily.h;/GR;/MP;/EHsc
-- [cryptopp] Build type: Release
-- Configuring done (24.7s)
-- Generating done (0.1s)
-- Build files have been written to: C:/Users/gbbirtla/.conan2/p/b/crypt226a74bbb8c40/b/build/Release

cryptopp/8.9.0: Running CMake.build()
cryptopp/8.9.0: RUN: cmake --build "C:\Users\gbbirtla\.conan2\p\b\crypt226a74bbb8c40\b\build\Release" -- -j8
conanvcvars.bat: Activating environment Visual Studio 17 - amd64_arm64 - winsdk_version=None - vcvars_ver=14.4
[vcvarsall.bat] Environment initialized for: 'x64_arm64'
[1/180] Building ASM_MASM object cryptopp\CMakeFiles\cryptopp.dir\C_\Users\gbbirtla\.conan2\p\b\crypt226a74bbb8c40\b\src\rdrand.asm.obj
FAILED: cryptopp/CMakeFiles/cryptopp.dir/C_/Users/gbbirtla/.conan2/p/b/crypt226a74bbb8c40/b/src/rdrand.asm.obj
ml -D_M_X64 -IC:\Users\gbbirtla\.conan2\p\b\crypt226a74bbb8c40\b\src -IC:\Users\gbbirtla\.conan2\p\b\crypt226a74bbb8c40\b  -c -Fo cryptopp\CMakeFiles\cryptopp.dir\C_\Users\gbbirtla\.conan2\p\b\crypt226a74bbb8c40\b\src\rdrand.asm.obj C:\Users\gbbirtla\.conan2\p\b\crypt226a74bbb8c40\b\src\rdrand.asm
CreateProcess failed: The system cannot find the file specified.
[2/180] Building ASM_MASM object cryptopp\CMakeFiles\cryptopp.dir\C_\Users\gbbirtla\.conan2\p\b\crypt226a74bbb8c40\b\src\rdseed.asm.obj
FAILED: cryptopp/CMakeFiles/cryptopp.dir/C_/Users/gbbirtla/.conan2/p/b/crypt226a74bbb8c40/b/src/rdseed.asm.obj
ml -D_M_X64 -IC:\Users\gbbirtla\.conan2\p\b\crypt226a74bbb8c40\b\src -IC:\Users\gbbirtla\.conan2\p\b\crypt226a74bbb8c40\b  -c -Fo cryptopp\CMakeFiles\cryptopp.dir\C_\Users\gbbirtla\.conan2\p\b\crypt226a74bbb8c40\b\src\rdseed.asm.obj C:\Users\gbbirtla\.conan2\p\b\crypt226a74bbb8c40\b\src\rdseed.asm
CreateProcess failed: The system cannot find the file specified.
[3/180] Building ASM_MASM object cryptopp\CMakeFiles\cryptopp.dir\C_\Users\gbbirtla\.conan2\p\b\crypt226a74bbb8c40\b\src\x64dll.asm.obj
FAILED: cryptopp/CMakeFiles/cryptopp.dir/C_/Users/gbbirtla/.conan2/p/b/crypt226a74bbb8c40/b/src/x64dll.asm.obj
ml -D_M_X64 -IC:\Users\gbbirtla\.conan2\p\b\crypt226a74bbb8c40\b\src -IC:\Users\gbbirtla\.conan2\p\b\crypt226a74bbb8c40\b  -c -Fo cryptopp\CMakeFiles\cryptopp.dir\C_\Users\gbbirtla\.conan2\p\b\crypt226a74bbb8c40\b\src\x64dll.asm.obj C:\Users\gbbirtla\.conan2\p\b\crypt226a74bbb8c40\b\src\x64dll.asm
CreateProcess failed: The system cannot find the file specified.
[4/180] Building ASM_MASM object cryptopp\CMakeFiles\cryptopp.dir\C_\Users\gbbirtla\.conan2\p\b\crypt226a74bbb8c40\b\src\x64masm.asm.objninja: fatal: ReadFile: The handle is invalid.


FAILED: cryptopp/CMakeFiles/cryptopp.dir/C_/Users/gbbirtla/.conan2/p/b/crypt226a74bbb8c40/b/src/x64masm.asm.obj
ml -D_M_X64 -IC:\Users\gbbirtla\.conan2\p\b\crypt226a74bbb8c40\b\src -IC:\Users\gbbirtla\.conan2\p\b\crypt226a74bbb8c40\b  -c -Fo cryptopp\CMakeFiles\cryptopp.dir\C_\Users\gbbirtla\.conan2\p\b\crypt226a74bbb8c40\b\src\x64masm.asm.obj C:\Users\gbbirtla\.conan2\p\b\crypt226a74bbb8c40\b\src\x64masm.asm
CreateProcess failed: The system cannot find the file specified.

cryptopp/8.9.0: ERROR:
Package '178761a61a8a0d586b569b7f49e5bd91016a50ce' build failed
cryptopp/8.9.0: WARN: Build folder C:\Users\gbbirtla\.conan2\p\b\crypt226a74bbb8c40\b\build\Release
ERROR: cryptopp/8.9.0: Error in build() method, line 132
        cmake.build()
        ConanException: Error 1 while executing
@alanb-sony alanb-sony added the bug Something isn't working label Dec 16, 2024
@AbrilRBS
Copy link
Member

Hi @alanb-sony thanks a lot for taking the time to report this issue.

I can confirm that I'm able to reproduce this locally, but unfortunately, even after patching it, I face a different error:

  • CMakeLists contains:
check_compile_link_option(
  "-DCRYPTOPP_ARM_ACLE_HEADER=1 -march=armv8-a"   CRYPTOPP_ARM_ACLE_HEADER
  "${TEST_PROG_DIR}/test_arm_acle_header.cpp"
)
if(CRYPTOPP_ARM_ACLE_HEADER)
    list(APPEND CRYPTOPP_COMPILE_DEFINITIONS "CRYPTOPP_ARM_ACLE_HEADER=1")
endif()
  • So CRYPTOPP_ARM_ACLE_HEADER is not defined in my case, but then config_asm.h has
#if !defined(CRYPTOPP_ARM_ACLE_HEADER)
# if defined(__aarch32__) || defined(__aarch64__) || (__ARM_ARCH >= 8) || defined(__ARM_ACLE)
#  define CRYPTOPP_ARM_ACLE_HEADER 1
# endif
#endif

which, by having a totally different logic, means CRYPTOPP_ARM_ACLE_HEADER gets set to 1, thus trying to use a header in blake2b_simd.cpp that does not exist, makes the compilation fail with:

[21/176] Building CXX object cryptopp\CMakeFiles\cryptopp.dir\C_\Users\abril\.conan2\p\b\crypt36ec2e96c4c55\b\src\blake2s_simd.cpp.obj
FAILED: cryptopp/CMakeFiles/cryptopp.dir/C_/Users/abril/.conan2/p/b/crypt36ec2e96c4c55/b/src/blake2s_simd.cpp.obj
C:\PROGRA~1\MICROS~1\2022\COMMUN~1\VC\Tools\MSVC\1441~1.341\bin\HOSTAR~1\arm64\cl.exe  /nologo /TP -DCRYPTOPP_ARM_NEON_HEADER=1 -DCRYPTOPP_DISABLE_ARM_CRC32=1 -DCRYPTOPP_DISABLE_ARM_PMULL=1 -D_WIN32_WINNT=0x0A00 -IC:\Users\abril\.conan2\p\b\crypt36ec2e96c4c55\b\src -IC:\Users\abril\.conan2\p\b\crypt36ec2e96c4c55\b /DWIN32 /D_WINDOWS /EHsc /O2 /Ob2 /DNDEBUG -std:c++14 -MD -march=armv8-a /FIwinapifamily.h /GR /MP /showIncludes /Focryptopp\CMakeFiles\cryptopp.dir\C_\Users\abril\.conan2\p\b\crypt36ec2e96c4c55\b\src\blake2s_simd.cpp.obj /Fdcryptopp\CMakeFiles\cryptopp.dir\cryptopp.pdb /FS -c C:\Users\abril\.conan2\p\b\crypt36ec2e96c4c55\b\src\blake2s_simd.cpp
cl : Línea de comandos warning D9002 : se omite la opción desconocida '-march=armv8-a'
C:\Users\abril\.conan2\p\b\crypt36ec2e96c4c55\b\src\blake2s_simd.cpp(64): fatal error C1083: No se puede abrir el archivo incluir: 'arm_acle.h': No such file or directory

Is this something you also see on your end?

Nevertheless, if I force this to false instead, I get a clean compilation on arm64, and as this seems like an unrelated issue we might want to report to https://github.com/abdes/cryptopp-cmake, I'll open a PR to address your reported issue, and we can track the other in a follow-up issue :)

Thanks again for taking the time to report the issue!

@AbrilRBS AbrilRBS linked a pull request Dec 16, 2024 that will close this issue
@alanb-sony
Copy link
Author

alanb-sony commented Dec 17, 2024

ah, yes, I forgot to raise that one with them, I'll do that now. My fix was to define CRYPTOPP_ARM_NEON_HEADER=1 and CRYPTOPP_ARM_ACLE_HEADER=0 for MSVC abdes/cryptopp-cmake#127

@alanb-sony
Copy link
Author

The fix for the ACLE header has been committed uptream abdes/cryptopp-cmake@00a151f

@AbrilRBS
Copy link
Member

AbrilRBS commented Dec 19, 2024

Added to #26208, thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants