+ produce a target_features section when compiling with -CTwasmthreads

This commit is contained in:
Nikolay Nikolov 2022-05-28 04:04:02 +03:00
parent 1dd80d596d
commit 7cd082ba5f
2 changed files with 23 additions and 3 deletions

View File

@ -169,7 +169,7 @@ interface
implementation
uses
verbose,version;
verbose,version,globals;
procedure WriteUleb5(d: tdynamicarray; v: uint64);
var
@ -1655,6 +1655,19 @@ implementation
Writer.write(WasmModuleMagic,SizeOf(WasmModuleMagic));
Writer.write(WasmVersion,SizeOf(WasmVersion));
if ts_wasm_threads in current_settings.targetswitches then
begin
WriteUleb(FWasmCustomSections[wcstTargetFeatures],4);
WriteUleb(FWasmCustomSections[wcstTargetFeatures],$2B);
WriteName(FWasmCustomSections[wcstTargetFeatures],'atomics');
WriteUleb(FWasmCustomSections[wcstTargetFeatures],$2B);
WriteName(FWasmCustomSections[wcstTargetFeatures],'bulk-memory');
WriteUleb(FWasmCustomSections[wcstTargetFeatures],$2B);
WriteName(FWasmCustomSections[wcstTargetFeatures],'mutable-globals');
WriteUleb(FWasmCustomSections[wcstTargetFeatures],$2B);
WriteName(FWasmCustomSections[wcstTargetFeatures],'sign-ext');
end;
{ Write the producers section:
https://github.com/WebAssembly/tool-conventions/blob/main/ProducersSection.md }
WriteUleb(FWasmCustomSections[wcstProducers],2);
@ -1722,6 +1735,11 @@ implementation
end;
WriteWasmCustomSection(wcstProducers);
Inc(section_nr);
if ts_wasm_threads in current_settings.targetswitches then
begin
WriteWasmCustomSection(wcstTargetFeatures);
Inc(section_nr);
end;
result:=true;
end;

View File

@ -50,14 +50,16 @@ type
wcstLinking,
wcstRelocCode,
wcstRelocData,
wcstProducers);
wcstProducers,
wcstTargetFeatures);
const
WasmCustomSectionName: array [TWasmCustomSectionType] of string =
('linking',
'reloc.CODE',
'reloc.DATA',
'producers');
'producers',
'target_features');
type
TWasmRelocationType = (