Stream: git-wasmtime

Topic: wasmtime / PR #13837 Use alignof instead of __alignof in ...


view this post on Zulip Wasmtime GitHub notifications bot (Jul 07 2026 at 09:07):

crowforkotlin edited PR #13837.

view this post on Zulip Wasmtime GitHub notifications bot (Jul 07 2026 at 09:09):

crowforkotlin edited PR #13837:

Closes #13733

The static_assert check in val.h used __alignof (a GCC extension), which returns the preferred alignment rather than the ABI alignment. On the i686 architecture, these two alignment values ​​for uint64_t differ (8 and 4, respectively), resulting in a false-positive compilation failure. This has been changed to use alignof (provided by <stdalign.h> in C11 and natively supported in C++11), as it returns the ABI alignment that actually determines struct layout.

samples: https://github.com/crowforkotlin/wasmtime_c_api_32bit_issues
issues & effect : #13733
references: https://en.cppreference.com/c/language/_Alignof

> bash qemu-i686-test.sh
Compile OK. Running...
=== i686 (SysV ABI) layout probe ===

__alignof(uint64_t) = 8
_Alignof(uint64_t)  = 4
__alignof(int64_t)  = 8
_Alignof(int64_t)   = 4
__alignof(double)   = 8
_Alignof(double)    = 4

sizeof(wasmtime_val_t)    = 20
_Alignof(wasmtime_val_t)  = 4
__alignof(wasmtime_val_t) = 4
offsetof(kind)            = 0
offsetof(of)              = 4

sizeof(wasmtime_valunion_t)    = 16
_Alignof(wasmtime_valunion_t)  = 4
__alignof(wasmtime_valunion_t) = 4

sizeof(wasmtime_val_raw_t)  = 16
_Alignof(wasmtime_val_raw_t)= 4

=== static_assert passed ===

> export WASMTIME_DIR=~/develop/github/wasmtime/
> export NDK=/home/crowf/Android/Sdk/ndk/28.2.13676358
> bash qemu-armv7a-test.sh
Compile OK. Running (needs sudo for unshare)...
=== armv7a (AAPCS32) layout probe ===

__alignof(uint64_t) = 8
_Alignof(uint64_t)  = 8
__alignof(int64_t)  = 8
_Alignof(int64_t)   = 8
__alignof(double)   = 8
_Alignof(double)    = 8

sizeof(wasmtime_val_t)    = 24
_Alignof(wasmtime_val_t)  = 8
__alignof(wasmtime_val_t) = 8
offsetof(kind)            = 0
offsetof(of)              = 8

sizeof(wasmtime_valunion_t)    = 16
_Alignof(wasmtime_valunion_t)  = 8
__alignof(wasmtime_valunion_t) = 8

sizeof(wasmtime_val_raw_t)  = 16
_Alignof(wasmtime_val_raw_t)= 8

=== static_assert passed ===

view this post on Zulip Wasmtime GitHub notifications bot (Jul 07 2026 at 09:44):

crowforkotlin updated PR #13837.

view this post on Zulip Wasmtime GitHub notifications bot (Jul 07 2026 at 09:55):

crowforkotlin updated PR #13837.

view this post on Zulip Wasmtime GitHub notifications bot (Jul 07 2026 at 09:59):

crowforkotlin commented on PR #13837:

Iteration history:

  1. __alignof → _Alignof
    _Alignof is a C11 keyword but does not exist in C++, causing
    compile errors when val.h is included from .cc files.

  2. _Alignof → alignof
    alignof works in C++ and GCC/Clang C (via <stdalign.h>), but
    MSVC's C compiler does not support it.

  3. alignof → WASMTIME_ALIGNOF macro (final)
    A macro that selects the correct operator per compiler:
    alignof for C++ and GCC/Clang C, __alignof for MSVC C mode.
    #undef'd immediately after use.

view this post on Zulip Wasmtime GitHub notifications bot (Jul 07 2026 at 12:32):

github-actions[bot] added the label wasmtime:c-api on PR #13837.

view this post on Zulip Wasmtime GitHub notifications bot (Jul 07 2026 at 14:52):

:memo: fitzgen submitted PR review:

LGTM modulo one comment below, thanks!

view this post on Zulip Wasmtime GitHub notifications bot (Jul 07 2026 at 14:52):

:speech_balloon: fitzgen created PR review comment:

I think we can skip the \def and \brief since this isn't a public API and is #undef'd immediately after it is used.

view this post on Zulip Wasmtime GitHub notifications bot (Jul 07 2026 at 14:52):

:thumbs_up: alexcrichton submitted PR review.

view this post on Zulip Wasmtime GitHub notifications bot (Jul 08 2026 at 01:37):

crowforkotlin updated PR #13837.

view this post on Zulip Wasmtime GitHub notifications bot (Jul 08 2026 at 01:38):

crowforkotlin updated PR #13837.

view this post on Zulip Wasmtime GitHub notifications bot (Jul 08 2026 at 01:42):

crowforkotlin updated PR #13837.

view this post on Zulip Wasmtime GitHub notifications bot (Jul 08 2026 at 02:18):

:memo: crowforkotlin submitted PR review.

view this post on Zulip Wasmtime GitHub notifications bot (Jul 08 2026 at 02:18):

:speech_balloon: crowforkotlin created PR review comment:

Okay, it has been modified.

view this post on Zulip Wasmtime GitHub notifications bot (Jul 08 2026 at 02:23):

:speech_balloon: crowforkotlin edited PR review comment.

view this post on Zulip Wasmtime GitHub notifications bot (Jul 08 2026 at 14:21):

alexcrichton added PR #13837 Use alignof instead of __alignof in C API val.h assertions to the merge queue.

view this post on Zulip Wasmtime GitHub notifications bot (Jul 08 2026 at 14:44):

:check: alexcrichton merged PR #13837.

view this post on Zulip Wasmtime GitHub notifications bot (Jul 08 2026 at 14:44):

alexcrichton removed PR #13837 Use alignof instead of __alignof in C API val.h assertions from the merge queue.


Last updated: Jul 29 2026 at 05:03 UTC