diff --git a/compiler/options.pas b/compiler/options.pas index 59e4d377bf..9b83f86f56 100644 --- a/compiler/options.pas +++ b/compiler/options.pas @@ -4956,6 +4956,9 @@ begin if tf_x86_far_procs_push_odd_bp in target_info.flags then if not UpdateTargetSwitchStr('FARPROCSPUSHODDBP', init_settings.targetswitches, true) then InternalError(2013092802); + if tf_wasm_threads in target_info.flags then + if not UpdateTargetSwitchStr('WASMTHREADS', init_settings.targetswitches, true) then + InternalError(2025022701); { Use standard Android NDK prefixes when cross-compiling } if (source_info.system<>target_info.system) and (target_info.system in systems_android) then diff --git a/compiler/systems.inc b/compiler/systems.inc index 30979cfeda..025d576e5c 100644 --- a/compiler/systems.inc +++ b/compiler/systems.inc @@ -215,7 +215,8 @@ system_loongarch64_linux, { 120 } system_aarch64_iphonesim, { 121 } system_m68k_human68k, { 122 } - system_mipsel_ps1 { 123 } + system_mipsel_ps1, { 123 } + system_wasm32_wasip1threads { 124 } ); type diff --git a/compiler/systems.pas b/compiler/systems.pas index 0e6d8f88d3..c4c33d5d67 100644 --- a/compiler/systems.pas +++ b/compiler/systems.pas @@ -181,14 +181,16 @@ interface { units are initialized by direct calls and not table driven, in particular for a small amount of units, this results in smaller executables } - tf_init_final_units_by_calls + tf_init_final_units_by_calls, + { indicates that the default value of the ts_wasm_threads target switch is 'on' for this target } + tf_wasm_threads ); psysteminfo = ^tsysteminfo; { using packed causes bus errors on processors which require alignment } tsysteminfo = record system : tsystem; - name : string[53]; + name : string[88]; shortname : string[12]; flags : set of tsystemflags; cpu : tsystemcpu; diff --git a/compiler/systems/i_wasi.pas b/compiler/systems/i_wasi.pas index 47151babc3..c9f84253e3 100644 --- a/compiler/systems/i_wasi.pas +++ b/compiler/systems/i_wasi.pas @@ -101,6 +101,79 @@ unit i_wasi; ); + system_wasm32_wasip1threads_info : tsysteminfo = + ( + system : system_wasm32_wasip1threads; + name : 'The WebAssembly System Interface Preview 1 with Multithreading (WASI 0.1 + wasi-threads)'; + shortname : 'Wasip1threads'; + flags : [tf_under_development,tf_needs_symbol_size,tf_needs_symbol_type, + tf_files_case_sensitive, + tf_smartlink_sections,tf_has_winlike_resources, + { avoid the creation of threadvar tables } + tf_section_threadvars, + tf_wasm_threads]; + cpu : cpu_wasm32; + unit_env : ''; + extradefines : 'WASI;WASIP1'; + 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 @@ -108,5 +181,8 @@ initialization {$ifdef wasip1} set_source_info(system_wasm32_wasip1_info); {$endif wasip1} + {$ifdef wasip1threads} + set_source_info(system_wasm32_wasip1threads_info); + {$endif wasip1threads} {$endif CPUWASM32} end.