make fail flags and .wamr_aot configurable from build menu
This commit is contained in:
@ -12,6 +12,7 @@ LIBIWASM_LINUX_DEBUG := env("LIBIWASM_LINUX_DEBUG")
|
|||||||
LIBIWASM_LINUX_RELEASE := env("LIBIWASM_LINUX_RELEASE")
|
LIBIWASM_LINUX_RELEASE := env("LIBIWASM_LINUX_RELEASE")
|
||||||
CROSS_CC := env("CROSS_CC")
|
CROSS_CC := env("CROSS_CC")
|
||||||
LINUX_CC := env("LINUX_CC")
|
LINUX_CC := env("LINUX_CC")
|
||||||
|
WAMR_USE_AOT_SECTION := env_var_or_default("WAMR_USE_AOT_SECTION", "false")
|
||||||
|
|
||||||
# =================================================================================================================== #
|
# =================================================================================================================== #
|
||||||
# Helper recipes
|
# Helper recipes
|
||||||
@ -181,9 +182,9 @@ build-wasm-aot module target="fail":
|
|||||||
[group("1: build module")]
|
[group("1: build module")]
|
||||||
build-wasm-aot-array module:
|
build-wasm-aot-array module:
|
||||||
{{ XXD }} -i {{ BUILD_DIR }}-{{ module }}/wasm_module.aot > {{ BUILD_DIR }}-{{ module }}/wasm_aot_array.c
|
{{ XXD }} -i {{ BUILD_DIR }}-{{ module }}/wasm_module.aot > {{ BUILD_DIR }}-{{ module }}/wasm_aot_array.c
|
||||||
|
if [ "{{ WAMR_USE_AOT_SECTION }}" = "true" ]; then \
|
||||||
# Add __attribute__((section...)) to this array, so it is located into the .text.wamr_aot segment...
|
sed -i '1s/^/__attribute__((section(".text.wamr_aot"), aligned(4096)))\n/' {{ BUILD_DIR }}-{{ module }}/wasm_aot_array.c; \
|
||||||
sed -i '1s/^/__attribute__((section(".text.wamr_aot"), aligned(4096)))\n/' {{ BUILD_DIR }}-{{ module }}/wasm_aot_array.c
|
fi
|
||||||
|
|
||||||
[doc("WASM -> C-Array: Dump a WASM module to a binary array")]
|
[doc("WASM -> C-Array: Dump a WASM module to a binary array")]
|
||||||
[group("1: build module")]
|
[group("1: build module")]
|
||||||
|
|||||||
152
scripts/build.pl
152
scripts/build.pl
@ -23,8 +23,9 @@ my @targets = ( "fail", "linux", "linux-baremetal" );
|
|||||||
my @modes = ( "c", "aot", "interp" );
|
my @modes = ( "c", "aot", "interp" );
|
||||||
|
|
||||||
sub just {
|
sub just {
|
||||||
say "Running: just @_...";
|
say
|
||||||
system("$justbin -d $local_root -f $justfile @_")
|
"Running: WAMR_USE_AOT_SECTION=$ENV{WAMR_USE_AOT_SECTION} WAMR_USE_MMAP=$ENV{WAMR_USE_MMAP} WAMR_USE_XIP=$ENV{WAMR_USE_XIP} just @_...";
|
||||||
|
system("$justbin -d $local_root -f $justfile @_ >/dev/null 2>&1")
|
||||||
and die "Build failed";
|
and die "Build failed";
|
||||||
sleep(1);
|
sleep(1);
|
||||||
}
|
}
|
||||||
@ -45,11 +46,24 @@ my @selected_modes =
|
|||||||
TUI::select_from_list( "Select Execution Modes", 1, @modes );
|
TUI::select_from_list( "Select Execution Modes", 1, @modes );
|
||||||
die "No mode selected" unless @selected_modes;
|
die "No mode selected" unless @selected_modes;
|
||||||
|
|
||||||
|
# Select .text.wamr_aot section variant
|
||||||
|
my @aot_section_variants = (
|
||||||
|
"Place AOT array in .text.wamr_aot",
|
||||||
|
"Let the linker decide where the AOT array is located",
|
||||||
|
);
|
||||||
|
my @selected_aot_variants =
|
||||||
|
TUI::select_from_list( "Select WAMR Array.Text Variant",
|
||||||
|
1, @aot_section_variants );
|
||||||
|
die "No AOT section variant selected" unless @selected_aot_variants;
|
||||||
|
|
||||||
# Select WAMR mmap variant
|
# Select WAMR mmap variant
|
||||||
my @wamr_variants = ( "Locate mmap_space in .text.wamr_mmap", "Let the compiler decide where mmap_space is located" );
|
my @mmap_variants = (
|
||||||
my @selected_variants =
|
"Locate mmap_space in .text.wamr_mmap",
|
||||||
TUI::select_from_list( "Select WAMR mmap Variant", 1, @wamr_variants );
|
"Let the linker decide where mmap_space is located"
|
||||||
die "No variant selected" unless @selected_variants;
|
);
|
||||||
|
my @selected_mmap_variants =
|
||||||
|
TUI::select_from_list( "Select WAMR Mmap.Text Variant", 1, @mmap_variants );
|
||||||
|
die "No variant selected" unless @selected_mmap_variants;
|
||||||
|
|
||||||
# Select XIP variant
|
# Select XIP variant
|
||||||
my @xip_variants = ( "Compile AOT with --xip", "Compile AOT without --xip" );
|
my @xip_variants = ( "Compile AOT with --xip", "Compile AOT without --xip" );
|
||||||
@ -57,15 +71,23 @@ my @selected_xip_variants =
|
|||||||
TUI::select_from_list( "Select WAMRC XIP Variant", 1, @xip_variants );
|
TUI::select_from_list( "Select WAMRC XIP Variant", 1, @xip_variants );
|
||||||
die "No XIP variant selected" unless @selected_xip_variants;
|
die "No XIP variant selected" unless @selected_xip_variants;
|
||||||
|
|
||||||
|
# Select FAIL catch flags (written to runner_flags in each build dir, not a build loop)
|
||||||
|
my %catch_flag_map = (
|
||||||
|
"--catch-outer" => "--catch-outerspace",
|
||||||
|
"--catch-text" => "--catch-write-textsegment",
|
||||||
|
);
|
||||||
|
my @selected_catch_tags =
|
||||||
|
TUI::select_from_list( "Select FAIL Flags", 1, sort keys %catch_flag_map );
|
||||||
|
|
||||||
# Select 0.info contents
|
# Select 0.info contents
|
||||||
my $info = join " ", TUI::select_from_list( "Select '0.info' Contents for ", 1, (
|
my $info = join " ", TUI::select_from_list(
|
||||||
"baseline",
|
"Select '0.info' Contents for ",
|
||||||
"--catch-outer",
|
1,
|
||||||
"--catch-text",
|
(
|
||||||
"wamr_aot",
|
# mmap, xip, wamr_aot, --catch-outer, --catch-text are auto-included from variant selections
|
||||||
# "wamr_mmap",
|
"baseline",
|
||||||
# "--xip",
|
)
|
||||||
));
|
);
|
||||||
|
|
||||||
# Build everything
|
# Build everything
|
||||||
# TODO: linux-baremetal target is broken
|
# TODO: linux-baremetal target is broken
|
||||||
@ -73,29 +95,93 @@ system( "mkdir", "-p", "$local_builds_dir" );
|
|||||||
foreach my $experiment (@selected_experiments) {
|
foreach my $experiment (@selected_experiments) {
|
||||||
foreach my $target (@selected_targets) {
|
foreach my $target (@selected_targets) {
|
||||||
foreach my $mode (@selected_modes) {
|
foreach my $mode (@selected_modes) {
|
||||||
foreach my $variant (@selected_variants) {
|
foreach my $mmap_variant (@selected_mmap_variants) {
|
||||||
foreach my $xip_variant (@selected_xip_variants) {
|
foreach my $xip_variant (@selected_xip_variants) {
|
||||||
# These variables control which libiwasm and wamrc flags are used
|
foreach my $aot_variant (@selected_aot_variants) {
|
||||||
local $ENV{WAMR_USE_MMAP} = ( $variant eq "Locate mmap_space in .text.wamr_mmap" ) ? "true" : "false";
|
|
||||||
local $ENV{WAMR_USE_XIP} = ( $xip_variant eq "Compile AOT with --xip" ) ? "true" : "false";
|
|
||||||
|
|
||||||
my $date = strftime("%m-%d_%H-%M-%S", localtime);
|
# Skip redundant combinations where variants don't apply to this mode
|
||||||
just( "build", $experiment, $target, $mode );
|
# "c" uses no WAMR at all
|
||||||
|
# "interp" uses mmap but no AOT
|
||||||
|
next
|
||||||
|
if $mode eq "c"
|
||||||
|
&& ( $mmap_variant ne $mmap_variants[0]
|
||||||
|
|| $xip_variant ne $xip_variants[0]
|
||||||
|
|| $aot_variant ne $aot_section_variants[0] );
|
||||||
|
next
|
||||||
|
if $mode eq "interp"
|
||||||
|
&& ( $xip_variant ne $xip_variants[0]
|
||||||
|
|| $aot_variant ne $aot_section_variants[0] );
|
||||||
|
|
||||||
my $mmap = $variant eq "Locate mmap_space in .text.wamr_mmap" ? "mmap" : "";
|
# These variables control which libiwasm, wamrc flags, and build options are used
|
||||||
my $xip = $xip_variant eq "Compile AOT with --xip" ? "xip" : "";
|
local $ENV{WAMR_USE_MMAP} =
|
||||||
system( "echo '$mode $mmap $info $xip' > $local_root/build-$experiment/0.info" );
|
( $mmap_variant eq
|
||||||
|
"Locate mmap_space in .text.wamr_mmap" )
|
||||||
|
? "true"
|
||||||
|
: "false";
|
||||||
|
local $ENV{WAMR_USE_XIP} =
|
||||||
|
( $xip_variant eq "Compile AOT with --xip" )
|
||||||
|
? "true"
|
||||||
|
: "false";
|
||||||
|
local $ENV{WAMR_USE_AOT_SECTION} =
|
||||||
|
( $aot_variant eq
|
||||||
|
"Place AOT array in .text.wamr_aot" )
|
||||||
|
? "true"
|
||||||
|
: "false";
|
||||||
|
|
||||||
my $mmap_name = $mmap eq "mmap" ? "_mmap" : "";
|
my $aot_info =
|
||||||
my $xip_name = $xip eq "xip" ? "_xip" : "";
|
( $mode eq "aot"
|
||||||
system(
|
&& $aot_variant eq
|
||||||
join " ",
|
"Place AOT array in .text.wamr_aot" )
|
||||||
(
|
? "wamr_aot"
|
||||||
"mv",
|
: "";
|
||||||
"$local_root/build-$experiment",
|
my $mmap_info =
|
||||||
"$local_builds_dir/${date}_${experiment}_${target}_${mode}${mmap_name}${xip_name}",
|
( ( $mode eq "aot" || $mode eq "interp" )
|
||||||
)
|
&& $mmap_variant eq
|
||||||
);
|
"Locate mmap_space in .text.wamr_mmap" )
|
||||||
|
? "wamr_mmap"
|
||||||
|
: "";
|
||||||
|
my $xip_info =
|
||||||
|
( $mode eq "aot"
|
||||||
|
&& $xip_variant eq "Compile AOT with --xip" )
|
||||||
|
? "xip"
|
||||||
|
: "";
|
||||||
|
my $flags_info = join " ", @selected_catch_tags;
|
||||||
|
my $info_str = join " ",
|
||||||
|
grep { length } (
|
||||||
|
$mode, $aot_info, $mmap_info,
|
||||||
|
$xip_info, $flags_info, $info
|
||||||
|
);
|
||||||
|
|
||||||
|
# Build experiment
|
||||||
|
my $date = strftime( "%m-%d_%H-%M-%S", localtime );
|
||||||
|
just( "build", $experiment, $target, $mode );
|
||||||
|
|
||||||
|
# Write extra info for the menu
|
||||||
|
system(
|
||||||
|
"echo '$info_str' > $local_root/build-$experiment/0.info"
|
||||||
|
);
|
||||||
|
|
||||||
|
# Write runner_flags so runner.pl knows which FAIL flags to use
|
||||||
|
my $runner_flags_path =
|
||||||
|
"$local_root/build-$experiment/runner_flags";
|
||||||
|
open( my $rfh, '>', $runner_flags_path )
|
||||||
|
or die "Cannot write $runner_flags_path: $!";
|
||||||
|
print $rfh "$catch_flag_map{$_}\n"
|
||||||
|
for @selected_catch_tags;
|
||||||
|
close($rfh);
|
||||||
|
|
||||||
|
my $aot_name = $aot_info ? "_aot-text" : "";
|
||||||
|
my $mmap_name = $mmap_info ? "_mmap-text" : "";
|
||||||
|
my $xip_name = $xip_info ? "_xip" : "";
|
||||||
|
system(
|
||||||
|
join " ",
|
||||||
|
(
|
||||||
|
"mv",
|
||||||
|
"$local_root/build-$experiment",
|
||||||
|
"$local_builds_dir/${date}_${experiment}_${mode}_${target}${aot_name}${mmap_name}${xip_name}",
|
||||||
|
)
|
||||||
|
);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -206,6 +206,15 @@ sub inject {
|
|||||||
);
|
);
|
||||||
say "Server command: $server_command";
|
say "Server command: $server_command";
|
||||||
|
|
||||||
|
# Read catch flags written by build.pl into the experiment directory
|
||||||
|
my $runner_flags_file = "$remote_builds_dir/$experiment/runner_flags";
|
||||||
|
my @catch_flags = ();
|
||||||
|
if ( -e $runner_flags_file ) {
|
||||||
|
open( my $rfh, '<', $runner_flags_file ) or die "Cannot open $runner_flags_file: $!";
|
||||||
|
@catch_flags = map { chomp; "-Wf,$_" } grep { /\S/ } <$rfh>;
|
||||||
|
close($rfh);
|
||||||
|
}
|
||||||
|
|
||||||
my $client_command = join " ", (
|
my $client_command = join " ", (
|
||||||
"nice $bochs_runner",
|
"nice $bochs_runner",
|
||||||
"-V $fail_share/vgabios.bin",
|
"-V $fail_share/vgabios.bin",
|
||||||
@ -220,12 +229,7 @@ sub inject {
|
|||||||
"-Wf,--state-dir=$remote_builds_dir/$experiment/state",
|
"-Wf,--state-dir=$remote_builds_dir/$experiment/state",
|
||||||
"-Wf,--trap",
|
"-Wf,--trap",
|
||||||
|
|
||||||
# Catch invalid instruction pointers
|
@catch_flags,
|
||||||
"-Wf,--catch-outerspace",
|
|
||||||
|
|
||||||
# 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",
|
"-Wf,--timeout=500000",
|
||||||
"-Wf,--ok-marker=fail_marker_positive",
|
"-Wf,--ok-marker=fail_marker_positive",
|
||||||
|
|||||||
Reference in New Issue
Block a user