Visual Studio build error - e_chacha20poly1305.c
Hi, I'd like to use your fork of OpenSSL for an SSL scanner I'm working on, but I'm getting a build error when targeting Windows 32 bits with Visual Studio (for 1.0.2-chacha):
Configuring for VC-WIN32
no-asm [option] OPENSSL_NO_ASM
no-ec_nistp_64_gcc_128 [default] OPENSSL_NO_EC_NISTP_64_GCC_128 (skip dir)
no-gmp [default] OPENSSL_NO_GMP (skip dir)
no-jpake [experimental] OPENSSL_NO_JPAKE (skip dir)
no-krb5 [krb5-flavor not specified] OPENSSL_NO_KRB5
no-libunbound [experimental] OPENSSL_NO_LIBUNBOUND (skip dir)
no-rfc3779 [default] OPENSSL_NO_RFC3779 (skip dir)
no-sctp [default] OPENSSL_NO_SCTP (skip dir)
no-shared [option]
no-ssl-trace [default] OPENSSL_NO_SSL_TRACE (skip dir)
no-store [experimental] OPENSSL_NO_STORE (skip dir)
no-unit-test [default] OPENSSL_NO_UNIT_TEST (skip dir)
no-zlib-dynamic [option]
IsMK1MF=1
CC =cl
CFLAG =-DZLIB -DOPENSSL_THREADS -DDSO_WIN32 -DZLIB_WINAPI -W3 -Gs0 -GF -Gy -nologo -DOPENSSL_SYSNAME_WIN32 -DWIN32_LEAN_AND_
ECATE
EX_LIBS = -LC:\Users\user\Documents\builds\nassl32\bin\zlib\win32 -lz
CPUID_OBJ =mem_clr.o
BN_ASM =bn_asm.o
EC_ASM =
DES_ENC =des_enc.o fcrypt_b.o
AES_ENC =aes_core.o aes_cbc.o
BF_ENC =bf_enc.o
CAST_ENC =c_enc.o
RC4_ENC =rc4_enc.o rc4_skey.o
CHACHA_ENC =chacha_enc.o
POLY1305 =poly1305.o
RC5_ENC =rc5_enc.o
MD5_OBJ_ASM =
SHA1_OBJ_ASM =
RMD160_OBJ_ASM=
CMLL_ENC =camellia.o cmll_misc.o cmll_cbc.o
MODES_OBJ =
ENGINES_OBJ =
PROCESSOR =
RANLIB =true
ARFLAGS =
PERL =perl
THIRTY_TWO_BIT mode
BN_LLONG mode
RC4_INDEX mode
RC4_CHUNK is undefined
Configured for VC-WIN32.
C:\Users\user\Documents\builds\nassl32\openssl>perl util\mkfiles.pl 1>MINFO
C:\Users\user\Documents\builds\nassl32\openssl>perl util\mk1mf.pl no-asm VC-WIN32 1>ms\nt.mak
C:\Users\user\Documents\builds\nassl32\openssl>perl util\mk1mf.pl dll no-asm VC-WIN32 1>ms\ntdll.mak
C:\Users\user\Documents\builds\nassl32\openssl>if x == x goto skipce
C:\Users\user\Documents\builds\nassl32\openssl>perl util\mkdef.pl 32 libeay 1>ms\libeay32.def
C:\Users\user\Documents\builds\nassl32\openssl>perl util\mkdef.pl 32 ssleay 1>ms\ssleay32.def
Microsoft (R) Program Maintenance Utility Version 9.00.21022.08
Copyright (C) Microsoft Corporation. All rights reserved.
Building OpenSSL
perl .\util\copy-if-different.pl ".\crypto\buildinf.h" "tmp32\buildinf.h"
Copying: ./crypto/buildinf.h to tmp32/buildinf.h
perl .\util\copy-if-different.pl ".\crypto\opensslconf.h" "inc32\openssl\opensslconf.h"
Copying: ./crypto/opensslconf.h to inc32/openssl/opensslconf.h
cl /Fotmp32\e_chacha20poly1305.obj -Iinc32 -Itmp32 -DZLIB_WINAPI /MT /Ox /O2 /Ob2 -DZLIB -DOPENSSL_THREADS -DDSO_WIN32 -DZ
DOPENSSL_SYSNAME_WIN32 -DWIN32_LEAN_AND_MEAN -DL_ENDIAN -D_CRT_SECURE_NO_DEPRECATE -DOPENSSL_NO_KRB5 -DOPENSSL_NO_JPAKE -DZLIB -DOPEN
r\Documents\builds\nassl32\zlib-1.2.8 /Zl /Zi /Fdtmp32/lib -c .\crypto\evp\e_chacha20poly1305.c
e_chacha20poly1305.c
.\crypto\evp\e_chacha20poly1305.c(51) : fatal error C1083: Cannot open include file: 'stdint.h': No such file or directory
NMAKE : fatal error U1077: '"C:\Program Files (x86)\Microsoft Visual Studio 9.0\VC\BIN\cl.EXE"' : return code '0x2'
Stop.
It looks like stdint.h does not exist within Visual Studio, but I do not know how OpenSSL usually handles this. Is there a tag or commit that is known to build fine with Visual Studio ? Thanks!
Hi @nabla-c0d3 , are you using the most recent version ? There was a change around a week ago (?) which improved the build process for VS ?
Yes I did; the line causing the problem is this one: https://github.com/PeterMosmans/openssl/blob/1.0.2-chacha/crypto/evp/e_chacha20poly1305.c#L51 For various reasons I have to use Visual Studio 9.0, which doesn't have stdint.h (it was added to VS 10.0). However, the official OpenSSL 1.0.2 builds fine with it. Thanks!
Could you check whether you can compile with either a 'standard' stdint.h (see e.g. http://msinttypes.googlecode.com/svn/trunk/stdint.h ), or monkey-patch the offending lines like this ? These are probably the only types necessary...
#if (_MSC_VER == 1500)
typedef __int32 int32_t;
typedef unsigned __int32 uint32_t;
typedef __int64 int64_t;
typedef unsigned __int64 uint64_t;
#else
#include <stdint.h>
#endif
If it works, I'll patch the 'official' version. Thanks in advance
I got 32 bits builds to work (and will open a pull request) but it's still failing for Windows 64 bits:
Building OpenSSL
perl .\util\copy-if-different.pl ".\crypto\buildinf.h" "tmp32\buildinf.h"
Copying: ./crypto/buildinf.h to tmp32/buildinf.h
perl .\util\copy-if-different.pl ".\crypto\opensslconf.h" "inc32\openssl\opensslconf.h"
NOT copying: ./crypto/opensslconf.h to inc32/openssl/opensslconf.h
cl /Fotmp32\chacha_vec.obj -Iinc32 -Itmp32 -DZLIB_WINAPI /MT /Ox -DZLIB -DOPENSSL_THREADS -DDSO_WIN32 -DZLIB_
WINAPI -W3 -Gs0 -Gy -nologo -DOPENSSL_SYSNAME_WIN32 -DWIN32_LEAN_AND_MEAN -DL_ENDIAN -DUNICODE -D_UNICODE -D_CRT_SECURE_
NO_DEPRECATE -DOPENSSL_IA32_SSE2 -DOPENSSL_BN_ASM_MONT -DOPENSSL_BN_ASM_MONT5 -DOPENSSL_BN_ASM_GF2m -DSHA1_ASM -DSHA256_
ASM -DSHA512_ASM -DMD5_ASM -DAES_ASM -DVPAES_ASM -DBSAES_ASM -DWHIRLPOOL_ASM -DGHASH_ASM -DECP_NISTZ256_ASM -DOPENSSL_NO
_KRB5 -DOPENSSL_NO_JPAKE -DZLIB -DOPENSSL_NO_DYNAMIC_ENGINE -IC:\Users\user\Documents\builds\nassl64\zlib-1.2.8 /Zl /Zi
/Fdtmp32/lib -c .\crypto\chacha\chacha_vec.c
chacha_vec.c
.\crypto\chacha\chacha_vec.c(74) : error C2061: syntax error : identifier '__attribute__'
.\crypto\chacha\chacha_vec.c(74) : error C2059: syntax error : ';'
.\crypto\chacha\chacha_vec.c(74) : error C2143: syntax error : missing ')' before 'constant'
.\crypto\chacha\chacha_vec.c(74) : error C2143: syntax error : missing ')' before 'constant'
.\crypto\chacha\chacha_vec.c(127) : fatal error C1189: #error : -- Implementation supports only machines with neon or S
SE2
NMAKE : fatal error U1077: '"C:\Program Files (x86)\Microsoft Visual Studio 9.0\VC\BIN\amd64\cl.EXE"' : return code '0x2
'
Stop.
I can get rid of the __attribute__ syntax error using a #define but not sure what to do about the fatal error.
Hmm, the current ChaCha implementation needs either ARM neon or SSE2 extensions. On what type of (processor) architecture are you building ? SSE2 should be 'fairly common' since 2003 ?
The usual Windows 7 64 bits VM. I think the giant #if / #else in this file is just wrong or missing a case for win64?
I looked at what's on the OpenSSL 1.1.0 branch but that file is gone there.
Yeah, that's the reason this fork is created :wink: - Weird, as it compiles perfect on Windows/MSYS , and with newer Visual Studios. I'll look into it later this week, thanks for troubleshooting so far
Issue closed for x86, still open for x64
Hello Peter,
Have you made any headway on the x64 build? I am still getting this issue with both VS2012 and VS2015. I have no issue building x86 but the x64 build will fail.
Hi @irakhlin - openssl-1.0.2 compiles successfully on msys2 / mingw(64) on Windows. Today I added continuous integation using Appveyor to check other platforms (VS2012 / 2015 / ...) - see https://ci.appveyor.com/project/PeterMosmans/openssl/build/1.0.2
So now I can finally reproduce your issues.. stay tuned !
Thank you for the prompt reply! I can indeed build x86/x64 versions using both msys2 and mingw64 without any issue. I am building with VS2012/2015 because I am hoping to use the built library files to link for http://tomcat.apache.org/native-doc (tomcat-native) to run in a windows native version of tomcat. I have been able to do this thus far with Linux x86/x64 and windows x86. The result seems to be a working version of tomcat w/ chacha ciphers!
If you need any help testing please let me know.
Ouch, the MSVS compiler doesn't support the __attribute__ syntax. I fiddled around, but this isn't easy to rewrite. Allow me some more time to look further into it..