Fix linux-baremetal build
This commit is contained in:
@@ -219,7 +219,6 @@ if ( grep { $_ eq "fail" } @selected_targets ) {
|
|||||||
# Build everything
|
# Build everything
|
||||||
# ========================================================================================= #
|
# ========================================================================================= #
|
||||||
|
|
||||||
# TODO: linux-baremetal target is broken
|
|
||||||
system( "mkdir", "-p", "$local_builds_dir" );
|
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) {
|
||||||
|
|||||||
+27
-10
@@ -123,8 +123,7 @@ my @cross_ldflags_base = (
|
|||||||
my @linux_ldflags_base = ( '-Wl,--build-id=none', '-m32', '-lm' );
|
my @linux_ldflags_base = ( '-Wl,--build-id=none', '-m32', '-lm' );
|
||||||
my @baremetal_ldflags_base = (
|
my @baremetal_ldflags_base = (
|
||||||
'-Wl,--build-id=none', '-static', '-nostdlib', '-m32',
|
'-Wl,--build-id=none', '-static', '-nostdlib', '-m32',
|
||||||
'-lc', '-lgcc', '-lm', '--entry',
|
'-lc', '-lgcc', '-lm'
|
||||||
'main'
|
|
||||||
);
|
);
|
||||||
my @cross_ldflags_nowasm = (
|
my @cross_ldflags_nowasm = (
|
||||||
'-Wl,--build-id=none', '-static', '-nostdlib', '-m32',
|
'-Wl,--build-id=none', '-static', '-nostdlib', '-m32',
|
||||||
@@ -199,7 +198,8 @@ sub build {
|
|||||||
die "Unknown mode '$mode'; expected: aot, interp, c\n";
|
die "Unknown mode '$mode'; expected: aot, interp, c\n";
|
||||||
}
|
}
|
||||||
|
|
||||||
build_iso( $module, $bd );
|
build_iso( $module, $bd )
|
||||||
|
if $target eq 'fail' || $target eq 'linux-baremetal';
|
||||||
}
|
}
|
||||||
|
|
||||||
# ========================================================================================= #
|
# ========================================================================================= #
|
||||||
@@ -373,8 +373,9 @@ sub compile_wasm_host {
|
|||||||
sub compile_c_module {
|
sub compile_c_module {
|
||||||
my ( $module, $bd, $target ) = @_;
|
my ( $module, $bd, $target ) = @_;
|
||||||
my ( $cc, @flags ) =
|
my ( $cc, @flags ) =
|
||||||
( $target eq 'linux' )
|
( $target eq 'linux' ) ? ( $linux_cc, @linux_cflags, '-DTARGET_LINUX' )
|
||||||
? ( $linux_cc, @linux_cflags, '-DTARGET_LINUX' )
|
: ( $target eq 'linux-baremetal' )
|
||||||
|
? ( $cross_cc, @linux_baremetal_cflags, '-DTARGET_LINUX_BAREMETAL' )
|
||||||
: ( $cross_cc, @cross_cflags, '-DTARGET_FAIL' );
|
: ( $cross_cc, @cross_cflags, '-DTARGET_FAIL' );
|
||||||
|
|
||||||
if ( Util::module_is_tacle($module) ) {
|
if ( Util::module_is_tacle($module) ) {
|
||||||
@@ -404,8 +405,9 @@ sub compile_c_module {
|
|||||||
sub compile_c_host {
|
sub compile_c_host {
|
||||||
my ( $module, $bd, $target ) = @_;
|
my ( $module, $bd, $target ) = @_;
|
||||||
my ( $cc, @flags ) =
|
my ( $cc, @flags ) =
|
||||||
( $target eq 'linux' )
|
( $target eq 'linux' ) ? ( $linux_cc, @linux_cflags, '-DTARGET_LINUX' )
|
||||||
? ( $linux_cc, @linux_cflags, '-DTARGET_LINUX' )
|
: ( $target eq 'linux-baremetal' )
|
||||||
|
? ( $cross_cc, @linux_baremetal_cflags, '-DTARGET_LINUX_BAREMETAL' )
|
||||||
: ( $cross_cc, @cross_cflags, '-DTARGET_FAIL' );
|
: ( $cross_cc, @cross_cflags, '-DTARGET_FAIL' );
|
||||||
Util::run( $cc, @flags, '-c', 'targets/c-host/c_host.c', '-o',
|
Util::run( $cc, @flags, '-c', 'targets/c-host/c_host.c', '-o',
|
||||||
"$bd/c_host.o" );
|
"$bd/c_host.o" );
|
||||||
@@ -414,7 +416,7 @@ sub compile_c_host {
|
|||||||
|
|
||||||
sub compile_startup {
|
sub compile_startup {
|
||||||
my ( $module, $bd, $target ) = @_;
|
my ( $module, $bd, $target ) = @_;
|
||||||
return unless $target eq 'fail';
|
return unless $target eq 'fail' || $target eq 'linux-baremetal';
|
||||||
Util::run( $cross_cc, 'targets/startup.s', '-I./targets/wasm-host',
|
Util::run( $cross_cc, 'targets/startup.s', '-I./targets/wasm-host',
|
||||||
@cross_cflags, '-c', '-o', "$bd/startup.o" );
|
@cross_cflags, '-c', '-o', "$bd/startup.o" );
|
||||||
}
|
}
|
||||||
@@ -450,8 +452,13 @@ sub link_wasm {
|
|||||||
@linux_ldflags_base, '-o', "$bd/system.elf" );
|
@linux_ldflags_base, '-o', "$bd/system.elf" );
|
||||||
}
|
}
|
||||||
elsif ( $target eq 'linux-baremetal' ) {
|
elsif ( $target eq 'linux-baremetal' ) {
|
||||||
Util::run( $cross_cc, "$bd/system.o", "$bd/syscalls.o",
|
Util::run(
|
||||||
"$bd/libiwasm.a", @baremetal_ldflags_base, '-o', "$bd/system.elf" );
|
$cross_cc, '-Wl,-T',
|
||||||
|
'targets/linker.ld', "$bd/system.o",
|
||||||
|
"$bd/startup.o", "$bd/syscalls.o",
|
||||||
|
"$bd/libiwasm.a", @baremetal_ldflags_base,
|
||||||
|
'-o', "$bd/system.elf"
|
||||||
|
);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
die "Unknown target '$target'\n";
|
die "Unknown target '$target'\n";
|
||||||
@@ -476,6 +483,16 @@ sub link_c {
|
|||||||
Util::run( $linux_cc, "$bd/c_host.o", "$bd/c_module.o", @tacle_objs,
|
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" );
|
||||||
}
|
}
|
||||||
|
elsif ( $target eq 'linux-baremetal' ) {
|
||||||
|
Util::run(
|
||||||
|
$cross_cc, '-Wl,-T',
|
||||||
|
'targets/linker.ld', "$bd/c_host.o",
|
||||||
|
"$bd/startup.o", "$bd/syscalls.o",
|
||||||
|
"$bd/c_module.o", @tacle_objs,
|
||||||
|
@baremetal_ldflags_base, '-o',
|
||||||
|
"$bd/system.elf"
|
||||||
|
);
|
||||||
|
}
|
||||||
else {
|
else {
|
||||||
die "C mode is not supported for target '$target'\n";
|
die "C mode is not supported for target '$target'\n";
|
||||||
}
|
}
|
||||||
|
|||||||
+2
-2
@@ -31,11 +31,11 @@
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef TARGET_LINUX_BAREMETAL
|
#ifdef TARGET_LINUX_BAREMETAL
|
||||||
#define MAIN int main(int argc, char *argv[])
|
#define MAIN void os_main(void)
|
||||||
#define PRINT(fmt, ...)
|
#define PRINT(fmt, ...)
|
||||||
#define PRINT_ERROR(fmt, ...)
|
#define PRINT_ERROR(fmt, ...)
|
||||||
#define PRINT_SUCCESS(fmt, ...)
|
#define PRINT_SUCCESS(fmt, ...)
|
||||||
#define RET(val) return val
|
#define RET(val) return
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef TARGET_LINUX
|
#ifdef TARGET_LINUX
|
||||||
|
|||||||
Reference in New Issue
Block a user