libressl/portable

LibreSSL 3.8.3 fails to build with `syntax error: _CET_ENDBR` (Windows, MSVC, x64)

Closed this issue · 7 comments

LDVG commented

When attempting to build stable release 3.8.3 (extracted from the release tarball) for Windows (MSVC, x64), I end up with syntax errors relating to _CET_ENDBR:

libressl-3.8.3\crypto\aes\aes-masm-x86_64.S(94): error A2008: syntax error : _CET_ENDBR
... more similar errors ...
Complete configure and build logs
$ cmake -Bbuild -A x64
-- Building for: Visual Studio 17 2022
-- Selecting Windows SDK version 10.0.22000.0 to target Windows 10.0.22631.
-- The C compiler identification is MSVC 19.39.33521.0
-- The ASM compiler identification is MSVC
-- Found assembler: C:/Program Files/Microsoft Visual Studio/2022/Community/VC/Tools/MSVC/14.39.33519/bin/Hostx64/x64/cl.exe
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Check for working C compiler: C:/Program Files/Microsoft Visual Studio/2022/Community/VC/Tools/MSVC/14.39.33519/bin/Hostx64/x64/cl.exe - skipped
-- Detecting C compile features
-- Detecting C compile features - done
-- Using [MSVC] compiler
-- Looking for asprintf
-- Looking for asprintf - not found
-- Looking for getopt
-- Looking for getopt - not found
-- Looking for reallocarray
-- Looking for reallocarray - not found
-- Looking for strcasecmp
-- Looking for strcasecmp - not found
-- Looking for strlcat
-- Looking for strlcat - not found
-- Looking for strlcpy
-- Looking for strlcpy - not found
-- Looking for strndup
-- Looking for strndup - not found
-- Looking for strsep
-- Looking for strsep - not found
-- Looking for strtonum
-- Looking for strtonum - not found
-- Looking for timegm
-- Looking for timegm - not found
-- Looking for arc4random_buf
-- Looking for arc4random_buf - not found
-- Looking for arc4random_uniform
-- Looking for arc4random_uniform - not found
-- Looking for explicit_bzero
-- Looking for explicit_bzero - not found
-- Looking for getauxval
-- Looking for getauxval - not found
-- Looking for getentropy
-- Looking for getentropy - not found
-- Looking for getpagesize
-- Looking for getpagesize - not found
-- Looking for getprogname
-- Looking for getprogname - not found
-- Looking for syslog_r
-- Looking for syslog_r - not found
-- Looking for syslog
-- Looking for syslog - not found
-- Looking for timespecsub
-- Looking for timespecsub - not found
-- Looking for timingsafe_bcmp
-- Looking for timingsafe_bcmp - not found
-- Looking for timingsafe_memcmp
-- Looking for timingsafe_memcmp - not found
-- Looking for memmem
-- Looking for memmem - not found
-- Looking for include file endian.h
-- Looking for include file endian.h - not found
-- Looking for include file machine/endian.h
-- Looking for include file machine/endian.h - not found
-- Looking for include file err.h
-- Looking for include file err.h - not found
-- Looking for 3 include files sys/types.h, ..., netinet/ip.h
-- Looking for 3 include files sys/types.h, ..., netinet/ip.h - not found
-- The ASM_MASM compiler identification is MSVC
-- Found assembler: C:/Program Files/Microsoft Visual Studio/2022/Community/VC/Tools/MSVC/14.39.33519/bin/Hostx64/x64/ml64.exe
-- Looking for clock_gettime
-- Looking for clock_gettime - not found
-- Looking for sys/types.h
-- Looking for sys/types.h - found
-- Looking for stdint.h
-- Looking for stdint.h - found
-- Looking for stddef.h
-- Looking for stddef.h - found
-- Check size of time_t
-- Check size of time_t - done
-- Looking for pipe2
-- Looking for pipe2 - not found
-- Configuring done (37.2s)
-- Generating done (1.4s)
-- Build files have been written to: C:/Users/ludvig/Desktop/x/libressl-3.8.3/build

$ cmake --build build

MSBuild version 17.9.5+33de0b227 for .NET Framework

  1>Checking Build System
  1>Building Custom Rule C:/Users/ludvig/Desktop/x/libressl-3.8.3/ssl/CMakeLists.txt
  bs_ber.c
  bs_cbb.c
  bs_cbs.c
  bs_obj.vcxproj -> C:\Users\ludvig\Desktop\x\libressl-3.8.3\build\ssl\bs_obj.dir\Debug\bs_obj.lib
  1>Building Custom Rule C:/Users/ludvig/Desktop/x/libressl-3.8.3/crypto/CMakeLists.txt
  Assembling C:\Users\ludvig\Desktop\x\libressl-3.8.3\crypto\aes\aes-masm-x86_64.S...
