Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Windows clang build fails with -Werror,-Wcast-function-type-mismatch #1971

Closed
vszakats opened this issue Nov 6, 2024 · 0 comments · Fixed by #1972
Closed

Windows clang build fails with -Werror,-Wcast-function-type-mismatch #1971

vszakats opened this issue Nov 6, 2024 · 0 comments · Fixed by #1972

Comments

@vszakats
Copy link
Contributor

vszakats commented Nov 6, 2024

Problem:

When building AWS-LC for Windows using clang and mingw-w64, the build fails with:

/path/to/awslc/crypto/rand_extra/windows.c:68:22: error: cast from 'FARPROC' (aka 'long long (*)()')
to 'ProcessPrngFunction' (aka 'int (*)(unsigned char *, unsigned long long)') converts
to incompatible function type [-Werror,-Wcast-function-type-mismatch]
   68 |   g_processprng_fn = (ProcessPrngFunction)GetProcAddress(hmod, "ProcessPrng");
      |                      ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
1 error generated.

Full log: https://github.com/curl/curl-for-win/actions/runs/11712448493/job/32623148501#step:3:3996

Relevant details

AWS-LC commit: 1.37.0

System information: for linux, below info can be collected by running uname -srvmp

  • CPU architecture: x86_64
  • OS: Windows (cross-built from Debian testing)

Build log:

-- The C compiler identification is Clang 19.1.2
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Check for working C compiler: /usr/bin/clang-19 - skipped
-- Detecting C compile features
-- Detecting C compile features - done
-- The CXX compiler identification is Clang 19.1.2
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Check for working CXX compiler: /usr/bin/clang++-19 - skipped
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- Go not found. Disabling some code generation and using pre-generated code in generated-src/
-- Perl not found. Disabling some code generation and using pre-generated code in generated-src/
-- Setting CMAKE_C_STANDARD=11
-- stdalign_check.c probe is positive, enabling AWS_LC_STDALIGN_AVAILABLE
-- builtin_swap_check.c probe is positive, enabling AWS_LC_BUILTIN_SWAP_SUPPORTED
-- The ASM_NASM compiler identification is NASM
-- Found assembler: /usr/bin/nasm
Copying platform assembly files from /home/runner/work/curl-for-win/curl-for-win/awslc/generated-src/win-x86_64/crypto/ to /home/runner/work/curl-for-win/curl-for-win/awslc/_x64-win-ucrt-bld/crypto
-- Performing Test CMAKE_HAVE_LIBC_PTHREAD
-- Performing Test CMAKE_HAVE_LIBC_PTHREAD - Success
-- Found Threads: TRUE
-- Configuring done (1.1s)
-- Generating done (0.1s)
@vszakats vszakats changed the title Windows build fails with -Werror,-Wcast-function-type-mismatch Windows clang build fails with -Werror,-Wcast-function-type-mismatch Nov 6, 2024
vszakats added a commit to vszakats/aws-lc that referenced this issue Nov 6, 2024
```
crypto/rand_extra/windows.c:68:22: error: cast from 'FARPROC' (aka 'long long (*)()')
to 'ProcessPrngFunction' (aka 'int (*)(unsigned char *, unsigned long long)') converts
to incompatible function type [-Werror,-Wcast-function-type-mismatch]
   68 |   g_processprng_fn = (ProcessPrngFunction)GetProcAddress(hmod, "ProcessPrng");
      |                      ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
```

Fixes aws#1971
vszakats added a commit to curl/curl-for-win that referenced this issue Nov 7, 2024
Experimental. Not working.

The goal is to make it possible to test and compare it with BoringSSL.

Also:

