libressl / portable

LibreSSL Portable itself. This includes the build scaffold and compatibility layer that builds portable LibreSSL from the OpenBSD source code. Pull requests or patches sent to tech@openbsd.org are welcome.
https://www.libressl.org
1.35k stars 269 forks source link

Libressl-3.9.2 generates lots of warnings on windows using ClangCL #1088

Open d3x0r opened 1 month ago

d3x0r commented 1 month ago

Visual studio has an option to use Clang-CL as a backend - it's supposed to behave like 'cl.exe' but is clang and llvm.

with libressl source in a directory, from that directory... In order to enable it - using the visual studio installer, under Modify 'Individual components` search for 'clang' and select all options...

image

mkdir build
cd build
cmake -T ClangCL ..

and build resulting libressl.sln ( can either use cmake --build . or load the project in visual studio) and then a ton of error in the test projects are generated... for example:

lld-link : error : duplicate symbol: posix_perror [M:\javascript\vfs\native\src\sack\libressl\3.9.2\build\tests\aeadtest.vcxproj]
  >>> defined at M:\javascript\vfs\native\src\sack\libressl\3.9.2\crypto\compat\posix_win.c:25
  >>>            M:\javascript\vfs\native\src\sack\libressl\3.9.2\build\crypto\compat_obj.dir\Debug\posix_win.obj
  >>> defined at crypto.lib(posix_win.obj)

Also get a bunch of warnings... the clang-cl compiler is using clang warnings instead of the C4496 sort of warning... for example:

            "C4996" # The POSIX name for this item is deprecated.
                    # Instead, use the ISO C and C++ conformant name

This fixes additional warnings... (for building the library anyway)

    set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wno-unused-parameter -Wno-deprecated-declarations -Wno-microsoft-enum-forward-reference")

(disregard below...)

The above is a 32 bit build... enabling -A x64 so assembly builds fails for a different reason... (Pretty sure this is a MS issue, since the /W3 that's getting added is from 'masm.target' build rule.) cmake -T ClangCL -A x64 ..

MASM : fatal error A1013: invalid numerical command-line argument : /W [...\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  ... (defs and includes)  /W3 /errorReport:prompt (warning disables)

(This last one I was just trying to figure out exactly what was causing a compile error; if I disable assembly I guess I can get past this, CMake also has code in it to add /W3 erroneously to the C,C++ compiler flags... though I'm not sure if that IS an issue of if it's just this ml64.exe that's puking )

Edit: This last one is apparently caused by me.... I had a warning disable from 3.8.0

    set_target_properties( crypto_obj PROPERTIES COMPILE_FLAGS "-Wno-sign-compare -Wno-missing-field-initializers")

with that, then the assembly fails with /W3 (so disregard after horizontal bar above)