Skip to content

Commit 06c5a57

Browse files
committed
Add cabal.project file
- Adds cabal projects to cabal.project - Disables cabal building C++ by default in cabal.project - Updates some of the wpc-plugin and external-stg-compiler code
1 parent 34e865d commit 06c5a57

File tree

5 files changed

+52
-15
lines changed

5 files changed

+52
-15
lines changed

cabal.project

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
packages:
2+
external-stg/
3+
external-stg-syntax/
4+
external-stg-interpreter/
5+
external-stg-compiler/
6+
wpc-plugin/
7+
lambda/
8+
9+
package external-stg-interpreter
10+
flags: +external-ext-stg-gc
11+
12+
package external-stg-compiler
13+
flags: +external-ext-stg-liveness
14+
15+
source-repository-package
16+
type: git
17+
location: https://github.com/david-christiansen/final-pretty-printer
18+
tag: 048e8fa2d8b2b7a6f9e4e209db4f67361321eec8
19+
20+
source-repository-package
21+
type: git
22+
location: https://github.com/luc-tielen/souffle-haskell
23+
tag: 268a11283ca9293b5eacabf7a0b79d9368232478

external-stg-compiler/.ghci

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
:set -ilib

external-stg-compiler/external-stg-compiler.cabal

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,15 @@ copyright: 2020 Csaba Hruska
1212
category: Compiler
1313
build-type: Simple
1414

15+
flag external-ext-stg-liveness
16+
manual:
17+
True
18+
default:
19+
False
20+
description:
21+
If enabled, the ext-stg-liveness binary is provided externally and available in $PATH
22+
Disbled by default.
23+
1524
library
1625
hs-source-dirs: lib
1726
exposed-modules:
@@ -43,13 +52,14 @@ library
4352
default-language: Haskell2010
4453
cpp-options: -DEXTERNAL_STG_COMPILER_PACKAGE
4554

46-
include-dirs: cbits
55+
if !flag(external-ext-stg-liveness)
56+
include-dirs: cbits
4757

48-
extra-libraries: gomp
58+
extra-libraries: gomp
4959

50-
cxx-sources: cbits/ext-stg-liveness.cpp
51-
cxx-options: -D__EMBEDDED_SOUFFLE__ -D_OPENMP -std=c++17
52-
ld-options: "-Wl,--undefined=__factory_Sf_ext_stg_liveness_instance"
60+
cxx-sources: cbits/ext-stg-liveness.cpp
61+
cxx-options: -D__EMBEDDED_SOUFFLE__ -D_OPENMP -std=c++17
62+
ld-options: "-Wl,--undefined=__factory_Sf_ext_stg_liveness_instance"
5363

5464
executable gen-exe
5565
hs-source-dirs: app

external-stg-compiler/lib/Stg/GHC/Backend.hs

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
module Stg.GHC.Backend where
22

33
-- Compiler
4-
import GHC
4+
import GHC hiding (Backend)
55
import GHC.Paths ( libdir )
66
import GHC.Platform ( platformOS, osSubsectionsViaSymbols )
77
import GHC.Driver.CodeOutput
@@ -10,11 +10,12 @@ import GHC.Driver.Main
1010
import GHC.Driver.Phases
1111
import GHC.Driver.Pipeline
1212
import GHC.Driver.Session
13-
--import GHC.Driver.Types
1413
import GHC.Utils.Error
1514
import GHC.Utils.Outputable
1615
import GHC.Builtin.Names (rOOT_MAIN)
1716
import GHC.Unit.State
17+
import GHC.Types.Basic
18+
import GHC.Types.HpcInfo
1819

1920
-- Stg Types
2021
import GHC.Data.FastString
@@ -33,7 +34,7 @@ import GHC.Cmm
3334
import GHC.Cmm.Info (cmmToRawCmm )
3435
import GHC.StgToCmm (codeGen)
3536
import GHC.Types.Unique.Supply ( mkSplitUniqSupply, initUs_ )
36-
import GHC.StgToCmm.Types (CgInfos (..))
37+
import GHC.StgToCmm.Types
3738

3839
import Control.Monad.Trans
3940
import Control.Monad
@@ -61,11 +62,11 @@ modl = rOOT_MAIN
6162
data Backend = NCG | LLVM
6263

6364

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

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

@@ -103,7 +104,7 @@ compileToObjectM backend unitId modName stubs tyCons topBinds_simple outputName
103104
-- Compile
104105
dflags <- getSessionDynFlags
105106
pkgs <- setSessionDynFlags $
106-
dflags { hscTarget = target, ghcLink = NoLink }
107+
dflags { targetPlatform = target, ghcLink = NoLink }
107108
`gopt_set` Opt_KeepSFiles
108109
`gopt_set` Opt_KeepLlvmFiles
109110
-- `dopt_set` Opt_D_dump_cmm
@@ -125,7 +126,7 @@ compileToObjectM backend unitId modName stubs tyCons topBinds_simple outputName
125126
pure ()
126127

127128

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

@@ -176,7 +177,7 @@ type CollectedCCs
176177
setSessionDynFlags $
177178
(if noHsMain then flip gopt_set Opt_NoHsMain else id) $
178179
dflags
179-
{ hscTarget = target
180+
{ targetPlatform = target
180181
, ghcLink = LinkBinary
181182
, libraryPaths = libraryPaths dflags ++ libPaths
182183
, ldInputs = ldInputs dflags ++ map Option ldOpts
@@ -220,12 +221,12 @@ newGen :: DynFlags
220221
-> HscEnv
221222
-> FilePath
222223
-> Module
223-
-> ForeignStubs
224+
-> C.ForeignStubs
224225
-> [TyCon]
225226
-> CollectedCCs
226227
-> [StgTopBinding]
227228
-> HpcInfo
228-
-> IO (FilePath, Maybe FilePath, [(ForeignSrcLang, FilePath)], CgInfos)
229+
-> IO (FilePath, Maybe FilePath, [(ForeignSrcLang, FilePath)], CmmCgInfos)
229230
newGen dflags hsc_env output_filename this_mod foreign_stubs data_tycons cost_centre_info stg_binds hpc_info = do
230231
-- TODO: add these to parameters
231232
let location = ModLocation

wpc-plugin/src/WPC/StgToExtStg.hs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,13 +8,15 @@ import GHC.Prelude
88
import qualified Data.ByteString.Char8 as BS8
99

1010
import qualified GHC
11+
import qualified GHC.Tc.Types.Origin as GHC
1112
import qualified GHC.Hs.Extension as GHC
1213
import qualified GHC.Hs.Decls as GHC
1314
import qualified GHC.Builtin.PrimOps as GHC
1415
import qualified GHC.Core as GHC
1516
import qualified GHC.Core.DataCon as GHC
1617
import qualified GHC.Core.TyCon as GHC
1718
import qualified GHC.Core.TyCo.Ppr as GHC
19+
import qualified GHC.Core.TyCon as GHC
1820
import qualified GHC.Core.TyCo.Rep as GHC
1921
import qualified GHC.Core.Type as GHC
2022
import qualified GHC.Data.FastString as GHC

0 commit comments

Comments
 (0)