Update compile.pl to support tacle c (no wasm) compilation

This commit is contained in:
2026-07-06 23:16:34 +02:00
parent 0d677a71e1
commit a797335be9
+26 -3
View File
@@ -374,8 +374,29 @@ sub compile_c_module {
( $target eq 'linux' ) ( $target eq 'linux' )
? ( $linux_cc, @linux_cflags ) ? ( $linux_cc, @linux_cflags )
: ( $cross_cc, @cross_cflags ); : ( $cross_cc, @cross_cflags );
if ( Util::module_is_tacle($module) ) {
my ( $srcs, $inc ) = Util::find_tacle_sources($module);
# Compile the wrapper separately, so the main can be renamed
Util::run( $cc, @flags, "-I$inc", '-c',
"targets/wasm-module/$module.cpp",
'-o', "$bd/c_module.o" );
my @objs;
for my $src (@$srcs) {
( my $obj = $src ) =~ s{.*/}{};
$obj =~ s/\.c$/.o/;
$obj = "$bd/tacle_$obj";
Util::run( $cc, @flags, "-I$inc", '-Dmain=tacle_main_bullshit',
'-c', $src, '-o', $obj );
push @objs, $obj;
}
}
else {
Util::run( $cc, @flags, '-c', "targets/wasm-module/$module.cpp", Util::run( $cc, @flags, '-c', "targets/wasm-module/$module.cpp",
'-o', "$bd/c_module.o" ); '-o', "$bd/c_module.o" );
}
} }
sub compile_c_host { sub compile_c_host {
@@ -437,17 +458,19 @@ sub link_wasm {
sub link_c { sub link_c {
my ( $module, $bd, $target ) = @_; my ( $module, $bd, $target ) = @_;
my @tacle_objs =
Util::module_is_tacle($module) ? glob("$bd/tacle_*.o") : ();
if ( $target eq 'fail' ) { if ( $target eq 'fail' ) {
Util::run( Util::run(
$cross_cc, '-Wl,-T', $cross_cc, '-Wl,-T',
'targets/linker.ld', "$bd/c_host.o", 'targets/linker.ld', "$bd/c_host.o",
"$bd/startup.o", "$bd/c_module.o", "$bd/startup.o", "$bd/c_module.o",
@cross_ldflags_nowasm, '-o', @tacle_objs, @cross_ldflags_nowasm,
"$bd/system.elf" '-o', "$bd/system.elf"
); );
} }
elsif ( $target eq 'linux' ) { elsif ( $target eq 'linux' ) {
Util::run( $linux_cc, "$bd/c_host.o", "$bd/c_module.o", Util::run( $linux_cc, "$bd/c_host.o", "$bd/c_module.o", @tacle_objs,
@linux_ldflags_nowasm, '-o', "$bd/system.elf" ); @linux_ldflags_nowasm, '-o', "$bd/system.elf" );
} }
else { else {