asterius icon indicating copy to clipboard operation
asterius copied to clipboard

Exported static Haskell function is not exposed when built with ahc-cabal

Open acrylic-origami opened this issue 4 years ago • 1 comments

Describe the bug A clear and concise description of what the bug is.

When building with ahc-cabal + ahc-dist, it seems that exported from Haskell aren't populated in the Asterius instance. When building with ahc-link they are exposed.

To Reproduce Steps to reproduce the behavior.

  1. Take the js-ffi test from /asterius/tests/ and convert it into a Cabal project
  2. Build with ahs-cabal build and link+run with ahc-dist --input-exe <path-to-cabal-executable>/jsffi --input-mjs jsffi.mjs --export-function=mult_hs_int --export-function=mult_hs_double --export-function=putchar --run
  3. TypeError: e.exports.mult_hs_int is not a function

Alternatively, linking with ahc-link in exactly the same command (except of course input-hs jsffi.hs) will work properly.

This also occurs with the browser. Here is a gist with this test set up.

Expected behavior A clear and concise description of what you expected to happen.

Both ahc-dist and ahc-link expose Haskell functions to JS.

Environment

  • OS name + version: MacOS Mojave 10.14.2
  • Version of the code: Asterius docker image 018c2194f998 (June 16, 2020, from terrorjack/asterius)

Additional context Add any other context about the problem here.

Thinking that it may be a dead code issue I've also tried this with --no-gc-sections and --extra-root-symbol=... to no avail. I think that I've read most of the documentation about exporting Haskell functions chasing this bug by now, am I missing something?

acrylic-origami avatar Jun 18 '20 11:06 acrylic-origami

Any updates on this one?

ingun37 avatar Jul 31 '21 16:07 ingun37