Skip to content

GHC 9.6+ updates #13

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

Open
wants to merge 6 commits into
base: master
Choose a base branch
from
Open
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
28 changes: 28 additions & 0 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
name: GHC-WPC CI
on:
push:
branches:
- master
pull_request:

jobs:
build:
runs-on: ubuntu-latest
if: github.ref != 'refs/heads/master'
steps:
- uses: DeterminateSystems/nix-installer-action@main

- name: Nix channel update
run: nix-channel --update

- name: Cabal install
run: nix-env -iA cabal-install -f '<nixpkgs>'

- name: Cabal update
run: cabal update

- name: Build external-stg-interpreter
run: nix-shell -p ghc -p bzip2.dev -p zlib.dev --run 'cabal build external-stg-interpreter'

- name: Test external-stg-interpreter
run: nix-shell -p 'haskellPackages.ghcWithPackages (p: with p; [ hspec-discover ])' --run 'cabal test external-stg-interpreter'
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1 +1,4 @@
**/.stack-work/
TAGS
dist-newstyle
*~
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# GHC whole program compiler project
# GHC whole program compiler project [![Build Status](https://img.shields.io/endpoint.svg?url=https%3A%2F%2Factions-badge.atrox.dev%2Fgrin-compiler%2Fghc-whole-program-compiler-project%2Fbadge%3Fref%3Dmaster&style=flat-square)](https://actions-badge.atrox.dev/grin-compiler/ghc-whole-program-compiler-project/goto?ref=master)

The project consists of GHC **wpc-plugin** and the corresponding **External STG IR** and **tooling**.

Expand Down
23 changes: 23 additions & 0 deletions cabal.project
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
packages:
external-stg/
external-stg-syntax/
external-stg-interpreter/
external-stg-compiler/
wpc-plugin/
lambda/

package external-stg-interpreter
flags: +external-ext-stg-gc

package external-stg-compiler
flags: +external-ext-stg-liveness

source-repository-package
type: git
location: https://github.com/david-christiansen/final-pretty-printer
tag: 048e8fa2d8b2b7a6f9e4e209db4f67361321eec8

source-repository-package
type: git
location: https://github.com/luc-tielen/souffle-haskell
tag: 268a11283ca9293b5eacabf7a0b79d9368232478
1 change: 1 addition & 0 deletions external-stg-compiler/.ghci
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
:set -ilib
20 changes: 15 additions & 5 deletions external-stg-compiler/external-stg-compiler.cabal
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,15 @@ copyright: 2020 Csaba Hruska
category: Compiler
build-type: Simple

flag external-ext-stg-liveness
manual:
True
default:
False
description:
If enabled, the ext-stg-liveness binary is provided externally and available in $PATH
Disbled by default.

library
hs-source-dirs: lib
exposed-modules:
Expand Down Expand Up @@ -43,13 +52,14 @@ library
default-language: Haskell2010
cpp-options: -DEXTERNAL_STG_COMPILER_PACKAGE

include-dirs: cbits
if !flag(external-ext-stg-liveness)
include-dirs: cbits

extra-libraries: gomp
extra-libraries: gomp

cxx-sources: cbits/ext-stg-liveness.cpp
cxx-options: -D__EMBEDDED_SOUFFLE__ -D_OPENMP -std=c++17
ld-options: "-Wl,--undefined=__factory_Sf_ext_stg_liveness_instance"
cxx-sources: cbits/ext-stg-liveness.cpp
cxx-options: -D__EMBEDDED_SOUFFLE__ -D_OPENMP -std=c++17
ld-options: "-Wl,--undefined=__factory_Sf_ext_stg_liveness_instance"

executable gen-exe
hs-source-dirs: app
Expand Down
21 changes: 11 additions & 10 deletions external-stg-compiler/lib/Stg/GHC/Backend.hs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
module Stg.GHC.Backend where

-- Compiler
import GHC
import GHC hiding (Backend)
import GHC.Paths ( libdir )
import GHC.Platform ( platformOS, osSubsectionsViaSymbols )
import GHC.Driver.CodeOutput
Expand All @@ -10,11 +10,12 @@ import GHC.Driver.Main
import GHC.Driver.Phases
import GHC.Driver.Pipeline
import GHC.Driver.Session
--import GHC.Driver.Types
import GHC.Utils.Error
import GHC.Utils.Outputable
import GHC.Builtin.Names (rOOT_MAIN)
import GHC.Unit.State
import GHC.Types.Basic
import GHC.Types.HpcInfo