- disable Perl (it's not present on Alpine by default).
  Needed for FIPS only.

- add new Windows-specific AWS-LC build issue where it force-sets
  `_WIN32_WINNT` to Win7.

- address the above by patching out `_WIN32_WINNT` force-set.

- address the above by bumping Windows target to Win7.
  Yet to be seen if this is a true requirement or an arbitrary
  value that's newer than the default they intended to avoid in
  some mingw builds.

- fix clang 19? deprecation warning triggered in mingw-w64 builds
  ```
  /usr/lib/llvm-19/lib/clang/19/include/mm3dnow.h:16:2: error: "The <mm3dnow.h> header is deprecated, and 3dNow! intrinsics are unsupported. For other intrinsics, include <x86intrin.h>, instead." [-Werror,-W#warnings]
     16 | #warning "The <mm3dnow.h> header is deprecated, and 3dNow! intrinsics are unsupported. For other intrinsics, include <x86intrin.h>, instead."
        |  ^
  1 error generated.
  ```
  https://github.com/curl/curl-for-win/actions/runs/11714432529/job/32629108727#step:3:4286

- patch AWS-LC to avoid `-Werror,-Wcast-function-type-mismatch`
  on Windows:
  ```
  /path/to/awslc/crypto/rand_extra/windows.c:68:22: error: cast from 'FARPROC' (aka 'long long (*)()')
  to 'ProcessPrngFunction' (aka 'int (*)(unsigned char *, unsigned long long)') converts
  to incompatible function type [-Werror,-Wcast-function-type-mismatch]
     68 |   g_processprng_fn = (ProcessPrngFunction)GetProcAddress(hmod, "ProcessPrng");
        |                      ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  1 error generated.
  ```
  https://github.com/curl/curl-for-win/actions/runs/11712448493/job/32623148501#step:3:3996
  Upstream report and patch:
  aws/aws-lc#1971
  aws/aws-lc#1972

Unfixed issues:

- curl cmake is trying and failing to detect ECH support:
  ```
  -- Looking for SSL_set1_ech_config_list - not found
  [...]
           "/usr/bin/ld.lld-19" --sysroot=/usr/x86_64-w64-mingw32 -m i386pep -Bdynamic -o cmTC_d97c0.exe /usr/x86_64-w64-mingw32/lib/crt2.o /usr/x86_64-w64-mingw32/lib/crtbegin.o -L/usr/lib/gcc/x86_64-w64-mingw32/13-posix -L/usr/x86_64-w64-mingw32/x86_64-w64-mingw32/lib -L/usr/x86_64-w64-mingw32/x86_64-w64-mingw32/mingw/lib -L/usr/x86_64-w64-mingw32/lib -lucrt -Xlink=-cetcompat --gc-sections --icf=all -s -Bstatic -Map curl.map -lpthread CMakeFiles/cmTC_d97c0.dir/CheckSymbolExists.c.obj --out-implib libcmTC_d97c0.dll.a --major-image-version 0 --minor-image-version 0 /home/runner/work/curl-for-win/curl-for-win/awslc/_x64-win-ucrt/usr/lib/libssl.a /home/runner/work/curl-for-win/curl-for-win/awslc/_x64-win-ucrt/usr/lib/libcrypto.a /home/runner/work/curl-for-win/curl-for-win/zlib/_x64-win-ucrt/usr/lib/libz.a -lws2_32 -lbcrypt -lkernel32 -luser32 -lgdi32 -lwinspool -lshell32 -lole32 -loleaut32 -luuid -lcomdlg32 -ladvapi32 -lmingw32 -lgcc -lgcc_eh -lmoldname -lmingwex -lmsvcrt -ladvapi32 -lshell32 -luser32 -lkernel32 -lmingw32 -lgcc -lgcc_eh -lmoldname -lmingwex -lmsvcrt -lkernel32 /usr/x86_64-w64-mingw32/lib/crtend.o
          ld.lld-19: error: libcrypto.a(err.o): invalid symbol index in addrsig section
          clang-19: error: linker command failed with exit code 1 (use -v to see invocation)
  ```
  https://github.com/curl/curl-for-win/actions/runs/11714665857/job/32629738265#step:3:6997
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant