From cc2fa87f2144329b6f287dc5be2ea28e2a21f5ef Mon Sep 17 00:00:00 2001 From: Cheng Shao Date: Fri, 15 Nov 2024 22:02:13 +0000 Subject: [PATCH 1/5] Bump nix-installer-action --- .github/workflows/build.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index e12bf3d..ddbdcb7 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -18,7 +18,7 @@ jobs: uses: actions/checkout@v4 - name: install-nix - uses: DeterminateSystems/nix-installer-action@v15 + uses: DeterminateSystems/nix-installer-action@v16 - name: build-frontend run: | From b1ab03ac2f71aa3ed922fc6a55221a20ee1828c2 Mon Sep 17 00:00:00 2001 From: Cheng Shao Date: Fri, 15 Nov 2024 22:19:36 +0000 Subject: [PATCH 2/5] Bump nix flake & index state --- cabal.project | 2 +- flake.lock | 18 +++++++++--------- 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/cabal.project b/cabal.project index fc31946..c7673fa 100644 --- a/cabal.project +++ b/cabal.project @@ -1,6 +1,6 @@ packages: . reflex-todomvc -index-state: 2024-11-11T12:54:21Z +index-state: 2024-11-15T08:25:42Z if arch(wasm32) -- Required for TemplateHaskell. When using wasm32-wasi-cabal from diff --git a/flake.lock b/flake.lock index b585a4b..98dd055 100644 --- a/flake.lock +++ b/flake.lock @@ -5,11 +5,11 @@ "systems": "systems" }, "locked": { - "lastModified": 1726560853, - "narHash": "sha256-X6rJYSESBVr3hBoH0WbKE5KvhPU5bloyZ2L4K60/fPQ=", + "lastModified": 1731533236, + "narHash": "sha256-l0KFg5HjrsfsO/JpG+r7fRrqm12kzFHyUHqHCVpMMbI=", "owner": "numtide", "repo": "flake-utils", - "rev": "c1dfcf08411b08f6b8615f7d8971a2bfa81d5e8a", + "rev": "11707dc2f618dd54ca8739b309ec4fc024de578b", "type": "github" }, "original": { @@ -25,11 +25,11 @@ }, "locked": { "host": "gitlab.haskell.org", - "lastModified": 1731323753, - "narHash": "sha256-K6uBL4TVGHl9bknKdEAevBUXmkaimNXc8H4yaB2CBBk=", + "lastModified": 1731781423, + "narHash": "sha256-lJY6i9NNDQgU+vqx08iXj6ZnApE6h13bj5YsEmL+NKU=", "owner": "ghc", "repo": "ghc-wasm-meta", - "rev": "94337065008e8892f0188be0e636cc4b5aa4652d", + "rev": "9c4525d3f04ea278d0792f7e84abe34a67be7356", "type": "gitlab" }, "original": { @@ -41,11 +41,11 @@ }, "nixpkgs": { "locked": { - "lastModified": 1731139594, - "narHash": "sha256-IigrKK3vYRpUu+HEjPL/phrfh7Ox881er1UEsZvw9Q4=", + "lastModified": 1731319897, + "narHash": "sha256-PbABj4tnbWFMfBp6OcUK5iGy1QY+/Z96ZcLpooIbuEI=", "owner": "NixOS", "repo": "nixpkgs", - "rev": "76612b17c0ce71689921ca12d9ffdc9c23ce40b2", + "rev": "dc460ec76cbff0e66e269457d7b728432263166c", "type": "github" }, "original": { From 1d701bc58fd4009360a3c1b69d8ec888b1bf8944 Mon Sep 17 00:00:00 2001 From: Cheng Shao Date: Fri, 15 Nov 2024 22:30:34 +0000 Subject: [PATCH 3/5] ci: don't pass --debuginfo to wasm-opt --- .github/workflows/build.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index ddbdcb7..af10ff6 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -22,7 +22,7 @@ jobs: - name: build-frontend run: | - nix develop --command bash -c "cd frontend && wasm32-wasi-cabal update && exec ./build.sh --debuginfo --low-memory-unused --converge --gufa --flatten --rereloop -Oz" + nix develop --command bash -c "cd frontend && wasm32-wasi-cabal update && exec ./build.sh --low-memory-unused --converge --gufa --flatten --rereloop -Oz" ghcup-build: name: ghcup-build @@ -64,7 +64,7 @@ jobs: --with-hc-pkg=wasm32-wasi-ghc-pkg \ --with-hsc2hs=wasm32-wasi-hsc2hs \ update - ./build.sh --debuginfo --low-memory-unused --converge --gufa --flatten --rereloop -Oz + ./build.sh --low-memory-unused --converge --gufa --flatten --rereloop -Oz non-nix-build: name: non-nix-build @@ -96,7 +96,7 @@ jobs: - name: build-frontend run: | cd frontend - ./build.sh --debuginfo --low-memory-unused --converge --gufa --flatten --rereloop -Oz + ./build.sh --low-memory-unused --converge --gufa --flatten --rereloop -Oz - name: upload-pages-artifact uses: actions/upload-pages-artifact@v3 From f50c11e54a94f7f872d936726e0ec6a4b7915d99 Mon Sep 17 00:00:00 2001 From: Cheng Shao Date: Fri, 15 Nov 2024 22:17:30 +0000 Subject: [PATCH 4/5] Apply -H64m to GHCRTS --- frontend/build.sh | 2 +- frontend/index.js | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/frontend/build.sh b/frontend/build.sh index 19d47cb..7ba79fe 100755 --- a/frontend/build.sh +++ b/frontend/build.sh @@ -37,7 +37,7 @@ hs_wasm_path=$(find .. -name "*.wasm") if $dev_mode; then cp "$hs_wasm_path" dist/bin.wasm else - wizer --allow-wasi --wasm-bulk-memory true --init-func _initialize -o dist/bin.wasm "$hs_wasm_path" + env -i GHCRTS=-H64m "$(type -P wizer)" --allow-wasi --wasm-bulk-memory true --inherit-env true --init-func _initialize -o dist/bin.wasm "$hs_wasm_path" wasm-opt ${1+"$@"} dist/bin.wasm -o dist/bin.wasm wasm-tools strip -o dist/bin.wasm dist/bin.wasm fi diff --git a/frontend/index.js b/frontend/index.js index 1d5605b..45bd70c 100644 --- a/frontend/index.js +++ b/frontend/index.js @@ -2,7 +2,7 @@ import { WASI, OpenFile, File, ConsoleStdout } from "https://cdn.jsdelivr.net/np import ghc_wasm_jsffi from "./ghc_wasm_jsffi.js"; const args = []; -const env = []; +const env = ["GHCRTS=-H64m"]; const fds = [ new OpenFile(new File([])), // stdin ConsoleStdout.lineBuffered((msg) => console.log(`[WASI stdout] ${msg}`)), From 8b08be406cdce22d9404277c166791e7150e1be3 Mon Sep 17 00:00:00 2001 From: Cheng Shao Date: Sat, 16 Nov 2024 19:03:04 +0000 Subject: [PATCH 5/5] ci: add cabal-cache logic --- .github/workflows/build.yml | 50 +++++++++++++++++++++++++++++++++++-- 1 file changed, 48 insertions(+), 2 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index af10ff6..6a4114c 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -20,9 +20,23 @@ jobs: - name: install-nix uses: DeterminateSystems/nix-installer-action@v16 + - name: gen-plan-json + id: gen-plan-json + run: | + nix develop --command bash -c 'cd frontend && wasm32-wasi-cabal update && wasm32-wasi-cabal build ghc-wasm-reflex-examples --dry-run && echo WASM32_WASI_GHC=$(which wasm32-wasi-ghc) >> $GITHUB_OUTPUT' + + - name: cabal-cache + uses: actions/cache@v4 + with: + key: nix-${{ hashFiles('dist-newstyle/cache/plan.json') }} + restore-keys: nix- + path: | + ~/.ghc-wasm/.cabal/store + dist-newstyle + - name: build-frontend run: | - nix develop --command bash -c "cd frontend && wasm32-wasi-cabal update && exec ./build.sh --low-memory-unused --converge --gufa --flatten --rereloop -Oz" + nix develop --command bash -c "cd frontend && exec ./build.sh --low-memory-unused --converge --gufa --flatten --rereloop -Oz" ghcup-build: name: ghcup-build @@ -56,7 +70,7 @@ jobs: ghcup config add-release-channel https://raw.githubusercontent.com/haskell/ghcup-metadata/develop/ghcup-cross-0.0.8.yaml ghcup install ghc --set wasm32-wasi-9.10.1.20241021 -- $CONFIGURE_ARGS - - name: build-frontend + - name: gen-plan-json run: | cd frontend cabal \ @@ -64,6 +78,24 @@ jobs: --with-hc-pkg=wasm32-wasi-ghc-pkg \ --with-hsc2hs=wasm32-wasi-hsc2hs \ update + cabal \ + --with-compiler=wasm32-wasi-ghc \ + --with-hc-pkg=wasm32-wasi-ghc-pkg \ + --with-hsc2hs=wasm32-wasi-hsc2hs \ + build ghc-wasm-reflex-examples --dry-run + + - name: cabal-cache + uses: actions/cache@v4 + with: + key: ghcup-${{ hashFiles('dist-newstyle/cache/plan.json') }} + restore-keys: ghcup- + path: | + ~/.local/state/cabal/store + dist-newstyle + + - name: build-frontend + run: | + cd frontend ./build.sh --low-memory-unused --converge --gufa --flatten --rereloop -Oz non-nix-build: @@ -93,6 +125,20 @@ jobs: env: FLAVOUR: '9.10' + - name: gen-plan-json + run: | + cd frontend + wasm32-wasi-cabal build ghc-wasm-reflex-examples --dry-run + + - name: cabal-cache + uses: actions/cache@v4 + with: + key: vanilla-${{ hashFiles('dist-newstyle/cache/plan.json') }} + restore-keys: vanilla- + path: | + ~/.ghc-wasm/.cabal/store + dist-newstyle + - name: build-frontend run: | cd frontend