Define WABT_BIG_ENDIAN=1 on big-endian hosts

WebAssembly is little-endian regardless of what machine you run it on,
so the WebAssembly implementation needs to know if the machine is
big-endian or little-endian to function properly.
This commit is contained in:
刘皓 2025-01-01 17:36:52 -05:00
parent ca6fb125c1
commit a32646ff72
No known key found for this signature in database
GPG key ID: 7901753DB465B711
3 changed files with 12 additions and 8 deletions

View file

@ -364,12 +364,11 @@ jobs:
cd build
ninja
mv libretro-mkxp-z.dll "$runner_temp"/retro-phase2
mv "$runner_temp"/retro-phase2 .
- uses: actions/upload-artifact@v4
with:
name: libretro-mkxp-z.windows
path: retro-phase2
path: ${{ runner.temp }}/retro-phase2
build-retro-phase2-linux:
needs: build-retro-phase1

View file

@ -1,6 +1,7 @@
project('mkxp-z', 'c', 'cpp', version: '2.4.2', meson_version: '>=0.56.0', default_options: ['cpp_std=c++14', 'buildtype=release'])
host_system = host_machine.system()
host_endian = host_machine.endian()
if get_option('retro') == false and host_system == 'darwin'
error('\nThis Meson project no longer supports macOS. Please use the Xcode project instead.')
@ -58,6 +59,14 @@ if get_option('retro') == true
endif
retro_deps += cmake.subproject('libzip', options: libzip_options).dependency('zip')
retro_defines = [
'-DWASM_RT_TRAP_HANDLER=mkxp_sandbox_trap_handler',
'-DMKXPZ_RETRO=1',
]
if host_endian == 'big'
retro_defines += '-DWABT_BIG_ENDIAN=1'
endif
library(
'retro-' + meson.project_name(),
dependencies: retro_deps,
@ -70,11 +79,8 @@ if get_option('retro') == true
'-Wno-unused-variable',
'-Wno-unused-but-set-variable',
'-Wno-ignored-optimization-argument',
'-DWASM_RT_TRAP_HANDLER=mkxp_sandbox_trap_handler',
],
cpp_args: [
'-DMKXPZ_RETRO',
],
] + retro_defines,
cpp_args: retro_defines,
link_args: [
host_system == 'darwin' ? '' : ('-Wl,--version-script=' + join_paths(meson.current_source_dir(), 'retro/link.T')),
],

View file

@ -37,7 +37,6 @@
#define WASM_NULL 0
#define WASM_MEM(address) ((void *)&ruby->w2c_memory.data[address])
#define AWAIT(statement) do statement; while (w2c_ruby_mkxp_sandbox_yield(RB))
#define VALIDATE_MALLOC(ptr) do { if (ptr == WASM_NULL || ptr >= ruby.w2c_memory.size) throw SandboxOutOfMemoryException(); } while (0)
// This function is imported by wasm-rt-impl.c from wasm2c
extern "C" void mkxp_sandbox_trap_handler(wasm_rt_trap_t code) {