Fix linux-baremetal build
This commit is contained in:
+27
-10
@@ -123,8 +123,7 @@ my @cross_ldflags_base = (
|
||||
my @linux_ldflags_base = ( '-Wl,--build-id=none', '-m32', '-lm' );
|
||||
my @baremetal_ldflags_base = (
|
||||
'-Wl,--build-id=none', '-static', '-nostdlib', '-m32',
|
||||
'-lc', '-lgcc', '-lm', '--entry',
|
||||
'main'
|
||||
'-lc', '-lgcc', '-lm'
|
||||
);
|
||||
my @cross_ldflags_nowasm = (
|
||||
'-Wl,--build-id=none', '-static', '-nostdlib', '-m32',
|
||||
@@ -199,7 +198,8 @@ sub build {
|
||||
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 {
|
||||
my ( $module, $bd, $target ) = @_;
|
||||
my ( $cc, @flags ) =
|
||||
( $target eq 'linux' )
|
||||
? ( $linux_cc, @linux_cflags, '-DTARGET_LINUX' )
|
||||
( $target eq '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' );
|
||||
|
||||
if ( Util::module_is_tacle($module) ) {
|
||||
@@ -404,8 +405,9 @@ sub compile_c_module {
|
||||
sub compile_c_host {
|
||||
my ( $module, $bd, $target ) = @_;
|
||||
my ( $cc, @flags ) =
|
||||
( $target eq 'linux' )
|
||||
? ( $linux_cc, @linux_cflags, '-DTARGET_LINUX' )
|
||||
( $target eq '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' );
|
||||
Util::run( $cc, @flags, '-c', 'targets/c-host/c_host.c', '-o',
|
||||
"$bd/c_host.o" );
|
||||
@@ -414,7 +416,7 @@ sub compile_c_host {
|
||||
|
||||
sub compile_startup {
|
||||
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',
|
||||
@cross_cflags, '-c', '-o', "$bd/startup.o" );
|
||||
}
|
||||
@@ -450,8 +452,13 @@ sub link_wasm {
|
||||
@linux_ldflags_base, '-o', "$bd/system.elf" );
|
||||
}
|
||||
elsif ( $target eq 'linux-baremetal' ) {
|
||||
Util::run( $cross_cc, "$bd/system.o", "$bd/syscalls.o",
|
||||
"$bd/libiwasm.a", @baremetal_ldflags_base, '-o', "$bd/system.elf" );
|
||||
Util::run(
|
||||
$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 {
|
||||
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,
|
||||
@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 {
|
||||
die "C mode is not supported for target '$target'\n";
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user