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

Rename wasi-cross to wasm-cross #181

Merged
merged 1 commit into from
Aug 17, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 7 additions & 2 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -108,8 +108,13 @@ jobs:
name: ghc-nix
signingKey: '${{ secrets.CACHIX_SIGNING_KEY }}'

- name: "wasi-cross: Run nix develop - Boot and Configure"
run: nix develop -Lv --fallback ghc.nix#wasi-cross -c bash -c "./boot && configure_ghc"
- name: "wasm-cross: Run nix develop - Boot and Configure"
run:
nix develop -Lv --fallback ghc.nix#wasm-cross -c bash -c "./boot && configure_ghc"

- name: "wasm-cross: Check backward compat synonym"
run:
nix develop -Lv --fallback ghc.nix#wasi-cross -c true

- name: "js-cross: Run nix develop - Boot and Configure"
run: nix develop -Lv --fallback ghc.nix#js-cross -c bash -c "./boot && configure_ghc"
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -126,9 +126,9 @@ HLS should also just work.
### For WebAsm:

```sh
nix-shell ~/ghc.nix --arg withWasiSDK true
nix-shell ~/ghc.nix --arg withWasm true
# or
nix develop github:alpmestan/ghc.nix#wasi-cross
nix develop github:alpmestan/ghc.nix#wasm-cross
```

### For JavaScript:
Expand Down Expand Up @@ -241,7 +241,7 @@ be careful to specify the path to the `shell.nix`, not to the `default.nix`.
| `withDtrace` | whether to include `linuxPackage.systemtap` | `nixpkgs.stdenv.isLinux` | ❌ |
| `withGrind` | whether to include `valgrind` | `true` | ❌ |
| `withEMSDK` | whether to include `emscripten` for the js-backend, will create an `.emscripten_cache` folder in your working directory of the shell for writing. `EM_CACHE` is set to that path, prevents [sub word sized atomic](https://gitlab.haskell.org/ghc/ghc/-/wikis/javascript-backend/building#configure-fails-with-sub-word-sized-atomic-operations-not-available) kinds of issues | `false` | ❌ |
| `withWasiSDK` | whether to include `wasi-sdk` & `wasmtime` for the ghc wasm backend | `false` | ❌ |
| `withWasm` | whether to include `wasi-sdk` & `wasmtime` for the ghc wasm backend | `false` | ❌ |
| `withFindNoteDef` | install a shell script `find_note_def`; `find_note_def "Adding a language extension"` will point to the definition of the Note "Adding a language extension" | `true` | ❌ |

## `direnv`
Expand Down
4 changes: 3 additions & 1 deletion flake.nix
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,9 @@
devShells = perSystem (system: rec {
default = ghc-nix;
ghc-nix = import ./ghc.nix (defaultSettings system // userSettings);
wasi-cross = import ./ghc.nix (defaultSettings system // userSettings // { withWasiSDK = true; });
wasm-cross = import ./ghc.nix (defaultSettings system // userSettings // { withWasm = true; });
# Backward compat synonym
wasi-cross = wasm-cross;
js-cross = import ./ghc.nix (defaultSettings system // userSettings // {
crossTarget = "javascript-unknown-ghcjs";
withEMSDK = true;
Expand Down
18 changes: 14 additions & 4 deletions ghc.nix
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ let
then "${builtins.getEnv "PWD"}/hadrian/hadrian.cabal"
else null;
in
{ system ? builtins.currentSystem
args@{ system ? builtins.currentSystem
, nixpkgs
, all-cabal-hashes
, bootghc ? "ghc96"
Expand All @@ -29,7 +29,8 @@ in
, withGrind ? !((pkgsFor nixpkgs system).valgrind.meta.broken or false)
, withSystemLibffi ? false
, withEMSDK ? false # load emscripten for js-backend
, withWasiSDK ? false # load the toolchain for wasm backend
, withWasm ? false # load the toolchain for wasm backend
, withWasiSDK ? false # Backward compat synonym for withWasm.
, withFindNoteDef ? true # install a shell script `find_note_def`;
# `find_note_def "Adding a language extension"`
# will point to the definition of the Note "Adding a language extension"
Expand All @@ -38,7 +39,15 @@ in
, crossTarget ? null
}:

# Assert that args has only one of withWasm and withWasiSDK.
let
wasi = args ? withWasiSDK;
wasm = args ? withWasm;
in
assert (wasi -> !wasm) && (wasm -> !wasi);
let
# Fold in the backward-compat synonym.
withWasm' = withWasm || withWasiSDK;
overlay = self: super: {
haskell = super.haskell // {
packages = super.haskell.packages // {
Expand Down Expand Up @@ -115,7 +124,7 @@ let
++ optional withLlvm llvmForGhc
++ optional withGrind valgrind
++ optional withEMSDK emscripten
++ optionals withWasiSDK [ wasi-sdk wasmtime ]
++ optionals withWasm' [ wasi-sdk wasmtime ]
++ optional withNuma numactl
++ optional withDwarf elfutils
++ optional withGhcid ghcid
Expand Down Expand Up @@ -270,7 +279,8 @@ hspkgs.shellFor rec {
${lib.optionalString withDocs "export FONTCONFIG_FILE=${fonts}"}

# N.B. This overrides CC, CONFIGURE_ARGS, etc. to configure the cross-compiler.
${lib.optionalString withWasiSDK "addWasiSDKHook"}
# See https://gitlab.haskell.org/ghc/ghc-wasm-meta/-/blob/master/pkgs/wasi-sdk-setup-hook.sh
${lib.optionalString withWasm' "addWasiSDKHook"}

>&2 echo "Recommended ./configure arguments (found in \$CONFIGURE_ARGS:"
>&2 echo "or use the configure_ghc command):"
Expand Down
Loading