Skip to content

Make compatible with new GHC JS backend#335

Open
sevanspowell wants to merge 2 commits into
well-typed:masterfrom
sambnt:master
Open

Make compatible with new GHC JS backend#335
sevanspowell wants to merge 2 commits into
well-typed:masterfrom
sambnt:master

Conversation

@sevanspowell
Copy link
Copy Markdown

  • We need to make a few changes to compile cborg with the new GHC Javascript backend.
  • Tested with GHC 9.8.2.

Signed-off-by: Samuel Evans-Powell <mail@sevanspowell.net>
@dcoutts
Copy link
Copy Markdown
Member

dcoutts commented May 22, 2024

Is there any way we can add GHCJS to the CI?

@sevanspowell
Copy link
Copy Markdown
Author

Good question, I will have a look! 👍

@sevanspowell
Copy link
Copy Markdown
Author

It seems using the new GHC Javascript backend is not yet possible using haskell-ci (which is used to generate the CI script in this repo), see haskell-CI/haskell-ci#723. So I'll have to take a look at submitting a PR against haskell-ci.

Signed-off-by: Samuel Evans-Powell <mail@sevanspowell.net>
@sevanspowell
Copy link
Copy Markdown
Author

I am attempting to use ghcup to build the javascript backend, but unfortunately the instructions in the user guide don't work (https://www.haskell.org/ghcup/guide/#ghc-js-cross-bindists-experimental). So far I've had limited success with:

docker run -it buildpack-deps:bionic bash
export VERSION="3.1.57"
git clone https://github.com/emscripten-core/emsdk.git
cd emsdk
./emsdk install "$VERSION"
./emsdk activate "$VERSION"
source ./emsdk_env.sh

curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.7/install.sh | bash
nvm install 16.20.0
vi .emscripten > "NODE_JS = '/root/.nvm/versions/node/v16.20.0/bin/node'"

emconfigure ghcup install ghc 9.10.1 --set javascript-unknown-ghcjs

Failing with an issue regarding word size:

[ ghc-configure ] checking size of void *... 4
[ ghc-configure ] configure: error: This binary distribution produces binaries for a target with
[ ghc-configure ]                   word size of 8, but your target toolchain produces binaries
[ ghc-configure ]                   with a word size of 4. Are you sure your toolchain
[ ghc-configure ]                   targets the intended target platform of this compiler

I'll get back to this when I can.

@sevanspowell
Copy link
Copy Markdown
Author

Had success building with ghcup!

docker run -it buildpack-deps:noble bash
apt-get update
apt-get install -y --no-install-recommends gnupg ca-certificates dirmngr curl git software-properties-common libtinfo5
mkdir -p "$HOME/.ghcup/bin"
curl -sL https://downloads.haskell.org/ghcup/0.1.22.0/x86_64-linux-ghcup-0.1.22.0 > "$HOME/.ghcup/bin/ghcup"
chmod a+x "$HOME/.ghcup/bin/ghcup"
export PATH="$HOME/.ghcup/bin":"${PATH}"

export EM_VERSION="3.1.57"
git clone https://github.com/emscripten-core/emsdk.git
cd emsdk
./emsdk install "$EM_VERSION"
./emsdk activate "$EM_VERSION"
source "/emsdk/emsdk_env.sh"

ghcup config add-release-channel https://raw.githubusercontent.com/haskell/ghcup-metadata/develop/ghcup-cross-0.0.8.yaml
emconfigure ghcup install ghc --set javascript-unknown-ghcjs-9.10.0.20240413
# emconfigure ghcup install ghc --set javascript-unknown-ghcjs-9.6.2

echo 'main = putStrLn "hello world"' > hello.hs
javascript-unknown-ghcjs-ghc -fforce-recomp hello.hs
./hello

I needed to:

  • Set the release channel: ghcup config add-release-channel https://raw.githubusercontent.com/haskell/ghcup-metadata/develop/ghcup-cross-0.0.8.yaml
  • Upgrade to Ubuntu Noble, in order to get the newer version of GLIBC.

So it is possible to build with ghcup, so it should be possible to submit a PR to haskell-ci to get GHCJS working with certain versions of GHC.

hamishmack added a commit to input-output-hk/hackage-overlay-ghcjs that referenced this pull request Jun 10, 2024
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

Successfully merging this pull request may close these issues.

2 participants