Closed
Description
When attempting to build the recent 1.1.1t release sources from scratch using Visual Studio (In my example: VS 2019) under 32-bit, I'm getting the following build error:
[INFO] libcrypto-1_1.lib(rsa_sup_mul.obj) : error LNK2019: unresolved external symbol __umul128 referenced in function __mul_limb [XXX\win32-x86-vc142\apps\openssl.vcxproj]
[INFO] XXX\bin\openssl\win32-x86-vc142\Debug\openssl.exe : fatal error LNK1120: 1 unresolved externals [XXX\win32-x86-vc142\apps\openssl.vcxproj]
[INFO] ExitValue: 1
The root of the problem becomes more evident by the following preceding warning:
[INFO] XXX\src\crypto\bn\rsa_sup_mul.c(114,9): warning C4163: '_umul128': not available as an intrinsic function [XXX\win32-x86-vc142\crypto\crypto.vcxproj]
So, it seems that the existing preprocessor conditional in line 112 of /crypto/bn/rsa_sup_mul.c,
#elif (BN_BYTES == 8) && (defined _MSC_VER)
is insufficient to be entered for a 32-bit build and according to the referred to Microsoft documentation https://learn.microsoft.com/en-us/cpp/intrinsics/umul128?view=msvc-170 the _umul128
intrinsic is only on 64-bit available. I got the build fixed by extending the conditional to
#elif (BN_BYTES == 8) && (defined _MSC_VER) && defined(_WIN64)
which solved the problem.
I'm prepared to make a corresponding PULL request, if the direction of the fix seems plausible.