mirror of
https://gitlab.com/freepascal.org/fpc/source.git
synced 2025-09-03 23:50:36 +02:00
[PATCH 83/83] using wasa assembler instead of wat2wasm. using assembler symbols to identify weak symbols (sub functions and __stack_top for regular units). Getting rid of wasmtool use wabt text output alignment with tabs
From 11b08b2747e7e11ef6f18a70eca2bb94009c8d3d Mon Sep 17 00:00:00 2001 From: Dmitry Boyarintsev <skalogryz.lists@gmail.com> Date: Thu, 9 Apr 2020 13:48:36 -0400 git-svn-id: branches/wasm@45960 -
This commit is contained in:
parent
5d62ef7ca1
commit
5df473f7de
@ -68,7 +68,7 @@ end;
|
||||
procedure tlinkerwasm.SetDefaultInfo;
|
||||
begin
|
||||
Info.DllCmd[1] := 'wasm-ld $SONAME $GCSECTIONS -o $EXE';
|
||||
Info.DllCmd[2] := 'wasmtool --exportrename $INPUT $EXE';
|
||||
//Info.DllCmd[2] := 'wasmtool --exportrename $INPUT $EXE';
|
||||
end;
|
||||
|
||||
function tlinkerwasm.MakeSharedLibrary: boolean;
|
||||
@ -124,10 +124,10 @@ begin
|
||||
writeln(utilsprefix+binstr,' ',cmdstr);
|
||||
success:=DoExec(FindUtil(utilsprefix+binstr),cmdstr,true,false);
|
||||
|
||||
SplitBinCmd(Info.DllCmd[2],binstr,cmdstr);
|
||||
Replace(cmdstr,'$INPUT',current_module.objfilename );
|
||||
Replace(cmdstr,'$EXE',maybequoted(current_module.exefilename));
|
||||
DoExec(FindUtil(utilsprefix+binstr),cmdstr,false,false);
|
||||
//SplitBinCmd(Info.DllCmd[2],binstr,cmdstr);
|
||||
//Replace(cmdstr,'$INPUT',current_module.objfilename );
|
||||
//Replace(cmdstr,'$EXE',maybequoted(current_module.exefilename));
|
||||
//DoExec(FindUtil(utilsprefix+binstr),cmdstr,false,false);
|
||||
|
||||
MakeSharedLibrary:=success;
|
||||
end;
|
||||
|
@ -241,7 +241,7 @@ implementation
|
||||
begin
|
||||
//writer.AsmWriteLn('instr');
|
||||
cpu := taicpu(hp);
|
||||
writer.AsmWrite(#9);
|
||||
writer.AsmWrite(#9#9);
|
||||
writer.AsmWrite(wasm_op2str[cpu.opcode] );
|
||||
|
||||
if (cpu.opcode = a_call_indirect) then begin
|
||||
@ -303,7 +303,13 @@ implementation
|
||||
begin
|
||||
exit;
|
||||
end;
|
||||
writer.AsmWrite('(func ');
|
||||
|
||||
writer.AsmWriteLn('');
|
||||
if stub and stubUnreachable then begin
|
||||
writer.AsmWriteLn(#9';;.weak');
|
||||
end;
|
||||
|
||||
writer.AsmWrite(#9'(func ');
|
||||
|
||||
writer.AsmWrite( GetWasmName( pd.mangledname ));
|
||||
//procsym.RealName ));
|
||||
@ -342,7 +348,7 @@ implementation
|
||||
for i:=0 to pd.paras.Count-1 do
|
||||
begin
|
||||
prm := tcpuparavarsym(pd.paras[i]);
|
||||
writer.AsmWrite(#9'(param'#9);
|
||||
writer.AsmWrite(#9#9'(param'#9);
|
||||
case prm.paraloc[callerside].Size of
|
||||
OS_8..OS_32, OS_S8..OS_S32:
|
||||
writer.AsmWrite('i32');
|
||||
@ -373,7 +379,7 @@ implementation
|
||||
if not defToWasmBasic(pd.returndef, bt) then
|
||||
bt := wbt_i32;
|
||||
|
||||
writer.AsmWrite(#9'(result'#9);
|
||||
writer.AsmWrite(#9#9'(result'#9);
|
||||
case bt of
|
||||
wbt_i64: writer.AsmWrite('i64');
|
||||
wbt_f32: writer.AsmWrite('f32');
|
||||
@ -614,7 +620,7 @@ implementation
|
||||
|
||||
ait_local :
|
||||
begin
|
||||
writer.AsmWrite(#9'(local ');
|
||||
writer.AsmWrite(#9#9'(local ');
|
||||
if tai_local(hp).name <> '' then
|
||||
begin
|
||||
writer.AsmWrite(' ');
|
||||
@ -649,6 +655,10 @@ implementation
|
||||
{ print all global variables }
|
||||
//current_asmdata.AsmSymbolDict
|
||||
|
||||
// for every unit __stack_top is a weak symbol
|
||||
// __stack_top is strong only for libraries or programs.
|
||||
if current_module.is_unit then
|
||||
writer.AsmWriteLn(#9';;.weak');
|
||||
writer.AsmWrite(#9'(global $__stack_top (mut i32) (i32.const ');
|
||||
writer.AsmWrite(tostr(globals.stacksize));
|
||||
writer.AsmWriteLn('))');
|
||||
@ -1070,7 +1080,7 @@ implementation
|
||||
(
|
||||
id : as_wasm_wabt;
|
||||
idtxt : 'Wabt';
|
||||
asmbin : 'wat2wasm';
|
||||
asmbin : 'wasa';
|
||||
asmcmd : '-r --no-canonicalize-leb128s -o $OBJ $EXTRAOPT $ASM';
|
||||
supported_targets : [system_wasm_wasm32];
|
||||
flags : [];
|
||||
|
Loading…
Reference in New Issue
Block a user