i_wasi.pas 9.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266
  1. {
  2. Copyright (c) 2019 by Dmitry Boyarintsev
  3. This unit implements support information structures for WebAssembly
  4. This program is free software; you can redistribute it and/or modify
  5. it under the terms of the GNU General Public License as published by
  6. the Free Software Foundation; either version 2 of the License, or
  7. (at your option) any later version.
  8. This program is distributed in the hope that it will be useful,
  9. but WITHOUT ANY WARRANTY; without even the implied warranty of
  10. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  11. GNU General Public License for more details.
  12. You should have received a copy of the GNU General Public License
  13. along with this program; if not, write to the Free Software
  14. Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  15. ****************************************************************************
  16. }
  17. unit i_wasi;
  18. {$i fpcdefs.inc}
  19. interface
  20. uses
  21. systems,rescmn;
  22. const
  23. system_wasm32_wasip1_info : tsysteminfo =
  24. (
  25. system : system_wasm32_wasip1;
  26. name : 'The WebAssembly System Interface Preview 1 (WASI 0.1)';
  27. shortname : 'Wasip1';
  28. flags : [tf_needs_symbol_size,tf_needs_symbol_type,
  29. tf_files_case_sensitive,tf_no_pic_supported,
  30. tf_smartlink_sections,tf_has_winlike_resources,
  31. { avoid the creation of threadvar tables }
  32. tf_section_threadvars];
  33. cpu : cpu_wasm32;
  34. unit_env : '';
  35. extradefines : 'WASI';
  36. exeext : '.wasm';
  37. defext : '.def';
  38. scriptext : '.sh';
  39. smartext : '.sl';
  40. unitext : '.ppu';
  41. unitlibext : '.ppl';
  42. asmext : '.wat';
  43. objext : '.o';
  44. resext : '';
  45. resobjext : '.or';
  46. sharedlibext : ''; // keep it empty! The sharedlibext drives the export module name
  47. // if this is populated, then the name should be cleared when generating import
  48. staticlibext : '.a';
  49. staticlibprefix : '';
  50. sharedlibprefix : '';
  51. sharedClibext : '.wasm';
  52. staticClibext : '.wasm';
  53. staticClibprefix : '';
  54. sharedClibprefix : '';
  55. importlibprefix : '';
  56. importlibext : '.wasm';
  57. Cprefix : '';
  58. newline : #10;
  59. dirsep : '/';
  60. assem : as_wasm32_wasm;
  61. assemextern : as_wasm32_llvm_mc;
  62. link : ld_int_wasi;
  63. linkextern : ld_wasi;
  64. ar : ar_none;
  65. res : res_wasm;
  66. dbg : dbg_dwarf2;
  67. script : script_unix;
  68. endian : endian_little;
  69. alignment :
  70. (
  71. procalign : 0;
  72. loopalign : 0;
  73. jumpalign : 0;
  74. jumpalignskipmax : 0;
  75. coalescealign : 0;
  76. coalescealignskipmax: 0;
  77. constalignmin : 4;
  78. constalignmax : 16;
  79. varalignmin : 4;
  80. varalignmax : 16;
  81. localalignmin : 4;
  82. localalignmax : 16;
  83. recordalignmin : 0;
  84. recordalignmax : 16;
  85. maxCrecordalign : 16
  86. );
  87. first_parm_offset : 0;
  88. stacksize : 8*1024*1024;
  89. stackalign : 16;
  90. abi : abi_default;
  91. llvmdatalayout : 'todo';
  92. mos6502page0alloc : [];
  93. );
  94. system_wasm32_wasip1threads_info : tsysteminfo =
  95. (
  96. system : system_wasm32_wasip1threads;
  97. name : 'The WebAssembly System Interface Preview 1 with Multithreading (WASI 0.1 + wasi-threads)';
  98. shortname : 'Wasip1threads';
  99. flags : [tf_needs_symbol_size,tf_needs_symbol_type,
  100. tf_files_case_sensitive,tf_no_pic_supported,
  101. tf_smartlink_sections,tf_has_winlike_resources,
  102. { avoid the creation of threadvar tables }
  103. tf_section_threadvars,
  104. tf_wasm_threads];
  105. cpu : cpu_wasm32;
  106. unit_env : '';
  107. extradefines : 'WASI;WASIP1';
  108. exeext : '.wasm';
  109. defext : '.def';
  110. scriptext : '.sh';
  111. smartext : '.sl';
  112. unitext : '.ppu';
  113. unitlibext : '.ppl';
  114. asmext : '.wat';
  115. objext : '.o';
  116. resext : '';
  117. resobjext : '.or';
  118. sharedlibext : ''; // keep it empty! The sharedlibext drives the export module name
  119. // if this is populated, then the name should be cleared when generating import
  120. staticlibext : '.a';
  121. staticlibprefix : '';
  122. sharedlibprefix : '';
  123. sharedClibext : '.wasm';
  124. staticClibext : '.wasm';
  125. staticClibprefix : '';
  126. sharedClibprefix : '';
  127. importlibprefix : '';
  128. importlibext : '.wasm';
  129. Cprefix : '';
  130. newline : #10;
  131. dirsep : '/';
  132. assem : as_wasm32_wasm;
  133. assemextern : as_wasm32_llvm_mc;
  134. link : ld_int_wasi;
  135. linkextern : ld_wasi;
  136. ar : ar_none;
  137. res : res_wasm;
  138. dbg : dbg_dwarf2;
  139. script : script_unix;
  140. endian : endian_little;
  141. alignment :
  142. (
  143. procalign : 0;
  144. loopalign : 0;
  145. jumpalign : 0;
  146. jumpalignskipmax : 0;
  147. coalescealign : 0;
  148. coalescealignskipmax: 0;
  149. constalignmin : 4;
  150. constalignmax : 16;
  151. varalignmin : 4;
  152. varalignmax : 16;
  153. localalignmin : 4;
  154. localalignmax : 16;
  155. recordalignmin : 0;
  156. recordalignmax : 16;
  157. maxCrecordalign : 16
  158. );
  159. first_parm_offset : 0;
  160. stacksize : 8*1024*1024;
  161. stackalign : 16;
  162. abi : abi_default;
  163. llvmdatalayout : 'todo';
  164. mos6502page0alloc : [];
  165. );
  166. system_wasm32_wasip2_info : tsysteminfo =
  167. (
  168. system : system_wasm32_wasip2;
  169. name : 'The WebAssembly System Interface Preview 2 (WASI 0.2)';
  170. shortname : 'Wasip2';
  171. flags : [tf_under_development,tf_needs_symbol_size,tf_needs_symbol_type,
  172. tf_files_case_sensitive,tf_no_pic_supported,
  173. tf_smartlink_sections,tf_has_winlike_resources,
  174. { avoid the creation of threadvar tables }
  175. tf_section_threadvars];
  176. cpu : cpu_wasm32;
  177. unit_env : '';
  178. extradefines : 'WASI';
  179. exeext : '.wasm';
  180. defext : '.def';
  181. scriptext : '.sh';
  182. smartext : '.sl';
  183. unitext : '.ppu';
  184. unitlibext : '.ppl';
  185. asmext : '.wat';
  186. objext : '.o';
  187. resext : '';
  188. resobjext : '.or';
  189. sharedlibext : ''; // keep it empty! The sharedlibext drives the export module name
  190. // if this is populated, then the name should be cleared when generating import
  191. staticlibext : '.a';
  192. staticlibprefix : '';
  193. sharedlibprefix : '';
  194. sharedClibext : '.wasm';
  195. staticClibext : '.wasm';
  196. staticClibprefix : '';
  197. sharedClibprefix : '';
  198. importlibprefix : '';
  199. importlibext : '.wasm';
  200. Cprefix : '';
  201. newline : #10;
  202. dirsep : '/';
  203. assem : as_wasm32_wasm;
  204. assemextern : as_wasm32_llvm_mc;
  205. link : ld_int_wasi;
  206. linkextern : ld_wasi;
  207. ar : ar_none;
  208. res : res_wasm;
  209. dbg : dbg_dwarf2;
  210. script : script_unix;
  211. endian : endian_little;
  212. alignment :
  213. (
  214. procalign : 0;
  215. loopalign : 0;
  216. jumpalign : 0;
  217. jumpalignskipmax : 0;
  218. coalescealign : 0;
  219. coalescealignskipmax: 0;
  220. constalignmin : 4;
  221. constalignmax : 16;
  222. varalignmin : 4;
  223. varalignmax : 16;
  224. localalignmin : 4;
  225. localalignmax : 16;
  226. recordalignmin : 0;
  227. recordalignmax : 16;
  228. maxCrecordalign : 16
  229. );
  230. first_parm_offset : 0;
  231. stacksize : 8*1024*1024;
  232. stackalign : 16;
  233. abi : abi_default;
  234. llvmdatalayout : 'todo';
  235. mos6502page0alloc : [];
  236. );
  237. implementation
  238. initialization
  239. {$ifdef CPUWASM32}
  240. {$ifdef wasip1}
  241. set_source_info(system_wasm32_wasip1_info);
  242. {$endif wasip1}
  243. {$ifdef wasip1threads}
  244. set_source_info(system_wasm32_wasip1threads_info);
  245. {$endif wasip1threads}
  246. {$ifdef wasip2}
  247. set_source_info(system_wasm32_wasip2_info);
  248. {$endif wasip1}
  249. {$endif CPUWASM32}
  250. end.