C:\Users\ludvig\Desktop\x\libressl-3.8.3\crypto\aes\aes-masm-x86_64.S(94): error A2008: syntax error : _CET_ENDBR [C:\Users\ludvig\Desktop\x\libressl-3.8.3\build\crypto\crypto_obj.vcxproj]
C:\Users\ludvig\Desktop\x\libressl-3.8.3\crypto\aes\aes-masm-x86_64.S(248): error A2008: syntax error : _CET_ENDBR [C:\Users\ludvig\Desktop\x\libressl-3.8.3\build\crypto\crypto_obj.vcxproj]
C:\Users\ludvig\Desktop\x\libressl-3.8.3\crypto\aes\aes-masm-x86_64.S(437): error A2008: syntax error : _CET_ENDBR [C:\Users\ludvig\Desktop\x\libressl-3.8.3\build\crypto\crypto_obj.vcxproj]
C:\Users\ludvig\Desktop\x\libressl-3.8.3\crypto\aes\aes-masm-x86_64.S(504): error A2008: syntax error : _CET_ENDBR [C:\Users\ludvig\Desktop\x\libressl-3.8.3\build\crypto\crypto_obj.vcxproj]
C:\Users\ludvig\Desktop\x\libressl-3.8.3\crypto\aes\aes-masm-x86_64.S(660): error A2008: syntax error : _CET_ENDBR [C:\Users\ludvig\Desktop\x\libressl-3.8.3\build\crypto\crypto_obj.vcxproj]
C:\Users\ludvig\Desktop\x\libressl-3.8.3\crypto\aes\aes-masm-x86_64.S(900): error A2008: syntax error : _CET_ENDBR [C:\Users\ludvig\Desktop\x\libressl-3.8.3\build\crypto\crypto_obj.vcxproj]
C:\Users\ludvig\Desktop\x\libressl-3.8.3\crypto\aes\aes-masm-x86_64.S(979): error A2008: syntax error : _CET_ENDBR [C:\Users\ludvig\Desktop\x\libressl-3.8.3\build\crypto\crypto_obj.vcxproj]
C:\Users\ludvig\Desktop\x\libressl-3.8.3\crypto\aes\aes-masm-x86_64.S(1008): error A2008: syntax error : _CET_ENDBR [C:\Users\ludvig\Desktop\x\libressl-3.8.3\build\crypto\crypto_obj.vcxproj]
C:\Users\ludvig\Desktop\x\libressl-3.8.3\crypto\aes\aes-masm-x86_64.S(1258): error A2008: syntax error : _CET_ENDBR [C:\Users\ludvig\Desktop\x\libressl-3.8.3\build\crypto\crypto_obj.vcxproj]
C:\Users\ludvig\Desktop\x\libressl-3.8.3\crypto\aes\aes-masm-x86_64.S(1466): error A2008: syntax error : _CET_ENDBR [C:\Users\ludvig\Desktop\x\libressl-3.8.3\build\crypto\crypto_obj.vcxproj]
C:\Users\ludvig\Desktop\x\libressl-3.8.3\crypto\aes\aes-masm-x86_64.S(2712): error A2008: syntax error : _CET_ENDBR [C:\Users\ludvig\Desktop\x\libressl-3.8.3\build\crypto\crypto_obj.vcxproj]
C:\Users\ludvig\Desktop\x\libressl-3.8.3\crypto\aes\aes-masm-x86_64.S(2771): error A2008: syntax error : _CET_ENDBR [C:\Users\ludvig\Desktop\x\libressl-3.8.3\build\crypto\crypto_obj.vcxproj]
C:\Users\ludvig\Desktop\x\libressl-3.8.3\crypto\aes\aes-masm-x86_64.S(2829): error A2008: syntax error : _CET_ENDBR [C:\Users\ludvig\Desktop\x\libressl-3.8.3\build\crypto\crypto_obj.vcxproj]
C:\Program Files\Microsoft Visual Studio\2022\Community\MSBuild\Microsoft\VC\v170\BuildCustomizations\masm.targets(70,5): error MSB3721: The command "ml64.exe /c /nologo /Fo"crypto_obj.dir\Debug\aes-masm-x86_64.obj" /D"WIN32" /D"_WINDOWS" /D"LIBRESSL_INTERNAL" /D"OPENSSL_NO_HW_PADLOCK" /D"__BEGIN_HIDDEN_DECLS=" /D"__END_HIDDEN_DECLS=" /D"_CRT_SECURE_NO_WARNINGS" /D"_CRT_DEPRECATED_NO_WARNINGS" /D"_REENTRANT" /D"_POSIX_THREAD_SAFE_FUNCTIONS" /D"NO_SYSLOG" /D"WIN32_LEAN_AND_MEAN" /D"_WIN32_WINNT=0x0600" /D"inline=__inline" /D"HAVE_LITTLE_ENDIAN" /D"HAVE_STRNLEN" /D"LIBRESSL_CRYPTO_INTERNAL" /D"endbr64=" /D"AES_ASM" /D"BSAES_ASM" /D"VPAES_ASM" /D"OPENSSL_IA32_SSE2" /D"MD5_ASM" /D"GHASH_ASM" /D"RSA_ASM" /D"SHA1_ASM" /D"SHA256_ASM" /D"SHA512_ASM" /D"WHIRLPOOL_ASM" /D"OPENSSL_CPUID_OBJ" /D"OPENSSLDIR="C:/Windows/libressl/ssl"" /D"CMAKE_INTDIR="Debug"" /I "C:\Users\ludvig\Desktop\x\libressl-3.8.3\crypto\." /I "C:\Users\ludvig\Desktop\x\libressl-3.8.3\crypto\asn1" /I "C:\Users\ludvig\Desktop\x\libressl-3.8.3\crypto\bio" /I "C:\Users\ludvig\Desktop\x\libressl-3.8.3\crypto\bn" /I "C:\Users\ludvig\Desktop\x\libressl-3.8.3\crypto\bytestring" /I "C:\Users\ludvig\Desktop\x\libressl-3.8.3\crypto\dh" /I "C:\Users\ludvig\Desktop\x\libressl-3.8.3\crypto\dsa" /I "C:\Users\ludvig\Desktop\x\libressl-3.8.3\crypto\curve25519" /I "C:\Users\ludvig\Desktop\x\libressl-3.8.3\crypto\ec" /I "C:\Users\ludvig\Desktop\x\libressl-3.8.3\crypto\ecdh" /I "C:\Users\ludvig\Desktop\x\libressl-3.8.3\crypto\ecdsa" /I "C:\Users\ludvig\Desktop\x\libressl-3.8.3\crypto\evp" /I "C:\Users\ludvig\Desktop\x\libressl-3.8.3\crypto\hidden" /I "C:\Users\ludvig\Desktop\x\libressl-3.8.3\crypto\hmac" /I "C:\Users\ludvig\Desktop\x\libressl-3.8.3\crypto\modes" /I "C:\Users\ludvig\Desktop\x\libressl-3.8.3\crypto\ocsp" /I "C:\Users\ludvig\Desktop\x\libressl-3.8.3\crypto\pkcs12" /I "C:\Users\ludvig\Desktop\x\libressl-3.8.3\crypto\rsa" /I "C:\Users\ludvig\Desktop\x\libressl-3.8.3\crypto\sha" /I "C:\Users\ludvig\Desktop\x\libressl-3.8.3\crypto\x509" /I "C:\Users\ludvig\Desktop\x\libressl-3.8.3\crypto\..\include\compat" /I "C:\Users\ludvig\Desktop\x\libressl-3.8.3\crypto\..\include" /I "C:\Users\ludvig\Desktop\x\libressl-3.8.3\build\include" /I "C:\Users\ludvig\Desktop\x\libressl-3.8.3\crypto\bn\arch\amd64" /W3 /errorReport:prompt  /Ta"C:\Users\ludvig\Desktop\x\libressl-3.8.3\crypto\aes\aes-masm-x86_64.S"" exited with code 1. [C:\Users\ludvig\Desktop\x\libressl-3.8.3\build\crypto\crypto_obj.vcxproj]
  1>Building Custom Rule C:/Users/ludvig/Desktop/x/libressl-3.8.3/ssl/CMakeLists.txt
  bio_ssl.c
  d1_both.c
  d1_lib.c
  d1_pkt.c
