diff --git a/meson.build b/meson.build index 45c6406e..72bedb36 100644 --- a/meson.build +++ b/meson.build @@ -31,15 +31,6 @@ global_args += '-DHAVE_NANOSLEEP' # ==================== if get_option('retro') == true - # When Ruby is compiled to wasm32, we need `alignof(std::uint32_t) % 4 == 0`. When Ruby is compiled to wasm64, we need `alignof(std::uint64_t) % 8 == 0`. - # Strictly speaking, we only need to check one of these things depending on whether Ruby was compiled for wasm32 or wasm64, but I'm too lazy to figure out whether Ruby was compiled for wasm32 or wasm64 so let's just check both. - if compilers['cpp'].alignment('std::uint32_t', prefix: '#include ') % 4 != 0 - error('Alignment of `uint32_t` must be divisible by 4 for Ruby garbage collection to work.') - endif - if compilers['cpp'].alignment('std::uint64_t', prefix: '#include ') % 8 != 0 - error('Alignment of `uint64_t` must be divisible by 8 for Ruby garbage collection to work.') - endif - retro_phase1 = get_option('retro_phase1_path') cmake = import('cmake') diff --git a/retro/sandbox-bindgen.rb b/retro/sandbox-bindgen.rb index 990ea16b..90b4542c 100644 --- a/retro/sandbox-bindgen.rb +++ b/retro/sandbox-bindgen.rb @@ -357,6 +357,8 @@ PRELUDE = <<~HEREDOC #include #include "mkxp-sandbox-bindgen.h" + static_assert(alignof(VALUE) % sizeof(VALUE) == 0, "Alignment of `VALUE` must be divisible by size of `VALUE` for Ruby garbage collection to work. If you compiled Ruby for wasm64, try compiling it for wasm32 instead."); + #if WABT_BIG_ENDIAN #define SERIALIZE_32(value) __builtin_bswap32(value) #define SERIALIZE_64(value) __builtin_bswap64(value)