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

Unable to compile mbedtls 3.5.0 with mingw-w64 clang17 #8332

Closed
Andarwinux opened this issue Oct 9, 2023 · 5 comments
Closed

Unable to compile mbedtls 3.5.0 with mingw-w64 clang17 #8332

Andarwinux opened this issue Oct 9, 2023 · 5 comments
Labels
bug component-crypto Crypto primitives and low-level interfaces size-s Estimated task size: small (~2d)

Comments

@Andarwinux
Copy link

Andarwinux commented Oct 9, 2023

Summary

mpv-winbuild-cmake/build/packages/mbedtls-prefix/src/mbedtls/library/aesni.c:59:29: error: too many arguments to function call, expected 2, have 5
   59 |         __cpuid(1, info[0], info[1], info[2], info[3]);
      |         ~~~~~~~             ^~~~~~~~~~~~~~~~~~~~~~~~~
mpv-winbuild-cmake/build/install/x86_64-w64-mingw32/include/intrin.h:1139:21: note: '__cpuid' declared here
 1139 |     __MACHINEI(void __cpuid(int a[4],int b))
      |                     ^       ~~~~~~~~~~~~~~
mpv-winbuild-cmake/build/install/x86_64-w64-mingw32/include/intrin.h:178:20: note: expanded from macro '__MACHINEI'
  178 | #define __MACHINEI __MACHINE
      |                    ^
mpv-winbuild-cmake/build/install/x86_64-w64-mingw32/include/intrin.h:192:22: note: expanded from macro '__MACHINE'
  192 | #define __MACHINE(X) X;
      |                      ^
1 error generated.
make[2]: *** [library/CMakeFiles/mbedcrypto.dir/build.make:185: library/CMakeFiles/mbedcrypto.dir/aesni.c.obj] Error 1
make[2]: *** Waiting for unfinished jobs....
make[1]: *** [CMakeFiles/Makefile2:252: library/CMakeFiles/mbedcrypto.dir/all] Error 2
make: *** [Makefile:136: all] Error 2

System information

Mbed TLS version (number or commit id): 5ca3f0b
Operating system and version: build on wsl2 archlinux, host is x86_64-w64-mingw32
Configuration (if not default, please attach mbedtls_config.h):

        -DCMAKE_BUILD_TYPE=Release
        -DENABLE_PROGRAMS=OFF
        -DENABLE_TESTING=OFF
        -DGEN_FILES=ON
        -DUSE_STATIC_MBEDTLS_LIBRARY=ON
        -DUSE_SHARED_MBEDTLS_LIBRARY=OFF
        -DINSTALL_MBEDTLS_HEADERS=ON
        -DMBEDTLS_FATAL_WARNINGS=OFF

Compiler and options (if you used a pre-built binary, please indicate how you obtained it):
clang 17 with mingw-w64 git master

-target x86_64-w64-mingw32 --sysroot mpv-winbuild-cmake/build/install/x86_64-w64-mingw32 -march=native -mtune=generic -mguard=cf -O3 -mllvm --polly -mllvm --polly-position=before-vectorizer -mllvm --polly-scheduling=dynamic -mllvm --polly-ast-use-context -mllvm --polly-vectorizer=stripmine -mllvm --polly-run-dce -mllvm --polly-invariant-load-hoisting -mllvm --polly-run-inliner -gcodeview

Additional environment information:
use https://github.com/shinchiro/mpv-winbuild-cmake

Expected behavior

Successfully compiles without any errors.

Actual behavior

mpv-winbuild-cmake/build/packages/mbedtls-prefix/src/mbedtls/library/aesni.c:59:29: error: too many arguments to function call, expected 2, have 5
   59 |         __cpuid(1, info[0], info[1], info[2], info[3]);
      |         ~~~~~~~             ^~~~~~~~~~~~~~~~~~~~~~~~~

Steps to reproduce

git clone https://github.com/shinchiro/mpv-winbuild-cmake.git
cd mpv-winbuild-cmake
cmake -DTARGET_ARCH=x86_64-w64-mingw32 -DGCC_ARCH=native -DALWAYS_REMOVE_BUILDFILES=ON -DSINGLE_SOURCE_LOCATION=../src_packages -DCOMPILER_TOOLCHAIN=clang -G Ninja -B build -S ./
cd build
ninja llvm && ninja llvm-clang && ninja mbedtls

Additional information

Our Temporary Fixes:
shinchiro/mpv-winbuild-cmake@2fc10df
You can also use llvm-mingw directly to reproduce the problem without build llvm.

@ronald-cron-arm ronald-cron-arm added bug component-crypto Crypto primitives and low-level interfaces size-s Estimated task size: small (~2d) labels Oct 10, 2023
@ronald-cron-arm
Copy link
Contributor

Thanks for the bug report. We will look at fixing it before the next release. If you think you have a fix that does not impact other platforms, please submit a PR.

@tom-cosgrove-arm
Copy link
Contributor

@Andarwinux Can you see if it works for you, with commit 5ca3f0b, replacing line 38 (#else) with

#elif defined(__clang__)

@lpy4105 lpy4105 mentioned this issue Oct 10, 2023
3 tasks
@Andarwinux
Copy link
Author

@Andarwinux Can you see if it works for you, with commit 5ca3f0b, replacing line 38 (#else) with

#elif defined(__clang__)

This still doesn't work, but #8339 does solve the problem.

@tom-cosgrove-arm
Copy link
Contributor

Thanks for testing

@tom-cosgrove-arm
Copy link
Contributor

Closing this as OP reports #8339 fixes the problem, and it is now merged

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug component-crypto Crypto primitives and low-level interfaces size-s Estimated task size: small (~2d)
Projects
None yet
Development

No branches or pull requests

3 participants