Skip to content

pkgsCross.wasi32.haskell.compiler.{ghcHEAD,ghc961}: new wasm backend #225000

Draft
sternenseemann wants to merge 8 commits intoNixOS:haskell-updatesfrom
sternenseemann:ghc-wasi
Draft

pkgsCross.wasi32.haskell.compiler.{ghcHEAD,ghc961}: new wasm backend #225000
sternenseemann wants to merge 8 commits intoNixOS:haskell-updatesfrom
sternenseemann:ghc-wasi

Conversation

@sternenseemann
Copy link
Member

Description of changes
Things done
  • Built on platform(s)
    • x86_64-linux
    • aarch64-linux
    • x86_64-darwin
    • aarch64-darwin
  • For non-Linux: Is sandbox = true set in nix.conf? (See Nix manual)
  • Tested, as applicable:
  • Tested compilation of all packages that depend on this change using nix-shell -p nixpkgs-review --run "nixpkgs-review rev HEAD". Note: all changes have to be committed, also see nixpkgs-review usage
  • Tested basic functionality of all binary files (usually in ./result/bin/)
  • 23.05 Release Notes (or backporting 22.11 Release notes)
    • (Package updates) Added a release notes entry if the change is major or breaking
    • (Module updates) Added a release notes entry if the change is significant
    • (Module addition) Added a release notes entry if adding a new NixOS module
  • Fits CONTRIBUTING.md.

@sternenseemann sternenseemann changed the title Ghc wasi pkgsCross.wasi32.haskell.compiler.{ghcHEAD,ghc961}: new wasm backend Apr 6, 2023
@github-actions github-actions bot added the 6.topic: haskell General-purpose, statically typed, purely functional programming language label Apr 6, 2023
@ofborg ofborg bot added the 8.has: package (new) This PR adds a new package label Apr 6, 2023
@ofborg ofborg bot added 11.by: package-maintainer This PR was created by a maintainer of all the package it changes. 10.rebuild-darwin: 1-10 This PR causes between 1 and 10 packages to rebuild on Darwin. 10.rebuild-linux: 1-10 This PR causes between 1 and 10 packages to rebuild on Linux. labels Apr 6, 2023
@ofborg ofborg bot added 10.rebuild-darwin: 1 This PR causes 1 package to rebuild on Darwin. 10.rebuild-linux: 1 This PR causes 1 package to rebuild on Linux. labels Apr 6, 2023
@expipiplus1
Copy link
Contributor

Exciting! Thanks @sternenseemann

This will catch issue like the one that was present: Since we did not
make ../llvm writeable, the patch wouldn't apply.
Seems like sometime between LLVM 12 and 16 the platform check sneaked
into libcxx as well.
pkgsCross.wasi32.llvmPackages: 12 -> 16

* It appears BULK_MEMORY_SOURCES no longer needs to be set to be empty
  to compile firefox. Without it, the build of wasilibc would fail if
  enableThreads is true.

* Include preliminary support for the experimental threads support in
  wasilibc which provides pthreads API. If wasilibc is built with
  support, is exposed via passthru and libcxx / libcxxabi are built with
  threads support accordingly.

  See also:
  - WebAssembly/wasi-sdk#274
  - WebAssembly/wasi-sdk#301
  - WebAssembly/wasi-sdk#314

  wasi-sdk ships it by default, but as a separate variant of libc which
  would be a hassle for us. Let's just make it optional for now.

  You can try it out using the following overlay:

      self: super: {
        wasilibc = super.wasilibc.override { enableThreads = true; };
      }

  Flags for libc++abi are copied from wasi-sdk.
This is a quicker way than building firefox to see if linking works.
Seems like in a lot of cases the build->build compiler is propagated (?)
somehow, but we can also provide it explicitly and have it accompany the
stage0 GHC explicitly by setting the *_STAGE0 environment variables.
@sternenseemann
Copy link
Member Author

Progress report: A first step is done with #241739 which updates LLVM and wasilibc which are both a requisite for building GHC's wasm backend in nixpkgs. This doesn't get allow us to build GHC yet, though:

All of this leads me to conclude that the WASM backend is a technology preview in a very different sense to the JS backend. Consequently, I'm quite unenthusiastic about packaging this at the moment, since there is not really a clean way to do so. We'd need something akin to a pkgsCross.wasi32-ghc with a lot of weird patches—I'd rather wait for GHC upstream finding more permanent solutions or getting their changes into an upstreamable shape (i.e. I get the impression that the changes made for GHC's benefit would break other code).

@ofborg ofborg bot added 10.rebuild-darwin: 11-100 This PR causes between 11 and 100 packages to rebuild on Darwin. 10.rebuild-linux: 11-100 This PR causes between 11 and 100 packages to rebuild on Linux. and removed 10.rebuild-darwin: 1 This PR causes 1 package to rebuild on Darwin. labels Jul 7, 2023
@ofborg ofborg bot removed 10.rebuild-darwin: 1-10 This PR causes between 1 and 10 packages to rebuild on Darwin. 10.rebuild-linux: 1 This PR causes 1 package to rebuild on Linux. 10.rebuild-linux: 1-10 This PR causes between 1 and 10 packages to rebuild on Linux. labels Jul 7, 2023
@nixos-discourse
Copy link

This pull request has been mentioned on NixOS Discourse. There might be relevant details there:

https://discourse.nixos.org/t/how-to-get-haskell-wasm-work-for-haskell-flake/38318/3

@wegank wegank added 2.status: stale https://github.com/NixOS/nixpkgs/blob/master/.github/STALE-BOT.md 2.status: merge conflict This PR has merge conflicts with the target branch labels Mar 19, 2024
@stale stale bot removed the 2.status: stale https://github.com/NixOS/nixpkgs/blob/master/.github/STALE-BOT.md label Mar 20, 2024
@wegank wegank added the 2.status: stale https://github.com/NixOS/nixpkgs/blob/master/.github/STALE-BOT.md label Jul 4, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

2.status: merge conflict This PR has merge conflicts with the target branch 2.status: stale https://github.com/NixOS/nixpkgs/blob/master/.github/STALE-BOT.md 6.topic: haskell General-purpose, statically typed, purely functional programming language 8.has: package (new) This PR adds a new package 10.rebuild-darwin: 11-100 This PR causes between 11 and 100 packages to rebuild on Darwin. 10.rebuild-linux: 11-100 This PR causes between 11 and 100 packages to rebuild on Linux. 11.by: package-maintainer This PR was created by a maintainer of all the package it changes.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Get pkgsCross.wasi32.buildPackages.haskell.compiler.{ghc961,ghcHEAD} to work

4 participants