Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to build other packages for wasm32? #17

Open
brakubraku opened this issue Jul 22, 2024 · 2 comments
Open

How to build other packages for wasm32? #17

brakubraku opened this issue Jul 22, 2024 · 2 comments

Comments

@brakubraku
Copy link

Trying to add some dependencies to the project (entropy package specifically), but I am running into problems, which I assume stem from building for wasm32 architecture.

Failed to build entropy-0.4.1.10-7ad7e63631182fc592b386e6fc995366bf33c32811197665f528cdb53790f8d9. The failure occurred during the configure step. The exception was:
/home/branko/.ghc-wasm/.cabal/logs/ghc-9.10.0.20240509/entropy-0.4.1.10-7ad7e63631182fc592b386e6fc995366bf33c32811197665f528cdb53790f8d9.log: withFile: user error (CallStack (from HasCallStack):
withMetadata, called at src/Distribution/Simple/Utils.hs:447:12 in Cabal-3.11.0.0-inplace:Distribution.Simple.Utils
Error: cabal:
'/nix/store/p64q67ynh6aiblhlca4gdc2ycc6q6p8g-wasm32-wasi-ghc-9.10/bin/wasm32-wasi-ghc'
exited with an error:
wasm-ld: error: unable to find library -lHSrts-1.0.2_thr
wasm32-wasi-clang: error: linker command failed with exit code 1 (use -v to
see invocation)
wasm32-wasi-ghc-9.10.0.20240509: wasm32-wasi-clang' failed in phase Linker'.
(Exit code: 1)

I wonder if there's any generic "step-by-step" of how to update a package for it to compile to wasm32 without issues?

@brakubraku
Copy link
Author

I opened another issue in jsaddle-wasm, which I believe will help me resolve this.

@amesgen
Copy link
Member

amesgen commented Jul 23, 2024

Hey, thanks for opening the issue!

In your concrete case, the problem is that entropy has uses Cabal's build-type: Custom and therefore a Setup.hs script that has to be executed before building the package. This is not supported by the WASM backend as it is a cross compiler, also see haskell/entropy#42.

One solution for this specific case is to simply change entropy to use build-type: Simple instead: haskell/entropy@main...amesgen:entropy:build-type-simple
You can use this e.g. like this in your cabal.project:

source-repository-package
  type: git
  location: https://github.com/amesgen/entropy
  tag: 98dd0cf23355a1f87af14c10098b9545605ac556

Hope that helps!


I wonder if there's any generic "step-by-step" of how to update a package for it to compile to wasm32 without issues?

Yeah, that sounds nice; here a (probably non-exhaustive) list of some of the things that can cause a package to not compile via the WASM backend:


Also, in case you are interested, feel free to join the GHC WASM Matrix channel: https://matrix.to/#/#haskell-wasm:matrix.terrorjack.com

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants