Fix perl import errors

This commit is contained in:
2026-06-13 21:39:50 +02:00
parent b344c55eee
commit 4ba417ebdf
8 changed files with 72 additions and 58 deletions

View File

@ -32,13 +32,16 @@ my $wamr_root = require_env('WAMR_ROOT');
my $cross_cc = require_env('CROSS_CC');
my $linux_cc = require_env('LINUX_CC');
my $use_aot_in_text = ( $ENV{WAMR_USE_AOT_IN_TEXT} // 'false' ) eq 'true';
my $use_mmap_in_text = ( $ENV{WAMR_USE_MMAP_IN_TEXT} // 'false' ) eq 'true';
my $use_xip = ( $ENV{WAMR_USE_XIP} // 'false' ) eq 'true';
my $use_allocator = ( $ENV{WAMR_USE_ALLOCATOR} // 'false' ) eq 'true';
my $use_global_heap_in_text = ( $ENV{WAMR_USE_GLOBAL_HEAP_IN_TEXT} // 'false' ) eq 'true';
my $use_runtime_pool_in_text = ( $ENV{WAMR_USE_RUNTIME_POOL_IN_TEXT} // 'false' ) eq 'true';
my $use_linear_pool_in_text = ( $ENV{WAMR_USE_LINEAR_POOL_IN_TEXT} // 'false' ) eq 'true';
my $use_aot_in_text = ( $ENV{WAMR_USE_AOT_IN_TEXT} // 'false' ) eq 'true';
my $use_mmap_in_text = ( $ENV{WAMR_USE_MMAP_IN_TEXT} // 'false' ) eq 'true';
my $use_xip = ( $ENV{WAMR_USE_XIP} // 'false' ) eq 'true';
my $use_allocator = ( $ENV{WAMR_USE_ALLOCATOR} // 'false' ) eq 'true';
my $use_global_heap_in_text =
( $ENV{WAMR_USE_GLOBAL_HEAP_IN_TEXT} // 'false' ) eq 'true';
my $use_runtime_pool_in_text =
( $ENV{WAMR_USE_RUNTIME_POOL_IN_TEXT} // 'false' ) eq 'true';
my $use_linear_pool_in_text =
( $ENV{WAMR_USE_LINEAR_POOL_IN_TEXT} // 'false' ) eq 'true';
# ========================================================================================= #
# WAMR cmake configuration
@ -66,7 +69,8 @@ my @wamr_cmake_linux = ( '-DWAMR_BUILD_PLATFORM=linux', );
# Variant defines passed as CMAKE_C_FLAGS
my @variant_cflags =
( '-Wno-error=implicit-function-declaration', '-O0', '-ggdb3' );
push @variant_cflags, $use_mmap_in_text ? '-DWAMR_MMAP_IN_TEXT=1' : '-DWAMR_MMAP_IN_TEXT=0';
push @variant_cflags,
$use_mmap_in_text ? '-DWAMR_MMAP_IN_TEXT=1' : '-DWAMR_MMAP_IN_TEXT=0';
push @variant_cflags, '-DWASM_MEM_ALLOC_WITH_USAGE=1' if $use_allocator;
my $cmake_c_flags = join( ' ', @variant_cflags );
@ -78,9 +82,18 @@ push @variant_cmake_flags, '-DWAMR_BUILD_ALLOC_WITH_USAGE=1' if $use_allocator;
# 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;
push @host_variant_cflags, $use_global_heap_in_text ? '-DWAMR_GLOBAL_HEAP_IN_TEXT=1' : '-DWAMR_GLOBAL_HEAP_IN_TEXT=0';
push @host_variant_cflags, $use_runtime_pool_in_text ? '-DWAMR_RUNTIME_POOL_IN_TEXT=1' : '-DWAMR_RUNTIME_POOL_IN_TEXT=0';
push @host_variant_cflags, $use_linear_pool_in_text ? '-DWAMR_LINEAR_POOL_IN_TEXT=1' : '-DWAMR_LINEAR_POOL_IN_TEXT=0';
push @host_variant_cflags,
$use_global_heap_in_text
? '-DWAMR_GLOBAL_HEAP_IN_TEXT=1'
: '-DWAMR_GLOBAL_HEAP_IN_TEXT=0';
push @host_variant_cflags,
$use_runtime_pool_in_text
? '-DWAMR_RUNTIME_POOL_IN_TEXT=1'
: '-DWAMR_RUNTIME_POOL_IN_TEXT=0';
push @host_variant_cflags,
$use_linear_pool_in_text
? '-DWAMR_LINEAR_POOL_IN_TEXT=1'
: '-DWAMR_LINEAR_POOL_IN_TEXT=0';
# ========================================================================================= #
# Compiler / linker flags
@ -243,7 +256,8 @@ sub compile_wasm_module {
sub compile_wasm_aot {
my ( $module, $bd, $target ) = @_;
my @flags = ( $target eq 'linux' ) ? @linux_wamrcflags : @cross_wamrcflags;
Util::run( 'wamrc', @flags, '-o', "$bd/wasm_module.aot", "$bd/wasm_module.wasm" );
Util::run( 'wamrc', @flags, '-o', "$bd/wasm_module.aot",
"$bd/wasm_module.wasm" );
}
sub make_aot_array {
@ -299,26 +313,29 @@ sub compile_wasm_host {
my ( $module, $bd, $target ) = @_;
if ( $target eq 'fail' ) {
Util::run(
$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"
$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, @host_variant_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',
$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"
@wamr_inc_baremetal, '-DTARGET_LINUX_BAREMETAL',
'-c', "$bd/module_host.c",
'-o', "$bd/system.o"
);
}
else {
@ -342,15 +359,16 @@ sub compile_c_host {
( $target eq 'linux' )
? ( $linux_cc, @linux_cflags, '-DTARGET_LINUX' )
: ( $cross_cc, @cross_cflags, '-DTARGET_FAIL' );
Util::run( $cc, @flags, '-c', 'targets/c-host/c_host.c', '-o', "$bd/c_host.o" );
Util::run( $cc, @flags, '-c', 'targets/c-host/c_host.c', '-o',
"$bd/c_host.o" );
copy( 'targets/c-host/c_host.c', "$bd/module_host.c" );
}
sub compile_startup {
my ( $module, $bd, $target ) = @_;
return unless $target eq 'fail';
Util::run( $cross_cc, 'targets/startup.s', '-I./targets/wasm-host', @cross_cflags,
'-c', '-o', "$bd/startup.o" );
Util::run( $cross_cc, 'targets/startup.s', '-I./targets/wasm-host',
@cross_cflags, '-c', '-o', "$bd/startup.o" );
}
sub compile_syscalls {
@ -380,12 +398,12 @@ sub link_wasm {
);
}
elsif ( $target eq 'linux' ) {
Util::run( $linux_cc, "$bd/system.o", "$bd/libiwasm.a", @linux_ldflags_base,
'-o', "$bd/system.elf" );
Util::run( $linux_cc, "$bd/system.o", "$bd/libiwasm.a",
@linux_ldflags_base, '-o', "$bd/system.elf" );
}
elsif ( $target eq 'linux-baremetal' ) {
Util::run( $cross_cc, "$bd/system.o", "$bd/syscalls.o", "$bd/libiwasm.a",
@baremetal_ldflags_base, '-o', "$bd/system.elf" );
Util::run( $cross_cc, "$bd/system.o", "$bd/syscalls.o",
"$bd/libiwasm.a", @baremetal_ldflags_base, '-o', "$bd/system.elf" );
}
else {
die "Unknown target '$target'\n";
@ -404,8 +422,8 @@ sub link_c {
);
}
elsif ( $target eq 'linux' ) {
Util::run( $linux_cc, "$bd/c_host.o", "$bd/c_module.o", @linux_ldflags_nowasm,
'-o', "$bd/system.elf" );
Util::run( $linux_cc, "$bd/c_host.o", "$bd/c_module.o",
@linux_ldflags_nowasm, '-o', "$bd/system.elf" );
}
else {
die "C mode is not supported for target '$target'\n";