C:\Users\ludvig\Desktop\x\libressl-3.8.3\ssl\d1_pkt.c(1000,1): warning C4702: unreachable code [C:\Users\ludvig\Desktop\x\libressl-3.8.3\build\ssl\ssl_obj.vcxproj]
  d1_srtp.c
  pqueue.c
  s3_cbc.c
C:\Users\ludvig\Desktop\x\libressl-3.8.3\ssl\s3_cbc.c(464,1): warning C4702: unreachable code [C:\Users\ludvig\Desktop\x\libressl-3.8.3\build\ssl\ssl_obj.vcxproj]
C:\Users\ludvig\Desktop\x\libressl-3.8.3\ssl\s3_cbc.c(465,1): warning C4702: unreachable code [C:\Users\ludvig\Desktop\x\libressl-3.8.3\build\ssl\ssl_obj.vcxproj]
C:\Users\ludvig\Desktop\x\libressl-3.8.3\ssl\s3_cbc.c(466,1): warning C4702: unreachable code [C:\Users\ludvig\Desktop\x\libressl-3.8.3\build\ssl\ssl_obj.vcxproj]
  s3_lib.c
  ssl_algs.c
  ssl_asn1.c
  ssl_both.c
  ssl_cert.c
  ssl_ciph.c
  ssl_ciphers.c
  ssl_clnt.c
  ssl_err.c
  ssl_init.c
  ssl_kex.c
  ssl_lib.c
  ssl_methods.c
  ssl_packet.c
  ssl_pkt.c
  ssl_rsa.c
  ssl_seclevel.c
  ssl_sess.c
  ssl_sigalgs.c
  ssl_srvr.c
  ssl_stat.c
  ssl_tlsext.c
  ssl_transcript.c
  ssl_txt.c
  ssl_versions.c
  t1_enc.c
  t1_lib.c
  tls_buffer.c
  tls_content.c
  tls_key_share.c
  tls_lib.c
  tls12_key_schedule.c
  tls12_lib.c
  tls12_record_layer.c
  tls13_client.c
  tls13_error.c
  tls13_handshake.c
  tls13_handshake_msg.c
  tls13_key_schedule.c
  tls13_legacy.c
  tls13_lib.c
  tls13_quic.c
  tls13_record.c
  tls13_record_layer.c
  tls13_server.c
  ssl_obj.vcxproj -> C:\Users\ludvig\Desktop\x\libressl-3.8.3\build\ssl\ssl_obj.dir\Debug\ssl_obj.lib
  1>Building Custom Rule C:/Users/ludvig/Desktop/x/libressl-3.8.3/tls/CMakeLists.txt
  tls.c
  tls_bio_cb.c
  tls_client.c
  tls_config.c
  tls_conninfo.c
  tls_keypair.c
  tls_server.c
  tls_signer.c
  tls_ocsp.c
  tls_peer.c
  tls_util.c
  tls_verify.c
  ftruncate.c
  pread.c
  pwrite.c
  tls_obj.vcxproj -> C:\Users\ludvig\Desktop\x\libressl-3.8.3\build\tls\tls_obj.dir\Debug\tls_obj.lib

