[commit: ghc] master: Add a script for running a ghci that can load and run ghc (13d40ff)
git at git.haskell.org
git at git.haskell.org
Fri Jul 27 16:29:07 UTC 2018
Repository : ssh://git@git.haskell.org/ghc
On branch : master
Link : http://ghc.haskell.org/trac/ghc/changeset/13d40ff65b4171c4f0adac10577667d05074441a/ghc
>---------------------------------------------------------------
commit 13d40ff65b4171c4f0adac10577667d05074441a
Author: Michael Sloan <mgsloan at gmail.com>
Date: Thu Jul 26 17:17:41 2018 -0400
Add a script for running a ghci that can load and run ghc
Add scripts and .ghci files for loading GHC into GHCi
Major credit to Csongor Kiss who wrote nearly all of settings.ghci
Some small modifications to GHC are needed to make this work, and this
diff depends on [D4986](https://phabricator.haskell.org/D4986) being
merged.
Test Plan:
Manual for now. I have some thoughts on how to run the entire testsuite
against
GHC-in-GHCi.
Reviewers: alpmestan, mpickering, goldfire, bgamari, erikd
Reviewed By: alpmestan
Subscribers: rwbarton, thomie, carter
Differential Revision: https://phabricator.haskell.org/D4904
>---------------------------------------------------------------
13d40ff65b4171c4f0adac10577667d05074441a
.ghcid | 7 +++++++
utils/ghc-in-ghci/inner.ghci | 1 +
utils/ghc-in-ghci/load-main.ghci | 1 +
utils/ghc-in-ghci/run.sh | 36 +++++++++++++++++++++++++++++++++++
utils/ghc-in-ghci/settings.ghci | 41 ++++++++++++++++++++++++++++++++++++++++
5 files changed, 86 insertions(+)
diff --git a/.ghcid b/.ghcid
new file mode 100644
index 0000000..f751a6f
--- /dev/null
+++ b/.ghcid
@@ -0,0 +1,7 @@
+--command utils/ghc-in-ghci/run.sh
+--reload compiler
+--reload ghc
+--reload includes
+--restart utils/ghc-in-ghci/run.sh
+--restart utils/ghc-in-ghci/load-main.ghci
+--restart utils/ghc-in-ghci/settings.ghci
diff --git a/utils/ghc-in-ghci/inner.ghci b/utils/ghc-in-ghci/inner.ghci
new file mode 100644
index 0000000..72834c9
--- /dev/null
+++ b/utils/ghc-in-ghci/inner.ghci
@@ -0,0 +1 @@
+:set prompt "%s [inner]> "
diff --git a/utils/ghc-in-ghci/load-main.ghci b/utils/ghc-in-ghci/load-main.ghci
new file mode 100644
index 0000000..a798557
--- /dev/null
+++ b/utils/ghc-in-ghci/load-main.ghci
@@ -0,0 +1 @@
+:load Main
diff --git a/utils/ghc-in-ghci/run.sh b/utils/ghc-in-ghci/run.sh
new file mode 100755
index 0000000..2dda647
--- /dev/null
+++ b/utils/ghc-in-ghci/run.sh
@@ -0,0 +1,36 @@
+#!/bin/sh -xe
+
+# Runs ghc-stage2 with GHCi settings that allow GHC to be loaded and run in the
+# interpreter. Options provided on the command-line will be passed directly to
+# the GHCi invocation.
+
+# Note that this script is intended to be run from the root of the GHC repo,
+# like this:
+
+# ./utils/ghc-in-ghci/run.sh
+
+# This is substantially faster than doing an actual compile, and so can aid in
+# tighter development iterations. It can be made even faster by specifying "-jN"
+# for parallelism. Typically choosing an N value close to the number of logical
+# CPU cores you have leads to faster loads. Here's how to specify -j:
+
+# ./utils/ghc-in-ghci/run.sh -j4
+
+# The script will also run `:load Main`, to load GHC's main module. After that,
+# running `main` will run an inner GHCi, because there is a default `:set args
+# --interactive ...`. To override this, use `:set args ...` or `:main ...`.
+
+# If you don't want to wait for `:load Main`, since you want to load some other
+# module, then you can use `Ctrl+C` to cancel the initial load.
+
+
+export _GHC_TOP_DIR=./inplace/lib
+
+exec ./inplace/bin/ghc-stage2 \
+ --interactive \
+ -ghci-script ./utils/ghc-in-ghci/settings.ghci \
+ -ghci-script ./utils/ghc-in-ghci/load-main.ghci \
+ -odir ./ghci-tmp \
+ -hidir ./ghci-tmp \
+ +RTS -A128m -RTS \
+ "$@"
diff --git a/utils/ghc-in-ghci/settings.ghci b/utils/ghc-in-ghci/settings.ghci
new file mode 100644
index 0000000..1348274
--- /dev/null
+++ b/utils/ghc-in-ghci/settings.ghci
@@ -0,0 +1,41 @@
+:set -icompiler/backpack
+:set -icompiler/basicTypes
+:set -icompiler/cmm
+:set -icompiler/codeGen
+:set -icompiler/coreSyn
+:set -icompiler/deSugar
+:set -icompiler/ghci
+:set -icompiler/hsSyn
+:set -icompiler/iface
+:set -icompiler/llvmGen
+:set -icompiler/main
+:set -icompiler/nativeGen
+:set -icompiler/parser
+:set -icompiler/prelude
+:set -icompiler/profiling
+:set -icompiler/rename
+:set -icompiler/simplCore
+:set -icompiler/simplStg
+:set -icompiler/specialise
+:set -icompiler/stgSyn
+:set -icompiler/stranal
+:set -icompiler/typecheck
+:set -icompiler/types
+:set -icompiler/utils
+:set -icompiler/vectorise
+:set -ighc
+:set -Icompiler
+:set -Icompiler/stage2
+:set -Icompiler/stage2/build
+:set -icompiler/stage2/build
+:set -Iincludes
+:set -Iincludes/dist-derivedconstants/header
+:set -package=ghc-boot-th
+:set -DSTAGE=2
+:set -DGHCI
+:set -DGHC_LOADED_INTO_GHCI
+:set -XNoImplicitPrelude
+
+-- Setup args so that running "main" will run ghci and set the prompt to
+-- indicate that it is an inner ghci.
+:set args --interactive -ghci-script utils/ghc-in-ghci/inner.ghci
More information about the ghc-commits
mailing list