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

Make compatible with new GHC JS backend #335

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

sevanspowell
Copy link

  • 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
Member

dcoutts commented May 22, 2024

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

@sevanspowell
Copy link
Author

Good question, I will have a look! 👍

@sevanspowell
Copy link
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
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
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