replace build.just with compile.pl

This commit is contained in:
2026-06-05 17:14:34 +02:00
parent 9c42618028
commit bd6df6b4e9
6 changed files with 563 additions and 756 deletions

View File

@ -16,17 +16,18 @@ use feature 'say';
my $local_root = '/home/christoph/Notes/TU/MastersThesis/FailNix';
my $local_builds_dir = "$local_root/builds";
my $local_experiments_dir = "$local_root/targets/wasm-module";
my $justbin = "$local_root/just-bin/just";
my $justfile = "$local_root/scripts/build.just";
my $compile_pl = "$local_root/scripts/compile.pl";
my @targets = ( "fail", "linux", "linux-baremetal" );
my @modes = ( "c", "aot", "interp" );
sub compile {
my ( $module, $target, $mode ) = @_;
say "Running: WAMR_USE_AOT_IN_TEXT=$ENV{WAMR_USE_AOT_IN_TEXT}",
" WAMR_USE_MMAP_IN_TEXT=$ENV{WAMR_USE_MMAP_IN_TEXT}",
" WAMR_USE_XIP=$ENV{WAMR_USE_XIP}",
" WAMR_USE_ALLOCATOR=$ENV{WAMR_USE_ALLOCATOR}",
" compile.pl $module $target $mode";
sub just {
say
"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";
system( 'perl', $compile_pl, $module, $target, $mode ) == 0
or die "Build failed\n";
sleep(1);
}
@ -37,11 +38,13 @@ my @selected_experiments =
die "No experiment selected" unless @selected_experiments;
# Select targets
my @targets = ( "fail", "linux", "linux-baremetal" );
my @selected_targets =
TUI::select_from_list( "Select Target Platforms", 1, @targets );
die "No target selected" unless @selected_targets;
# Select modes
my @modes = ( "c", "aot", "interp" );
my @selected_modes =
TUI::select_from_list( "Select Execution Modes", 1, @modes );
die "No mode selected" unless @selected_modes;
@ -51,27 +54,53 @@ 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 =
my $selected_aot_variant =
TUI::select_from_list( "Select WAMR Array.Text Variant",
1, @aot_section_variants );
die "No AOT section variant selected" unless @selected_aot_variants;
0, @aot_section_variants );
die "No AOT section variant selected" unless $selected_aot_variant;
local $ENV{WAMR_USE_AOT_IN_TEXT} =
( $selected_aot_variant eq $aot_section_variants[0] )
? "true"
: "false";
# Select WAMR mmap variant
my @mmap_variants = (
"Locate mmap_space in .text.wamr_mmap",
"Place mmap_space in .text.wamr_mmap",
"Let the linker decide where mmap_space is located"
);
my @selected_mmap_variants =
TUI::select_from_list( "Select WAMR Mmap.Text Variant", 1, @mmap_variants );
die "No variant selected" unless @selected_mmap_variants;
my $selected_mmap_variant =
TUI::select_from_list( "Select WAMR Mmap.Text Variant", 0, @mmap_variants );
die "No variant selected" unless $selected_mmap_variant;
local $ENV{WAMR_USE_MMAP_IN_TEXT} =
( $selected_mmap_variant eq $mmap_variants[0] )
? "true"
: "false";
# Select WAMR allocator variant
my @allocator_variants = (
"Pool allocator (Alloc_With_Pool)",
"Allocator with usage (Alloc_With_Allocator)",
);
my $selected_allocator_variant =
TUI::select_from_list( "Select WAMR Allocator Variant",
0, @allocator_variants );
die "No allocator variant selected" unless $selected_allocator_variant;
local $ENV{WAMR_USE_ALLOCATOR} =
( $selected_allocator_variant eq $allocator_variants[0] )
? "true"
: "false";
# Select XIP variant
my @xip_variants = ( "Compile AOT with --xip", "Compile AOT without --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;
my $selected_xip_variant =
TUI::select_from_list( "Select WAMRC XIP Variant", 0, @xip_variants );
die "No XIP variant selected" unless $selected_xip_variant;
local $ENV{WAMR_USE_XIP} =
( $selected_xip_variant eq $xip_variants[0] )
? "true"
: "false";
# Select FAIL catch flags (written to runner_flags in each build dir, not a build loop)
# Select FAIL catch flags (written to runner_flags in each build dir)
my %catch_flag_map = (
"--catch-outer" => "--catch-outerspace",
"--catch-text" => "--catch-write-textsegment",
@ -79,111 +108,71 @@ my %catch_flag_map = (
my @selected_catch_tags =
TUI::select_from_list( "Select FAIL Flags", 1, sort keys %catch_flag_map );
# Select 0.info contents
my $info = join " ", TUI::select_from_list(
"Select '0.info' Contents for ",
1,
(
# mmap, xip, wamr_aot, --catch-outer, --catch-text are auto-included from variant selections
"baseline",
)
);
# Build everything
# TODO: linux-baremetal target is broken
system( "mkdir", "-p", "$local_builds_dir" );
foreach my $experiment (@selected_experiments) {
foreach my $target (@selected_targets) {
foreach my $mode (@selected_modes) {
foreach my $mmap_variant (@selected_mmap_variants) {
foreach my $xip_variant (@selected_xip_variants) {
foreach my $aot_variant (@selected_aot_variants) {
# Skip redundant combinations where variants don't apply to this 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 $aot_info =
( $mode eq "aot"
&& $selected_aot_variant eq $aot_section_variants[0] )
? "wamr_aot"
: "";
my $mmap_info =
( ( $mode eq "aot" || $mode eq "interp" )
&& $selected_mmap_variant eq $mmap_variants[0] )
? "wamr_mmap"
: "";
my $allocator_info =
( ( $mode eq "aot" || $mode eq "interp" )
&& $selected_allocator_variant eq $allocator_variants[0] )
? "alloc_pool"
: "alloc_usage";
my $xip_info =
( $mode eq "aot" && $selected_xip_variant eq $xip_variants[0] )
? "xip"
: "";
my $flags_info = join " ", @selected_catch_tags;
my $info_str = join " ",
grep { length } (
$mode, $aot_info, $mmap_info,
$allocator_info, $xip_info, $flags_info
);
# These variables control which libiwasm, wamrc flags, and build options are used
local $ENV{WAMR_USE_MMAP} =
( $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";
# Build experiment
my $date = strftime( "%m-%d_%H-%M-%S", localtime );
compile( $experiment, $target, $mode );
my $aot_info =
( $mode eq "aot"
&& $aot_variant eq
"Place AOT array in .text.wamr_aot" )
? "wamr_aot"
: "";
my $mmap_info =
( ( $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
);
# Write extra info for the menu
system("echo '$info_str' > $local_root/build-$experiment/0.info");
# Build experiment
my $date = strftime( "%m-%d_%H-%M-%S", localtime );
just( "build", $experiment, $target, $mode );
# Write runner_flags so runner.pl knows which FAIL flags to use
my $runner_flags_path =
"$local_root/build-$experiment/runner_flags";
open( my $fhandle, '>', $runner_flags_path )
or die "Cannot write $runner_flags_path: $!";
print $fhandle "$catch_flag_map{$_}\n" for @selected_catch_tags;
close($fhandle);
# 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}",
)
);
}
}
}
my $aot_name = $aot_info ? "_aot-text" : "";
my $mmap_name = $mmap_info ? "_mmap-text" : "";
my $allocator_name = $allocator_info ? "_alloc-usage" : "";
my $xip_name = $xip_info ? "_xip" : "";
system(
join " ",
(
"mv",
"$local_root/build-$experiment",
join "",
(
"$local_builds_dir/",
"${date}_${experiment}_${mode}_${target}",
"${aot_name}${mmap_name}${allocator_name}${xip_name}",
)
)
);
}
}
}