i_wasi.pas 9.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263
  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. );
  93. system_wasm32_wasip1threads_info : tsysteminfo =
  94. (
  95. system : system_wasm32_wasip1threads;
  96. name : 'The WebAssembly System Interface Preview 1 with Multithreading (WASI 0.1 + wasi-threads)';
  97. shortname : 'Wasip1threads';
  98. flags : [tf_needs_symbol_size,tf_needs_symbol_type,
  99. tf_files_case_sensitive,tf_no_pic_supported,
  100. tf_smartlink_sections,tf_has_winlike_resources,
  101. { avoid the creation of threadvar tables }
  102. tf_section_threadvars,
  103. tf_wasm_threads];
  104. cpu : cpu_wasm32;
  105. unit_env : '';
  106. extradefines : 'WASI;WASIP1';
  107. exeext : '.wasm';
  108. defext : '.def';
  109. scriptext : '.sh';
  110. smartext : '.sl';
  111. unitext : '.ppu';
  112. unitlibext : '.ppl';
  113. asmext : '.wat';
  114. objext : '.o';
  115. resext : '';
  116. resobjext : '.or';
  117. sharedlibext : ''; // keep it empty! The sharedlibext drives the export module name
  118. // if this is populated, then the name should be cleared when generating import
  119. staticlibext : '.a';
  120. staticlibprefix : '';
  121. sharedlibprefix : '';
  122. sharedClibext : '.wasm';
  123. staticClibext : '.wasm';
  124. staticClibprefix : '';
  125. sharedClibprefix : '';
  126. importlibprefix : '';
  127. importlibext : '.wasm';
  128. Cprefix : '';
  129. newline : #10;
  130. dirsep : '/';
  131. assem : as_wasm32_wasm;
  132. assemextern : as_wasm32_llvm_mc;
  133. link : ld_int_wasi;
  134. linkextern : ld_wasi;
  135. ar : ar_none;
  136. res : res_wasm;
  137. dbg : dbg_dwarf2;
  138. script : script_unix;
  139. endian : endian_little;
  140. alignment :
  141. (
  142. procalign : 0;
  143. loopalign : 0;
  144. jumpalign : 0;
  145. jumpalignskipmax : 0;
  146. coalescealign : 0;
  147. coalescealignskipmax: 0;
  148. constalignmin : 4;
  149. constalignmax : 16;
  150. varalignmin : 4;
  151. varalignmax : 16;
  152. localalignmin : 4;
  153. localalignmax : 16;
  154. recordalignmin : 0;
  155. recordalignmax : 16;
  156. maxCrecordalign : 16
  157. );
  158. first_parm_offset : 0;
  159. stacksize : 8*1024*1024;
  160. stackalign : 16;
  161. abi : abi_default;
  162. llvmdatalayout : 'todo';
  163. );
  164. system_wasm32_wasip2_info : tsysteminfo =
  165. (
  166. system : system_wasm32_wasip2;
  167. name : 'The WebAssembly System Interface Preview 2 (WASI 0.2)';
  168. shortname : 'Wasip2';
  169. flags : [tf_under_development,tf_needs_symbol_size,tf_needs_symbol_type,
  170. tf_files_case_sensitive,tf_no_pic_supported,
  171. tf_smartlink_sections,tf_has_winlike_resources,
  172. { avoid the creation of threadvar tables }
  173. tf_section_threadvars];
  174. cpu : cpu_wasm32;
  175. unit_env : '';
  176. extradefines : 'WASI';
  177. exeext : '.wasm';
  178. defext : '.def';
  179. scriptext : '.sh';
  180. smartext : '.sl';
  181. unitext : '.ppu';
  182. unitlibext : '.ppl';
  183. asmext : '.wat';
  184. objext : '.o';
  185. resext : '';
  186. resobjext : '.or';
  187. sharedlibext : ''; // keep it empty! The sharedlibext drives the export module name
  188. // if this is populated, then the name should be cleared when generating import
  189. staticlibext : '.a';
  190. staticlibprefix : '';
  191. sharedlibprefix : '';
  192. sharedClibext : '.wasm';
  193. staticClibext : '.wasm';
  194. staticClibprefix : '';
  195. sharedClibprefix : '';
  196. importlibprefix : '';
  197. importlibext : '.wasm';
  198. Cprefix : '';
  199. newline : #10;
  200. dirsep : '/';
  201. assem : as_wasm32_wasm;
  202. assemextern : as_wasm32_llvm_mc;
  203. link : ld_int_wasi;
  204. linkextern : ld_wasi;
  205. ar : ar_none;
  206. res : res_wasm;
  207. dbg : dbg_dwarf2;
  208. script : script_unix;
  209. endian : endian_little;
  210. alignment :
  211. (
  212. procalign : 0;
  213. loopalign : 0;
  214. jumpalign : 0;
  215. jumpalignskipmax : 0;
  216. coalescealign : 0;
  217. coalescealignskipmax: 0;
  218. constalignmin : 4;
  219. constalignmax : 16;
  220. varalignmin : 4;
  221. varalignmax : 16;
  222. localalignmin : 4;
  223. localalignmax : 16;
  224. recordalignmin : 0;
  225. recordalignmax : 16;
  226. maxCrecordalign : 16
  227. );
  228. first_parm_offset : 0;
  229. stacksize : 8*1024*1024;
  230. stackalign : 16;
  231. abi : abi_default;
  232. llvmdatalayout : 'todo';
  233. );
  234. implementation
  235. initialization
  236. {$ifdef CPUWASM32}
  237. {$ifdef wasip1}
  238. set_source_info(system_wasm32_wasip1_info);
  239. {$endif wasip1}
  240. {$ifdef wasip1threads}
  241. set_source_info(system_wasm32_wasip1threads_info);
  242. {$endif wasip1threads}
  243. {$ifdef wasip2}
  244. set_source_info(system_wasm32_wasip2_info);
  245. {$endif wasip1}
  246. {$endif CPUWASM32}
  247. end.