+ added new target to the compiler: wasm32-wasip2. Not working, yet.

This commit is contained in:
Nikolay Nikolov 2025-03-10 21:53:40 +02:00
parent 09417140de
commit c515d45026
11 changed files with 101 additions and 17 deletions

View File

@ -567,6 +567,7 @@ implementation
end;
system_wasm32_wasip1,
system_wasm32_wasip1threads,
system_wasm32_wasip2,
system_wasm32_embedded:
begin
writer.AsmWrite('.section ');

View File

@ -6497,7 +6497,8 @@ implementation
idtxt : 'WASM';
asmbin : '';
asmcmd : '';
supported_targets : [system_wasm32_embedded,system_wasm32_wasip1,system_wasm32_wasip1threads];
supported_targets : [system_wasm32_embedded,system_wasm32_wasip1,system_wasm32_wasip1threads,
system_wasm32_wasip2];
flags : [af_outputbinary,af_smartlink_sections];
labelprefix : '..@';
labelmaxlen : -1;

View File

@ -200,7 +200,8 @@ implementation
heapsize:=65536;
end;
system_wasm32_wasip1,
system_wasm32_wasip1threads:
system_wasm32_wasip1threads,
system_wasm32_wasip2:
begin
if ts_wasm_threads in init_settings.targetswitches then
maxheapsize:=256*1024*1024

View File

@ -216,7 +216,8 @@
system_aarch64_iphonesim, { 121 }
system_m68k_human68k, { 122 }
system_mipsel_ps1, { 123 }
system_wasm32_wasip1threads { 124 }
system_wasm32_wasip1threads,{ 124 }
system_wasm32_wasip2 { 125 }
);
type

View File

@ -297,7 +297,8 @@ interface
systems_darwin = systems_ios + systems_iphonesim + systems_macosx;
{ all WebAssembly systems }
systems_wasm = [system_wasm32_embedded,system_wasm32_wasip1,system_wasm32_wasip1threads];
systems_wasm = [system_wasm32_embedded,system_wasm32_wasip1,system_wasm32_wasip1threads,
system_wasm32_wasip2];
{all solaris systems }
systems_solaris = [system_sparc_solaris, system_i386_solaris,
@ -399,7 +400,7 @@ interface
system_riscv32_linux,system_riscv64_linux,
system_aarch64_win64,
system_z80_zxspectrum,system_z80_msxdos,
system_wasm32_wasip1,system_wasm32_wasip1threads,
system_wasm32_wasip1,system_wasm32_wasip1threads,system_wasm32_wasip2,
system_loongarch64_linux,system_mipsel_ps1
]+systems_darwin+systems_amigalike;

View File

@ -174,6 +174,78 @@ unit i_wasi;
);
system_wasm32_wasip2_info : tsysteminfo =
(
system : system_wasm32_wasip2;
name : 'The WebAssembly System Interface Preview 2 (WASI 0.2)';
shortname : 'Wasip2';
flags : [tf_under_development,tf_needs_symbol_size,tf_needs_symbol_type,
tf_files_case_sensitive,tf_no_pic_supported,
tf_smartlink_sections,tf_has_winlike_resources,
{ avoid the creation of threadvar tables }
tf_section_threadvars];
cpu : cpu_wasm32;
unit_env : '';
extradefines : 'WASI';
exeext : '.wasm';
defext : '.def';
scriptext : '.sh';
smartext : '.sl';
unitext : '.ppu';
unitlibext : '.ppl';
asmext : '.wat';
objext : '.o';
resext : '';
resobjext : '.or';
sharedlibext : ''; // keep it empty! The sharedlibext drives the export module name
// if this is populated, then the name should be cleared when generating import
staticlibext : '.a';
staticlibprefix : '';
sharedlibprefix : '';
sharedClibext : '.wasm';
staticClibext : '.wasm';
staticClibprefix : '';
sharedClibprefix : '';
importlibprefix : '';
importlibext : '.wasm';
Cprefix : '';
newline : #10;
dirsep : '/';
assem : as_wasm32_wasm;
assemextern : as_wasm32_llvm_mc;
link : ld_int_wasi;
linkextern : ld_wasi;
ar : ar_none;
res : res_wasm;
dbg : dbg_dwarf2;
script : script_unix;
endian : endian_little;
alignment :
(
procalign : 0;
loopalign : 0;
jumpalign : 0;
jumpalignskipmax : 0;
coalescealign : 0;
coalescealignskipmax: 0;
constalignmin : 4;
constalignmax : 16;
varalignmin : 4;
varalignmax : 16;
localalignmin : 4;
localalignmax : 16;
recordalignmin : 0;
recordalignmax : 16;
maxCrecordalign : 16
);
first_parm_offset : 0;
stacksize : 8*1024*1024;
stackalign : 16;
abi : abi_default;
llvmdatalayout : 'todo';
);
implementation
initialization
@ -184,5 +256,8 @@ initialization
{$ifdef wasip1threads}
set_source_info(system_wasm32_wasip1threads_info);
{$endif wasip1threads}
{$ifdef wasip2}
set_source_info(system_wasm32_wasip2_info);
{$endif wasip1}
{$endif CPUWASM32}
end.

