ghc-whole-program-compiler-project icon indicating copy to clipboard operation
ghc-whole-program-compiler-project copied to clipboard

GHC 9.6+ updates

Open dmjio opened this issue 11 months ago • 1 comments

Hey @csabahruska,

In preparation for @mpickering and @alt-romes to release an alpha version of dap integration w/ GHC, I'd like to ensure that our work with the haskell-estgi-debugger is building along with the coming dap changes.

This PR updates the external-stg-interpreter, external-stg and external-stg-syntax to build with GHC 9.6+.

Things done:

  • [x] Adjusted primops and tests for 64-bit Word and Int since ghc-prim had slightly changed (primop tests pass now ✅ )
  • [x] cabal.project file was added and it does build with the latest souffle-haskell-0.4.0.0 and a working version of final-pretty
  • [x] A cabal flag was introduced (-fexternal-ext-stg-gc and -fexternal-ext-liveness-analysis -- disabled by default in the cabal file - but enabled by default in cabal.project) to allow users to build the souffle generated C++ by hand. This simplifies the build, and runSouffle is able to find the ext-stg-gc binary in $PATH.
  • [x] Re-introduced import Control.Monad, it was decided that Control.Monad should no longer be re-exported from mtl modules.
  • [x] Adds a github workflow file. This workflow will use cabal's resolver to build the Haskell code, and nix to acquire bzip2 and zlib.
  • [x] Adds a github workflow badge to the README.md
    neWord16# [✔]
     +++ OK, passed 100 tests.

Finished in 0.0904 seconds
240 examples, 0 failures
Test suite primop-test: PASS
Test suite logged to:
/home/dmjio/Desktop/ghc-whole-program-compiler-project/dist-newstyle/build/x86_64-linux/ghc-9.6.6/external-stg-interpreter-0.1.0.1/t/primop-test/test/external-stg-interpreter-0.1.0.1-primop-test.log
1 of 1 test suites (1 of 1 test cases) passed.

^ these tests should run in CI now

Then in the haskell-debugger I'm able to make ext-stg-gc available on PATH so runSouffle will always be able to find it, when we call the external-stg-interpreter from haskell-debugger.

  ext-stg-gc =
    pkgs.stdenv.mkDerivation {
      name = "ext-stg-gc";
      src = "${ghc-wpo-src}/external-stg-interpreter";
      buildInputs = with pkgs; [ souffle openmpi ];
      buildPhase = ''
        mkdir -pv $out/bin
        g++ -fopenmp $src/datalog/ext-stg-gc.cpp \
           -D_OPENMP -std=c++17 \
           -o $out/bin/ext-stg-gc
      '';
    };
    ```

dmjio avatar May 01 '25 05:05 dmjio

Since we've updated souffle, we've regen'd the reachability analysis for GC (per the README.md instructions).

It seems to build and do the right thing (checks roots for mark and sweep)

❯ $(nix-build -A ext-stg-gc)/bin/ext-stg-gc
Error loading GCRoot data: Cannot open fact file GCRoot.facts

dmjio avatar May 01 '25 18:05 dmjio