aws / aws-lc

AWS-LC is a general-purpose cryptographic library maintained by the AWS Cryptography team for AWS and their customers. It іs based on code from the Google BoringSSL project and the OpenSSL project.
Other
396 stars 118 forks source link

Compiling with zig for x86_64-windows-gnu fails due to X509_NAME and wincrypt.h #1434

Closed theoparis closed 8 months ago

theoparis commented 9 months ago

Problem:

When I tried to compile aws-lc using a build.zig file instead of cmake, for a x86_64-windows-gnu target, It fails due to conflicting symbols from wincrypt.h. Curl seems to have worked around it by using #undef but I'd have to keep a maintained fork of aws-lc to make those changes myself here...

See https://github.com/curl/curl/commit/4c46c829f5ed7c37b3313c67a6662b7332c1ff7f

Reproduction

Git clone the aws-lc zig build repository and extract the latest zig master tarball. Run zig build -Dtarget=x86_64-windows-gnu - it should fail with a bunch of X509_NAME errors...

Relevant details

AWS-LC commit: 56def5a253d27280f3b7bd6564cfa5a11211aee8

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

Build log:

/home/theo/.cache/zig/p/1220b404f239d0911665e3328c7574d8bf6b0f6bd2b0af9761cb2af7ea0eada6c6df/ssl/ssl_file.cc:146:26: error: expected ')'
    int (*old_cmp)(const X509_NAME *const *, const X509_NAME *const *);
                         ^
/home/theo/dev/zig.git/expidus/build/stage3/lib/zig/libc/include/any-windows-any/wincrypt.h:1515:29: note: expanded from macro 'X509_NAME'
#define X509_NAME ((LPCSTR) 7)
torben-hansen commented 9 months ago

Thanks for the report. Researching, this seems as a general issue with wincrypt.h.

Feel free to submit a PR with a fix you believe resolves your issue.

torben-hansen commented 9 months ago

This also look interesting: https://github.com/openssl/openssl/pull/18131#discussion_r854415820. Wonder what the status of that work is.

theoparis commented 8 months ago

This is still an issue but I'm not sure what the best way to fix this in aws-lc is.