Am I missing a configure step or is the _CET_ENDBR define missing under this build environment?

What version of MSVC are you using? We are testing a few different variants in our CI/CD environment without issue.

LDVG commented

Hi @busterb! I attached the output of the CMake configure step above although you may need to expand the "Complete configure and build logs" section to see it. The relevant bits with regards to MSVC version should be topmost section:

-- Building for: Visual Studio 17 2022
-- Selecting Windows SDK version 10.0.22000.0 to target Windows 10.0.22631.
-- The C compiler identification is MSVC 19.39.33521.0
-- The ASM compiler identification is MSVC
-- Found assembler: C:/Program Files/Microsoft Visual Studio/2022/Community/VC/Tools/MSVC/14.39.33519/bin/Hostx64/x64/cl.exe
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Check for working C compiler: C:/Program Files/Microsoft Visual Studio/2022/Community/VC/Tools/MSVC/14.39.33519/bin/Hostx64/x64/cl.exe - skipped

We're also hitting this issue when trying to bump the LibreSSL version for our libfido2 CI/CD here on GitHub. An example of such a failing pipeline can be found at https://github.com/Yubico/libfido2/actions/runs/8231145251/job/22505870981. We could build the 3.8.2 release without problem.

Does the CI/CD environment also test building out of the release tarballs? (If so, perhaps I can spot what it is I'm doing differently.)

Thanks!

Most of the CI/CD environments run a 'make distcheck', which does build from a release tarball, but this might be an exception. I'm not sure if that's what you're seeing here though.

I think you're spot on here; I found a deviation from when the tarballs generated on OpenBSD are built on Windows, and the same tarballs build on Linux.

I think this will be fixed with d7861a9, checking it out now.

This should be fixed in the next stable releases, but feel free to test out ahead of time:
libressl-3.9.1.tar.gz

LDVG commented

3.9.1 appears to be working as expected. Thank you for the swift turnaround!