When building with clang-cl
on Windows, the output is cluttered with warning messages because compiler diagnostic flags are not applied correctly:
0> cmake -B build -G Ninja -DCMAKE_C_COMPILER="C:\Users\hebasto\Downloads\clang+llvm-18.1.8-x86_64-pc-windows-msvc\bin\clang-cl.exe"
1> cmake --build build
2[1/16] Building C object src\CMakeFiles\bench.dir\bench.c.obj
3In file included from C:\Users\hebasto\secp256k1\src\bench.c:11:
4C:\Users\hebasto\secp256k1\src\util.h(34,13): warning: unused function 'print_buf_plain' [-Wunused-function]
5 34 | static void print_buf_plain(const unsigned char *buf, size_t len) {
6 | ^~~~~~~~~~~~~~~
71 warning generated.
8[2/16] Building C object src\CMakeFiles\secp256k1_precomputed.dir\precomputed_ecmult_gen.c.obj
9In file included from C:\Users\hebasto\secp256k1\src\precomputed_ecmult_gen.c:3:
10In file included from C:\Users\hebasto\secp256k1\src\group.h:10:
11In file included from C:\Users\hebasto\secp256k1\src\field.h:10:
12C:\Users\hebasto\secp256k1\src\util.h(34,13): warning: unused function 'print_buf_plain' [-Wunused-function]
13 34 | static void print_buf_plain(const unsigned char *buf, size_t len) {
14 | ^~~~~~~~~~~~~~~
This PR resolves this issue.
Additional note for reviewers: The VS builtin clang can also be used assuming that the following VS components are installed:
The user can generate a build system on Windows as follows:
- Using the default “Visual Studio” generator:
0cmake -B build -T ClangCL
- Using the “Ninja” generator:
0cmake -B build -G Ninja -DCMAKE_C_COMPILER=clang-cl
Required for downstream projects which aim to build with clang-cl
(see https://github.com/bitcoin/bitcoin/issues/31456).