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

Build fails for some targets because of missing _ISOC11_SOURCE preprocessor definition #370

Closed
ancwrd1 opened this issue Mar 9, 2024 · 2 comments
Labels
bug Something isn't working

Comments

@ancwrd1
Copy link

ancwrd1 commented Mar 9, 2024

When trying to build the aws-lc-rs or the dependent project it fails for some targets (in particular x86_64-pc-windows-gnu) with a compiler error around static_assert. Error example:

rust/aws-lc-rs/aws-lc-sys/aws-lc/crypto/refcount_win.c:23:15: error: expected declaration specifiers or '...' before '_Alignof'
     23 | static_assert(alignof(CRYPTO_refcount_t) == alignof(LONG),
        |               ^~~~~~~

This happens because the standard <assert.h> header for MinGW toolchain contains this:

#if (defined _ISOC11_SOURCE \
     || (defined __STDC_VERSION__ && __STDC_VERSION__ >= 201112L)) \
    && !defined (__cplusplus)
/* Static assertion.  Requires support in the compiler.  */
#undef static_assert
#define static_assert _Static_assert
#endif

The workaround is to use CFLAGS="-D_ISOC11_SOURCE" env variable when building. A better solution to my opinion is to configure the build scripts to include it by default.

Edit: I think it happens because build scripts set "-std=c99", and assert_static is c11 feature.

@justsmth
Copy link
Contributor

justsmth commented Mar 11, 2024

Thanks for submitting this issue. For most platforms, AWS-LC's C code is expected to be compliant with C99. However, Windows (of course) often requires exceptions to be made.

Let me take some time to investigate this (and potentially other issues?) when building AWS-LC w/ MinGW. I'll then follow up here.

@justsmth justsmth added the bug Something isn't working label Mar 12, 2024
@justsmth
Copy link
Contributor

justsmth commented May 3, 2024

As of our v1.7.1 release, I believe this issue to be resolved. Feel free to reopen or create a new issue if you are still having a problem building aws-lc-rs. Thanks!

@justsmth justsmth closed this as completed May 3, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants