Error compiling on `aarch64-pc-windows-msvc`
Hi,
Thanks for the library, I am having trouble compiling ring:0.16.20 on Windows (I don't usually use windows so this is all very new to me).
I have followed the instructions in BUILDING.md and I think I have installed all the right libraries (VSCode 2022 with the C++ Development workflow and MSVC v142 - VS 2019 C++ ARM64 build tools) but it is quite likely I am missing something.
error: failed to run custom build command for `ring v0.16.20`
Caused by:
process didn't exit successfully: `Y:\git\desktop\target\debug\build\ring-26b79f943f484e4c\build-script-build` (exit code: 101)
--- stdout
OPT_LEVEL = Some("0")
TARGET = Some("aarch64-pc-windows-msvc")
HOST = Some("x86_64-pc-windows-msvc")
CC_aarch64-pc-windows-msvc = None
CC_aarch64_pc_windows_msvc = None
TARGET_CC = None
CC = None
CFLAGS_aarch64-pc-windows-msvc = None
CFLAGS_aarch64_pc_windows_msvc = None
TARGET_CFLAGS = None
CFLAGS = None
CRATE_CC_NO_DEFAULTS = None
CARGO_CFG_TARGET_FEATURE = None
DEBUG = Some("true")
montgomery.c
C:\Users\muji\.cargo\registry\src\github.com-1ecc6299db9ec823\ring-0.16.20\crypto\fipsmodule\bn\internal.h(191): error C2065: 'BN_ULLONG': undeclared identifier
C:\Users\muji\.cargo\registry\src\github.com-1ecc6299db9ec823\ring-0.16.20\crypto\fipsmodule\bn\internal.h(191): error C2146: syntax error: missing ';' before identifier 'result'
C:\Users\muji\.cargo\registry\src\github.com-1ecc6299db9ec823\ring-0.16.20\crypto\fipsmodule\bn\internal.h(191): warning C4555: result of expression not used
C:\Users\muji\.cargo\registry\src\github.com-1ecc6299db9ec823\ring-0.16.20\crypto\fipsmodule\bn\internal.h(191): error C2065: 'result': undeclared identifier
C:\Users\muji\.cargo\registry\src\github.com-1ecc6299db9ec823\ring-0.16.20\crypto\fipsmodule\bn\internal.h(191): error C2146: syntax error: missing ';' before identifier 'a'
C:\Users\muji\.cargo\registry\src\github.com-1ecc6299db9ec823\ring-0.16.20\crypto\fipsmodule\bn\internal.h(191): warning C4552: '*': result of expression not used
C:\Users\muji\.cargo\registry\src\github.com-1ecc6299db9ec823\ring-0.16.20\crypto\fipsmodule\bn\internal.h(192): error C2065: 'result': undeclared identifier
C:\Users\muji\.cargo\registry\src\github.com-1ecc6299db9ec823\ring-0.16.20\crypto\fipsmodule\bn\internal.h(193): error C2065: 'result': undeclared identifier
C:\Users\muji\.cargo\registry\src\github.com-1ecc6299db9ec823\ring-0.16.20\crypto\fipsmodule\bn\internal.h(193): warning C4293: '>>': shift count negative or too big, undefined behavior
C:\Users\muji\.cargo\registry\src\github.com-1ecc6299db9ec823\ring-0.16.20\crypto\fipsmodule\bn\../../limbs/limbs.inl(38): warning C4163: '_addcarry_u64': not available as an intrinsic function
C:\Users\muji\.cargo\registry\src\github.com-1ecc6299db9ec823\ring-0.16.20\crypto\fipsmodule\bn\../../limbs/limbs.inl(38): warning C4163: '_subborrow_u64': not available as an intrinsic function
C:\Users\muji\.cargo\registry\src\github.com-1ecc6299db9ec823\ring-0.16.20\crypto\fipsmodule\bn\../../limbs/limbs.inl(62): warning C4013: '_addcarry_u64' undefined; assuming extern returning int
C:\Users\muji\.cargo\registry\src\github.com-1ecc6299db9ec823\ring-0.16.20\crypto\fipsmodule\bn\../../limbs/limbs.inl(62): warning C4242: '=': conversion from 'int' to 'Carry', possible loss of data
C:\Users\muji\.cargo\registry\src\github.com-1ecc6299db9ec823\ring-0.16.20\crypto\fipsmodule\bn\../../limbs/limbs.inl(76): warning C4242: '=': conversion from 'int' to 'Carry', possible loss of data
C:\Users\muji\.cargo\registry\src\github.com-1ecc6299db9ec823\ring-0.16.20\crypto\fipsmodule\bn\../../limbs/limbs.inl(92): warning C4013: '_subborrow_u64' undefined; assuming extern returning int
C:\Users\muji\.cargo\registry\src\github.com-1ecc6299db9ec823\ring-0.16.20\crypto\fipsmodule\bn\../../limbs/limbs.inl(92): warning C4242: '=': conversion from 'int' to 'Carry', possible loss of data
C:\Users\muji\.cargo\registry\src\github.com-1ecc6299db9ec823\ring-0.16.20\crypto\fipsmodule\bn\../../limbs/limbs.inl(106): warning C4242: '=': conversion from 'int' to 'Carry', possible loss of data
--- stderr
running "C:\\Program Files\\Microsoft Visual Studio\\2022\\Community\\VC\\Tools\\MSVC\\14.30.30705\\bin\\HostX64\\arm64\\cl.exe" "-nologo" "-MD" "-Z7" "-Brepro" "-I" "include" "-W4" "/GS" "/Gy" "/EHsc" "/GR-" "/Zc:wchar_t" "/Zc:forScope" "/Zc:inline" "/Zc:rvalueCast" "/sdl" "/Wall" "/wd4127" "/wd4464" "/wd4514" "/wd4710" "/wd4711" "/wd4820" "/wd5045" "/Od" "/RTCsu" "-DNDEBUG" "-c" "/FoY:\\git\\desktop\\target\\aarch64-pc-windows-msvc\\debug\\build\\ring-9fa65205694170bf\\out\\montgomery.obj" "crypto/fipsmodule/bn/montgomery.c"
thread 'main' panicked at 'execution failed', C:\Users\muji\.cargo\registry\src\github.com-1ecc6299db9ec823\ring-0.16.20\build.rs:656:9
I am note sure why rust thinks the host is x86_64 (HOST = Some("x86_64-pc-windows-msvc")) when I check the architecture:
wmic os get OSArchitecture
I get:
OSArchitecture
ARM 64-bit Processor
FYI, I am running Windows 11 on an M1 via Parallels but I don't know if that is relevant.
Any pointers would be much appreciated 🙏
Running into the same issues.
Alright, this was partially a matter of RTFM for me.
Documentations shows you need to set TARGET_CC for cross compile, it also says it uses clang. So it should be worth noting you need clang-cl as your TARGET_CC to cross compile.
However...
There is a bug in the build.rs for 16.20 that causes the compile to fail anyway. This is fixed in the 0.17.0-alpha.11.
Of course, it's alpha... hopefully a full 0.17 will be released.
Thanks! I am going to close this since it seems to be resolved. I'm hoping to make the cross-compiling "just work" in the near future.