implement another bump allocator for WAMR's Alloc_With_Allocator

This commit is contained in:
2026-06-05 19:11:00 +02:00
parent 7284849684
commit b6355a67f3
4 changed files with 110 additions and 28 deletions

View File

@ -71,6 +71,11 @@ my $cmake_c_flags = join( ' ', @variant_cflags );
my @variant_cmake_flags;
push @variant_cmake_flags, '-DWAMR_BUILD_ALLOC_WITH_USAGE=1' if $use_allocator;
# Defines forwarded to the host compilation so wasm_host.c sees the same
# WASM_MEM_ALLOC_WITH_USAGE value as libiwasm.a was built with.
my @host_variant_cflags;
push @host_variant_cflags, '-DWASM_MEM_ALLOC_WITH_USAGE=1' if $use_allocator;
# ========================================================================================= #
# Compiler / linker flags
# ========================================================================================= #
@ -260,10 +265,7 @@ sub make_interp_array {
sub prepare_wasm_host {
my ( $module, $bd, $mode ) = @_;
my $template =
$use_allocator
? 'targets/wasm-host/wasm_host_allocator.c'
: 'targets/wasm-host/wasm_host_pool.c';
my $template = 'targets/wasm-host/wasm_host.c';
my $mod_c = ( $module =~ s/-/_/gr );
my ( $array_file, $array_sym, $len_sym ) =
@ -290,29 +292,26 @@ sub compile_wasm_host {
my ( $module, $bd, $target ) = @_;
if ( $target eq 'fail' ) {
Util::run(
$cross_cc, '-I./targets/wasm-host',
@cross_cflags, @wamr_inc_baremetal,
'-DTARGET_FAIL', '-c',
"$bd/module_host.c", '-o',
"$bd/system.o"
$cross_cc, '-I./targets/wasm-host',
@cross_cflags, @host_variant_cflags,
@wamr_inc_baremetal, '-DTARGET_FAIL',
'-c', "$bd/module_host.c", '-o', "$bd/system.o"
);
}
elsif ( $target eq 'linux' ) {
Util::run(
$linux_cc, '-I./targets/wasm-host',
@linux_cflags, @wamr_inc_linux,
'-DTARGET_LINUX', '-c',
"$bd/module_host.c", '-o',
"$bd/system.o"
$linux_cc, '-I./targets/wasm-host',
@linux_cflags, @host_variant_cflags,
@wamr_inc_linux, '-DTARGET_LINUX',
'-c', "$bd/module_host.c", '-o', "$bd/system.o"
);
}
elsif ( $target eq 'linux-baremetal' ) {
Util::run(
$cross_cc, '-I./targets/wasm-host',
@linux_baremetal_cflags, @wamr_inc_baremetal,
'-DTARGET_LINUX_BAREMETAL', '-c',
"$bd/module_host.c", '-o',
"$bd/system.o"
$cross_cc, '-I./targets/wasm-host',
@linux_baremetal_cflags, @host_variant_cflags,
@wamr_inc_baremetal, '-DTARGET_LINUX_BAREMETAL',
'-c', "$bd/module_host.c", '-o', "$bd/system.o"
);
}
else {