From a797335be927a6deb95b6da261f123d2bffe33c6 Mon Sep 17 00:00:00 2001 From: Christoph Urlacher Date: Mon, 6 Jul 2026 23:16:34 +0200 Subject: [PATCH] Update compile.pl to support tacle c (no wasm) compilation --- scripts/compile.pl | 39 +++++++++++++++++++++++++++++++-------- 1 file changed, 31 insertions(+), 8 deletions(-) diff --git a/scripts/compile.pl b/scripts/compile.pl index 725a12d..0eabed9 100644 --- a/scripts/compile.pl +++ b/scripts/compile.pl @@ -374,8 +374,29 @@ sub compile_c_module { ( $target eq 'linux' ) ? ( $linux_cc, @linux_cflags ) : ( $cross_cc, @cross_cflags ); - Util::run( $cc, @flags, '-c', "targets/wasm-module/$module.cpp", - '-o', "$bd/c_module.o" ); + + 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", + '-o', "$bd/c_module.o" ); + } } sub compile_c_host { @@ -437,17 +458,19 @@ sub link_wasm { sub link_c { my ( $module, $bd, $target ) = @_; + my @tacle_objs = + Util::module_is_tacle($module) ? glob("$bd/tacle_*.o") : (); if ( $target eq 'fail' ) { Util::run( - $cross_cc, '-Wl,-T', - 'targets/linker.ld', "$bd/c_host.o", - "$bd/startup.o", "$bd/c_module.o", - @cross_ldflags_nowasm, '-o', - "$bd/system.elf" + $cross_cc, '-Wl,-T', + 'targets/linker.ld', "$bd/c_host.o", + "$bd/startup.o", "$bd/c_module.o", + @tacle_objs, @cross_ldflags_nowasm, + '-o', "$bd/system.elf" ); } 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" ); } else {