-- Stg Types
import GHC.Data.FastString
Expand All @@ -33,7 +34,7 @@ import GHC.Cmm
import GHC.Cmm.Info (cmmToRawCmm )
import GHC.StgToCmm (codeGen)
import GHC.Types.Unique.Supply ( mkSplitUniqSupply, initUs_ )
import GHC.StgToCmm.Types (CgInfos (..))
import GHC.StgToCmm.Types

import Control.Monad.Trans
import Control.Monad
Expand Down Expand Up @@ -61,11 +62,11 @@ modl = rOOT_MAIN
data Backend = NCG | LLVM


compileToObject :: Backend -> Unit -> ModuleName -> ForeignStubs -> [TyCon] -> [StgTopBinding] -> FilePath -> IO ()
compileToObject :: Backend -> Unit -> ModuleName -> C.ForeignStubs -> [TyCon] -> [StgTopBinding] -> FilePath -> IO ()
compileToObject backend unitId modName stubs tyCons topBinds_simple outputName = do
runGhc (Just libdir) $ compileToObjectM backend unitId modName stubs tyCons topBinds_simple outputName

compileToObjectM :: Backend -> Unit -> ModuleName -> ForeignStubs -> [TyCon] -> [StgTopBinding] -> FilePath -> Ghc ()
compileToObjectM :: Backend -> Unit -> ModuleName -> C.ForeignStubs -> [TyCon] -> [StgTopBinding] -> FilePath -> Ghc ()
compileToObjectM backend unitId modName stubs tyCons topBinds_simple outputName = do
dflags <- getSessionDynFlags

Expand Down Expand Up @@ -103,7 +104,7 @@ compileToObjectM backend unitId modName stubs tyCons topBinds_simple outputName
-- Compile
dflags <- getSessionDynFlags
pkgs <- setSessionDynFlags $
dflags { hscTarget = target, ghcLink = NoLink }
dflags { targetPlatform = target, ghcLink = NoLink }
`gopt_set` Opt_KeepSFiles
`gopt_set` Opt_KeepLlvmFiles
-- `dopt_set` Opt_D_dump_cmm
Expand All @@ -125,7 +126,7 @@ compileToObjectM backend unitId modName stubs tyCons topBinds_simple outputName
pure ()


compileProgram :: Backend -> Bool -> [String] -> [String] -> [String] -> [String] -> ForeignStubs -> [TyCon] -> [StgTopBinding] -> IO ()
compileProgram :: Backend -> Bool -> [String] -> [String] -> [String] -> [String] -> C.ForeignStubs -> [TyCon] -> [StgTopBinding] -> IO ()
compileProgram backend noHsMain incPaths libPaths ldOpts clikeFiles stubs tyCons topBinds_simple = runGhc (Just libdir) $ do
dflags <- getSessionDynFlags

Expand Down Expand Up @@ -176,7 +177,7 @@ type CollectedCCs
setSessionDynFlags $
(if noHsMain then flip gopt_set Opt_NoHsMain else id) $
dflags
{ hscTarget = target
{ targetPlatform = target
, ghcLink = LinkBinary
, libraryPaths = libraryPaths dflags ++ libPaths
, ldInputs = ldInputs dflags ++ map Option ldOpts
Expand Down Expand Up @@ -220,12 +221,12 @@ newGen :: DynFlags
-> HscEnv
-> FilePath
-> Module
-> ForeignStubs
-> C.ForeignStubs
-> [TyCon]
-> CollectedCCs
-> [StgTopBinding]
-> HpcInfo
-> IO (FilePath, Maybe FilePath, [(ForeignSrcLang, FilePath)], CgInfos)
-> IO (FilePath, Maybe FilePath, [(ForeignSrcLang, FilePath)], CmmCgInfos)
newGen dflags hsc_env output_filename this_mod foreign_stubs data_tycons cost_centre_info stg_binds hpc_info = do
-- TODO: add these to parameters
let location = ModLocation
Expand Down
1 change: 1 addition & 0 deletions external-stg-compiler/lib/Stg/GHC/ToStg.hs
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ import GHC.Core.TyCon
import GHC.Core.DataCon
import GHC.Core.Type

import Control.Monad
import Control.Monad.State
import Data.List (partition)

Expand Down
1 change: 1 addition & 0 deletions external-stg-interpreter/.ghci
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
:set -ilib
Loading