crowforkotlin edited PR #13837.
crowforkotlin edited PR #13837:
Closes #13733
The
static_assertcheck inval.hused__alignof(a GCC extension), which returns the preferred alignment rather than the ABI alignment. On the i686 architecture, these two alignment values foruint64_tdiffer (8 and 4, respectively), resulting in a false-positive compilation failure. This has been changed to usealignof(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 ===
crowforkotlin updated PR #13837.
crowforkotlin updated PR #13837.
crowforkotlin commented on PR #13837:
Iteration history:
__alignof → _Alignof
_Alignof is a C11 keyword but does not exist in C++, causing
compile errors when val.h is included from .cc files._Alignof → alignof
alignof works in C++ and GCC/Clang C (via <stdalign.h>), but
MSVC's C compiler does not support it.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.
github-actions[bot] added the label wasmtime:c-api on PR #13837.
:memo: fitzgen submitted PR review:
LGTM modulo one comment below, thanks!
:speech_balloon: fitzgen created PR review comment:
I think we can skip the
\defand\briefsince this isn't a public API and is#undef'd immediately after it is used.
:thumbs_up: alexcrichton submitted PR review.
crowforkotlin updated PR #13837.
crowforkotlin updated PR #13837.
crowforkotlin updated PR #13837.
:memo: crowforkotlin submitted PR review.
:speech_balloon: crowforkotlin created PR review comment:
Okay, it has been modified.
:speech_balloon: crowforkotlin edited PR review comment.
alexcrichton added PR #13837 Use alignof instead of __alignof in C API val.h assertions to the merge queue.
:check: alexcrichton merged PR #13837.
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