View File

@ -401,6 +401,9 @@ initialization
RegisterTarget(system_wasm32_wasip1threads_info);
RegisterImport(system_wasm32_wasip1threads, timportlibwasi);
RegisterExport(system_wasm32_wasip1threads, texportlibwasi);
RegisterTarget(system_wasm32_wasip2_info);
RegisterImport(system_wasm32_wasip2, timportlibwasi);
RegisterExport(system_wasm32_wasip2, texportlibwasi);
RegisterLinker(ld_int_wasi,TInternalLinkerWasi);
RegisterLinker(ld_wasi, tlinkerwasi);
RegisterRes(res_wasm_info,TWinLikeResourceFile);

View File

@ -250,7 +250,8 @@ const
{ 121 } 'iPhoneSim-AArch64',
{ 122 } 'Human68k-m68k',
{ 123 } 'PS1-mipsel',
{ 124 } 'WASIp1threads-WASM32'
{ 124 } 'WASIp1threads-WASM32',
{ 125 } 'WASIp2-WASM32'
);
const

View File

@ -590,7 +590,7 @@ implementation
idtxt : 'BINARYEN';
asmbin : 'wasm-as';
asmcmd : '$ASM $EXTRAOPT';
supported_targets : [system_wasm32_embedded,system_wasm32_wasip1,system_wasm32_wasip1threads];
supported_targets : [system_wasm32_embedded,system_wasm32_wasip1,system_wasm32_wasip1threads,system_wasm32_wasip2];
flags : [];
labelprefix : 'L';
labelmaxlen : -1;

View File

