[Git][ghc/ghc][master] Fix reST in users guide
Marge Bot (@marge-bot)
gitlab at gitlab.haskell.org
Mon Feb 19 12:13:58 UTC 2024
Marge Bot pushed to branch master at Glasgow Haskell Compiler / GHC
Commits:
17e309d2 by John Ericson at 2024-02-19T07:12:49-05:00
Fix reST in users guide
It appears that aef587f65de642142c1dcba0335a301711aab951 wasn't valid syntax.
- - - - -
1 changed file:
- docs/users_guide/javascript.rst
Changes:
=====================================
docs/users_guide/javascript.rst
=====================================
@@ -157,7 +157,7 @@ passed as an ``Int`` to a ``Callback`` that accepts a ``JSVal``:
releaseCallback add3
Callbacks as Foreign Exports
-~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+^^^^^^^^^^^^^^^^^^^^^^^^^^^^
JavaScript callbacks allow for a sort of FFI exports via FFI imports. To do
this, a global JavaScript variable is set, and that global variable can then
@@ -331,7 +331,7 @@ Next, the JavaScript ``h$getcwd`` function demonstrates several details:
in the error case.
Writing JavaScript Functions to be NodeJS and Browser Aware
-~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
In the above example of implementing ``getcwd``, the function we use in the JavaScript
implementation is from NodeJS, and the behaviour doesn't make sense to implement in a
@@ -434,7 +434,7 @@ C functions compiled with Emscripten get a "_" prepended to their name in
JavaScript. For example, C "malloc" becomes "_malloc" in JavaScript.
EMCC pragmas
-~~~~~~~~~~~~
+^^^^^^^^^^^^
By default the EMCC linker drops code considered dead and it has no way to know
which code is alive due to some call from Haskell or from a JavaScript wrapper.
@@ -470,16 +470,19 @@ passed once; the latter argument overrides the former ones).
This pragma allows additional options to be passed to Emscripten if need be. We
already pass:
+
- `-sSINGLE_FILE=1`: required to create a single `.js` file as artefact
(otherwise `.wasm` files corresponding to C codes need to be present in the
current working directory when invoking the resulting `.js` file).
+
- `-sALLOW_TABLE_GROWTH`: required to support `addFunction`
+
- `-sEXPORTED_RUNTIME_METHODS` and `-sEXPORTED_FUNCTIONS`: see above.
Be careful because some extra arguments may break the build in unsuspected ways.
Wrappers
-~~~~~~~~
+^^^^^^^^
The JavaScript backend doesn't generate wrappers for foreign imports to call
directly into the compiled C code. I.e. given the following foreign import:
@@ -513,7 +516,7 @@ GHC's JavaScript rts provides helper functions for this in `rts/js/mem.js`. See
`h$copyFromHeap`, `h$copyToHeap`, `h$initHeapBuffer`, etc.
Callbacks
-~~~~~~~~~
+^^^^^^^^^
Some C functions take function pointers as arguments (e.g. callbacks). This is
supported by the JavaScript backend but requires some work from the wrapper
View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/17e309d25bc943ddf9d331b157cb43939f0cf0e9
--
View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/17e309d25bc943ddf9d331b157cb43939f0cf0e9
You're receiving this email because of your account on gitlab.haskell.org.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.haskell.org/pipermail/ghc-commits/attachments/20240219/1bdd0001/attachment-0001.html>
More information about the ghc-commits
mailing list