make --xip and .wamr_mmap configurable from build menu

This commit is contained in:
2026-05-29 00:15:59 +02:00
parent 05a4aa18e4
commit c57ae5fced
10 changed files with 194 additions and 109 deletions

View File

@ -45,12 +45,24 @@ my @selected_modes =
TUI::select_from_list( "Select Execution Modes", 1, @modes );
die "No mode selected" unless @selected_modes;
# Select WAMR mmap variant
my @wamr_variants = ( "no .wamr_mmap", ".wamr_mmap" );
my @selected_variants =
TUI::select_from_list( "Select WAMR mmap Variant", 1, @wamr_variants );
die "No variant selected" unless @selected_variants;
# Select XIP variant
my @xip_variants = ( "no --xip", "--xip" );
my @selected_xip_variants =
TUI::select_from_list( "Select WAMRC XIP Variant", 1, @xip_variants );
die "No XIP variant selected" unless @selected_xip_variants;
# Select 0.info contents
my $info = join " ", TUI::select_from_list( "Select '0.info' Contents for ", 1, (
"baseline",
"--catch-outer",
"--catch-text",
".wamr_mmap",
# ".wamr_mmap",
".wamr_aot",
));
@ -60,18 +72,28 @@ system( "mkdir", "-p", "$local_builds_dir" );
foreach my $experiment (@selected_experiments) {
foreach my $target (@selected_targets) {
foreach my $mode (@selected_modes) {
just( "build", $experiment, $target, $mode );
foreach my $variant (@selected_variants) {
foreach my $xip_variant (@selected_xip_variants) {
# These variables control which libiwasm and wamrc flags are used
local $ENV{WAMR_USE_MMAP} = ( $variant eq ".wamr_mmap" ) ? "true" : "false";
local $ENV{WAMR_USE_XIP} = ( $xip_variant eq "--xip" ) ? "true" : "false";
system( "echo '$mode $info' > $local_root/build-$experiment/0.info" );
just( "build", $experiment, $target, $mode );
system(
join " ",
(
"mv",
"$local_root/build-$experiment",
"$local_builds_dir/${date}_$experiment-$target-$mode",
)
);
my $mmap = $variant eq ".wamr_mmap" ? ".wamr_mmap" : "";
my $xip = $xip_variant eq "--xip" ? "--xip" : "";
system( "echo '$mode $mmap $info $xip' > $local_root/build-$experiment/0.info" );
system(
join " ",
(
"mv",
"$local_root/build-$experiment",
"$local_builds_dir/${date}_$experiment-$target-$mode",
)
);
}
}
}
}
}

View File

@ -10,6 +10,8 @@ WASI_ROOT := env("WASI_ROOT")
WAMR_ROOT := env("WAMR_ROOT")
LIBIWASM_DEBUG := env("LIBIWASM_DEBUG")
LIBIWASM_RELEASE := env("LIBIWASM_RELEASE")
LIBIWASM_MMAP_DEBUG := env("LIBIWASM_MMAP_DEBUG")
LIBIWASM_MMAP_RELEASE := env("LIBIWASM_MMAP_RELEASE")
LIBIWASM_LINUX_DEBUG := env("LIBIWASM_LINUX_DEBUG")
LIBIWASM_LINUX_RELEASE := env("LIBIWASM_LINUX_RELEASE")
CROSS_CC := env("CROSS_CC")

View File

@ -223,7 +223,8 @@ sub inject {
# Catch invalid instruction pointers
"-Wf,--catch-outerspace",
# Messes with AOT compilation target if mmap memory is part of .text
# Messes with Wasm compilation targets if mmap memory is part of .text
# (because the linear memory is allocated using os_mmap)
"-Wf,--catch-write-textsegment",
"-Wf,--timeout=500000",

View File

@ -48,12 +48,12 @@ LINUX_LDFLAGS_NOWASM := "\
-lm \
"
WAMRC := "wamrc"
WAMR_USE_XIP := env_var_or_default("WAMR_USE_XIP", "false")
CROSS_WAMRCFLAGS := "\
--target=i386 \
--cpu=generic \
--opt-level=0 \
--xip \
"
" + if WAMR_USE_XIP == "true" { "--xip" } else { "" }
LINUX_WAMRCFLAGS := "\
--target=i386 \
--cpu=generic \
@ -74,7 +74,6 @@ build-wasm-aot-linux module:
build-wasm-aot-cross module:
{{ WAMRC }} {{ CROSS_WAMRCFLAGS }} -o {{ BUILD_DIR }}-{{ module }}/wasm_module.aot {{ BUILD_DIR }}-{{ module }}/wasm_module.wasm
[doc("WASM -> AOT: Compile a WASM module ahead-of-time using WAMR")]
[group("1: build module")]
build-wasm-aot module target="fail":
@ -144,8 +143,10 @@ copy-auxiliary module:
# =================================================================================================================== #
# FAIL*
WAMR_USE_MMAP := env_var_or_default("WAMR_USE_MMAP", "false")
ACTIVE_LIBIWASM_DEBUG := if WAMR_USE_MMAP == "true" { LIBIWASM_MMAP_DEBUG } else { LIBIWASM_DEBUG }
CROSS_CFLAGS := f"-I./targets/wasm-host {{CROSS_CFLAGS_NOWASM}}"
CROSS_LDFLAGS := f"-L{{LIBIWASM_DEBUG}} -liwasm {{CROSS_LDFLAGS_NOWASM}}"
CROSS_LDFLAGS := f"-L{{ACTIVE_LIBIWASM_DEBUG}} -liwasm {{CROSS_LDFLAGS_NOWASM}}"
CROSS_INCLUDES := f"\
-I{{WAMR_ROOT}}/core/iwasm/include \
-I{{WAMR_ROOT}}/core/shared/utils \
@ -178,7 +179,7 @@ LINUX_BAREMETAL_LDFLAGS := f"\
-static \
-nostdlib \
-m32 \
-L{{LIBIWASM_DEBUG}} \
-L{{ACTIVE_LIBIWASM_DEBUG}} \
-liwasm \
-lc \
-lgcc \