@ -438,7 +438,7 @@ implementation
idtxt : 'LLVM-MC-10';
asmbin : 'llvm-mc-10';
asmcmd : '--assemble --arch=wasm32 -mattr=+sign-ext,+exception-handling,+bulk-memory,+atomics --filetype=obj -o $OBJ $EXTRAOPT $ASM';
supported_targets : [system_wasm32_embedded,system_wasm32_wasip1,system_wasm32_wasip1threads];
supported_targets : [system_wasm32_embedded,system_wasm32_wasip1,system_wasm32_wasip1threads,system_wasm32_wasip2];
flags : [af_smartlink_sections];
labelprefix : '.L';
labelmaxlen : -1;
@ -451,7 +451,7 @@ implementation
idtxt : 'LLVM-MC-11';
asmbin : 'llvm-mc-11';
asmcmd : '--assemble --arch=wasm32 -mattr=+sign-ext,+exception-handling,+bulk-memory,+atomics,+reference-types --filetype=obj -o $OBJ $EXTRAOPT $ASM';
supported_targets : [system_wasm32_embedded,system_wasm32_wasip1,system_wasm32_wasip1threads];
supported_targets : [system_wasm32_embedded,system_wasm32_wasip1,system_wasm32_wasip1threads,system_wasm32_wasip2];
flags : [af_smartlink_sections];
labelprefix : '.L';
labelmaxlen : -1;
@ -464,7 +464,7 @@ implementation
idtxt : 'LLVM-MC-12';
asmbin : 'llvm-mc-12';
asmcmd : '--assemble --arch=wasm32 -mattr=+sign-ext,+exception-handling,+bulk-memory,+atomics,+reference-types --filetype=obj -o $OBJ $EXTRAOPT $ASM';
supported_targets : [system_wasm32_embedded,system_wasm32_wasip1,system_wasm32_wasip1threads];
supported_targets : [system_wasm32_embedded,system_wasm32_wasip1,system_wasm32_wasip1threads,system_wasm32_wasip2];
flags : [af_smartlink_sections];
labelprefix : '.L';
labelmaxlen : -1;
@ -489,7 +489,7 @@ implementation
idtxt : 'LLVM-MC-13';
asmbin : 'llvm-mc-13';
asmcmd : '--assemble --arch=wasm32 -mattr=+sign-ext,+exception-handling,+bulk-memory,+atomics,+reference-types --filetype=obj --no-type-check -o $OBJ $EXTRAOPT $ASM';
supported_targets : [system_wasm32_embedded,system_wasm32_wasip1,system_wasm32_wasip1threads];
supported_targets : [system_wasm32_embedded,system_wasm32_wasip1,system_wasm32_wasip1threads,system_wasm32_wasip2];
flags : [af_smartlink_sections];
labelprefix : '.L';
labelmaxlen : -1;
@ -506,7 +506,7 @@ implementation
idtxt : 'LLVM-MC-14';
asmbin : 'llvm-mc-14';
asmcmd : '--assemble --arch=wasm32 -mattr=+sign-ext,+exception-handling,+bulk-memory,+atomics,+reference-types --filetype=obj --no-type-check -o $OBJ $EXTRAOPT $ASM';
supported_targets : [system_wasm32_embedded,system_wasm32_wasip1,system_wasm32_wasip1threads];
supported_targets : [system_wasm32_embedded,system_wasm32_wasip1,system_wasm32_wasip1threads,system_wasm32_wasip2];
flags : [af_smartlink_sections];
labelprefix : '.L';
labelmaxlen : -1;
@ -525,7 +525,7 @@ implementation
idtxt : 'LLVM-MC-15';
asmbin : 'llvm-mc-15';
asmcmd : '--assemble --arch=wasm32 -mattr=+sign-ext,+exception-handling,+bulk-memory,+atomics,+reference-types --filetype=obj --no-type-check -o $OBJ $EXTRAOPT $ASM';
supported_targets : [system_wasm32_embedded,system_wasm32_wasip1,system_wasm32_wasip1threads];
supported_targets : [system_wasm32_embedded,system_wasm32_wasip1,system_wasm32_wasip1threads,system_wasm32_wasip2];
flags : [af_smartlink_sections];
labelprefix : '.L';
labelmaxlen : -1;
@ -541,7 +541,7 @@ implementation
idtxt : 'LLVM-MC-16';
asmbin : 'llvm-mc-16';
asmcmd : '--assemble --arch=wasm32 -mattr=+sign-ext,+exception-handling,+bulk-memory,+atomics,+reference-types --filetype=obj --no-type-check -o $OBJ $EXTRAOPT $ASM';
supported_targets : [system_wasm32_embedded,system_wasm32_wasip1,system_wasm32_wasip1threads];
supported_targets : [system_wasm32_embedded,system_wasm32_wasip1,system_wasm32_wasip1threads,system_wasm32_wasip2];
flags : [af_smartlink_sections];
labelprefix : '.L';
labelmaxlen : -1;
@ -561,7 +561,7 @@ implementation
idtxt : 'LLVM-MC-17';
asmbin : 'llvm-mc-17';
asmcmd : '--assemble --arch=wasm32 -mattr=+sign-ext,+exception-handling,+bulk-memory,+atomics,+reference-types --filetype=obj --no-type-check -o $OBJ $EXTRAOPT $ASM';
supported_targets : [system_wasm32_embedded,system_wasm32_wasip1,system_wasm32_wasip1threads];
supported_targets : [system_wasm32_embedded,system_wasm32_wasip1,system_wasm32_wasip1threads,system_wasm32_wasip2];
flags : [af_smartlink_sections];
labelprefix : '.L';
labelmaxlen : -1;
@ -577,7 +577,7 @@ implementation
idtxt : 'LLVM-MC';
asmbin : 'llvm-mc';
asmcmd : '--assemble --arch=wasm32 -mattr=+sign-ext,+exception-handling,+bulk-memory,+atomics,+reference-types --filetype=obj --no-type-check -o $OBJ $EXTRAOPT $ASM';
supported_targets : [system_wasm32_embedded,system_wasm32_wasip1,system_wasm32_wasip1threads];
supported_targets : [system_wasm32_embedded,system_wasm32_wasip1,system_wasm32_wasip1threads,system_wasm32_wasip2];
flags : [af_smartlink_sections];
labelprefix : '.L';
labelmaxlen : -1;

View File

@ -1094,7 +1094,7 @@ implementation
idtxt : 'WASA';
asmbin : 'wasa';
asmcmd : '-r --no-canonicalize-leb128s -o $OBJ $EXTRAOPT $ASM';
supported_targets : [system_wasm32_embedded,system_wasm32_wasip1,system_wasm32_wasip1threads];
supported_targets : [system_wasm32_embedded,system_wasm32_wasip1,system_wasm32_wasip1threads,system_wasm32_wasip2];
flags : [];
labelprefix : 'L';
labelmaxlen : -1;