summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBen Gamari <ben@smart-cactus.org>2017-11-22 08:50:45 -0500
committerBen Gamari <ben@smart-cactus.org>2017-11-22 08:50:45 -0500
commitabdb5559b74af003a6d85f32695c034ff739f508 (patch)
tree1d3df93568e0db2c00acfa14a89f52db6b8df5f2
parentc11f145cf6a32337c005b0f9185e228c9ade0a64 (diff)
parent360d7404809b3fa54541f7f932a6864294f75a4a (diff)
downloadhaskell-abdb5559b74af003a6d85f32695c034ff739f508.tar.gz
Update Hadrian
-rw-r--r--README.md278
-rwxr-xr-xbuild.nix.sh35
-rw-r--r--hadrian/cabal.project3
-rw-r--r--hadrian/hadrian.cabal10
-rw-r--r--hadrian/src/Rules/Compile.hs2
-rw-r--r--hadrian/src/Rules/Dependencies.hs4
-rw-r--r--hadrian/src/Rules/Program.hs3
-rw-r--r--hadrian/src/Settings/Builders/Ghc.hs8
-rw-r--r--hadrian/src/Settings/Packages/GhcCabal.hs5
-rw-r--r--hadrian/src/Utilities.hs30
-rw-r--r--hadrian/stack.yaml7
-rw-r--r--shell.nix61
12 files changed, 305 insertions, 141 deletions
diff --git a/README.md b/README.md
index 02bf4a8f1a..d188a4a054 100644
--- a/README.md
+++ b/README.md
@@ -1,128 +1,194 @@
-The Glasgow Haskell Compiler
-============================
+Hadrian
+=======
-[![Build Status](https://api.travis-ci.org/ghc/ghc.svg?branch=master)](http://travis-ci.org/ghc/ghc)
+[![Linux & OS X status](https://img.shields.io/travis/snowleopard/hadrian/master.svg?label=Linux%20%26%20OS%20X)](https://travis-ci.org/snowleopard/hadrian) [![Windows status](https://img.shields.io/appveyor/ci/snowleopard/hadrian/master.svg?label=Windows)](https://ci.appveyor.com/project/snowleopard/hadrian) [![OS X status](https://img.shields.io/circleci/project/github/snowleopard/hadrian.svg?label=OS%20X)](https://circleci.com/gh/snowleopard/hadrian)
-This is the source tree for [GHC][1], a compiler and interactive
-environment for the Haskell functional programming language.
+Hadrian is a new build system for the [Glasgow Haskell Compiler][ghc]. It is based
+on [Shake][shake] and we hope that it will soon replace the current
+[Make-based build system][make]. If you are curious about the rationale behind the
+project and the architecture of the build system you can find more details in
+this [Haskell Symposium 2016 paper][paper] and this [Haskell eXchange 2016 talk][talk].
-For more information, visit [GHC's web site][1].
+The new build system can work side-by-side with the existing build system. Note, there is
+some interaction between them: they put (some) build results in the same directories,
+e.g. the resulting GHC is `inplace/bin/ghc-stage2`.
-Information for developers of GHC can be found on the [GHC Trac][2].
+Your first build
+----------------
+Beware, the build system is in the alpha development phase. Things are shaky and sometimes
+break; there are numerous [known issues][issues]. Not afraid? Then put on the helmet and
+run the following command from root of the GHC tree:
-Getting the Source
-==================
+```
+hadrian/build.sh -j
+```
-There are two ways to get a source tree:
+or on Windows:
- 1. *Download source tarballs*
+```
+hadrian/build.bat -j
+```
- Download the GHC source distribution:
+Here flag `-j` enables parallelism and is optional. We will further refer to the build script
+simply as `build`. Note that Hadrian can also run the `boot` and `configure` scripts
+automatically if you pass the flag `--configure`, or simply `-c`. See the overview of
+command line flags below.
- ghc-<version>-src.tar.bz2
+Notes:
- which contains GHC itself and the "boot" libraries.
+* If the default build script doesn't work, you might want to give a try to another one, e.g. based
+on Cabal sandboxes (`build.cabal.*`), Stack (`build.stack.*`) or the global package database
+(`build.global-db.*`). Also see [instructions for building GHC on Windows using Stack][windows-build].
- 2. *Check out the source code from git*
+* Hadrian is written in Haskell and depends on `shake` (plus a few packages that `shake` depends on),
+`ansi-terminal`, `mtl`, `quickcheck`, and GHC core libraries.
- $ git clone --recursive git://git.haskell.org/ghc.git
+* If you have never built GHC before, start with the [preparation guide][ghc-preparation].
- Note: cloning GHC from Github requires a special setup. See [Getting a GHC
- repository from Github][7].
+Using the build system
+----------------------
+Once your first build is successful, simply run `build` to rebuild. Build results
+are placed into `_build` and `inplace` directories.
- *See the GHC team's working conventions regarding [how to contribute a patch to GHC](http://ghc.haskell.org/trac/ghc/wiki/WorkingConventions/FixingBugs).* First time contributors are encouraged to get started by just sending a Pull Request.
+#### Command line flags
+In addition to standard Shake flags (try `--help`), the build system
+currently supports several others:
-Building & Installing
-=====================
+* `--configure` or `-c`: use this flag to run the `boot` and `configure` scripts
+automatically, so that you don't have to remember to run them manually as you normally
+do when using Make (typically only in the first build):
+ ```bash
+ ./boot
+ ./configure # On Windows run ./configure --enable-tarballs-autodownload
+ ```
+ Beware that with this flag Hadrian may do network I/O on Windows to download necessary
+ tarballs, which may sometimes be undesirable.
-For full information on building GHC, see the [GHC Building Guide][3].
-Here follows a summary - if you get into trouble, the Building Guide
-has all the answers.
+* `--flavour=FLAVOUR`: choose a build flavour. The following settings are currently supported:
+`default`, `quick`, `quickest`, `perf`, `prof`, `devel1` and `devel2`. As an example, the
+`quickest` flavour adds `-O0` flag to all GHC invocations and builds libraries only in the
+`vanilla` way, which speeds up builds by 3-4x. Build flavours are documented
+[here](https://github.com/snowleopard/hadrian/blob/master/doc/flavours.md).
-Before building GHC you may need to install some other tools and
-libraries. See, [Setting up your system for building GHC][8].
+* `--freeze1`: freeze Stage1 GHC, i.e. do not rebuild it even if some of its source files
+are out-of-date. This allows to significantly reduce the rebuild time when you are working
+on a feature that affects both Stage1 and Stage2 compilers, but may lead to incorrect
+build results. To unfreeze Stage1 GHC simply drop the `--freeze1` flag and Hadrian will
+rebuild all out-of-date files.
-*NB.* In particular, you need [GHC][1] installed in order to build GHC,
-because the compiler is itself written in Haskell. You also need
-[Happy][4], [Alex][5], and [Cabal][9]. For instructions on how
-to port GHC to a new platform, see the [GHC Building Guide][3].
+* `--integer-simple`: build GHC using the `integer-simple` integer library (instead
+of `integer-gmp`).
-For building library documentation, you'll need [Haddock][6]. To build
-the compiler documentation, you need [Sphinx](http://www.sphinx-doc.org/)
-and Xelatex (only for PDF output).
+* `--progress-colour=MODE`: choose whether to use colours when printing build progress
+info. There are three settings: `never` (do not use colours), `auto` (attempt to detect
+whether the console supports colours; this is the default setting), and `always` (use
+colours).
-**Quick start**: the following gives you a default build:
-
- $ ./boot
- $ ./configure
- $ make # can also say 'make -jX' for X number of jobs
- $ make install
-
- On Windows, you need an extra repository containing some build tools.
- These can be downloaded for you by configure. This only needs to be done once by running:
-
- $ ./configure --enable-tarballs-autodownload
-
-(NB: **Do you have multiple cores? Be sure to tell that to `make`!** This can
-save you hours of build time depending on your system configuration, and is
-almost always a win regardless of how many cores you have. As a simple rule,
-you should have about N+1 jobs, where `N` is the amount of cores you have.)
-
-The `./boot` step is only necessary if this is a tree checked out
-from git. For source distributions downloaded from [GHC's web site][1],
-this step has already been performed.
-
-These steps give you the default build, which includes everything
-optimised and built in various ways (eg. profiling libs are built).
-It can take a long time. To customise the build, see the file `HACKING.md`.
-
-Filing bugs and feature requests
-================================
-
-If you've encountered what you believe is a bug in GHC, or you'd like
-to propose a feature request, please let us know! Submit a ticket in
-our [bug tracker][10] and we'll be sure to look into it. Remember:
-**Filing a bug is the best way to make sure your issue isn't lost over
-time**, so please feel free.
-
-If you're an active user of GHC, you may also be interested in joining
-the [glasgow-haskell-users][11] mailing list, where developers and
-GHC users discuss various topics and hang out.
-
-Hacking & Developing GHC
-========================
-
-Once you've filed a bug, maybe you'd like to fix it yourself? That
-would be great, and we'd surely love your company! If you're looking
-to hack on GHC, check out the guidelines in the `HACKING.md` file in
-this directory - they'll get you up to speed quickly.
-
-Contributors & Acknowledgements
-===============================
-
-GHC in its current form wouldn't exist without the hard work of
-[its many contributors][12]. Over time, it has grown to include the
-efforts and research of many institutions, highly talented people, and
-groups from around the world. We'd like to thank them all, and invite
-you to join!
-
- [1]: http://www.haskell.org/ghc/ "www.haskell.org/ghc/"
- [2]: http://ghc.haskell.org/trac/ghc "ghc.haskell.org/trac/ghc"
- [3]: http://ghc.haskell.org/trac/ghc/wiki/Building
- "ghc.haskell.org/trac/ghc/wiki/Building"
- [4]: http://www.haskell.org/happy/ "www.haskell.org/happy/"
- [5]: http://www.haskell.org/alex/ "www.haskell.org/alex/"
- [6]: http://www.haskell.org/haddock/ "www.haskell.org/haddock/"
- [7]: https://ghc.haskell.org/trac/ghc/wiki/Building/GettingTheSources#GettingaGHCrepositoryfromGitHub
- "https://ghc.haskell.org/trac/ghc/wiki/Building/GettingTheSources#GettingaGHCrepositoryfromGitHub"
- [8]: http://ghc.haskell.org/trac/ghc/wiki/Building/Preparation
- "http://ghc.haskell.org/trac/ghc/wiki/Building/Preparation"
- [9]: http://www.haskell.org/cabal/ "http://www.haskell.org/cabal/"
- [10]: http://ghc.haskell.org/trac/ghc/
- "http://ghc.haskell.org/trac/ghc/"
- [11]: http://www.haskell.org/pipermail/glasgow-haskell-users/
- "http://www.haskell.org/pipermail/glasgow-haskell-users/"
- [12]: http://ghc.haskell.org/trac/ghc/wiki/TeamGHC
- "http://ghc.haskell.org/trac/ghc/wiki/TeamGHC"
+* `--progress-info=STYLE`: choose how build progress info is printed. There are four
+settings: `none`, `brief` (one line per build command; this is the default setting),
+`normal` (typically a box per build command), and `unicorn` (when `normal` just won't do).
+
+* `--split-objects`: generate split objects, which are switched off by default. Due to
+a GHC [bug][ghc-split-objs-bug], you need a full clean rebuild when using this flag.
+
+* `--verbose`: run Hadrian in verbose mode. In particular this prints diagnostic messages
+by Shake oracles.
+
+#### User settings
+
+The Make-based build system uses `mk/build.mk` to specify user build settings. We
+use `hadrian/UserSettings.hs` for the same purpose, see [documentation](doc/user-settings.md).
+
+#### Clean and full rebuild
+
+* `build clean` removes all build artefacts.
+
+* `build -B` forces Shake to rerun all rules, even if the previous build results are
+are still up-to-date.
+
+#### Documentation
+
+To build GHC documentation, run `build docs`. Note that finer-grain documentation
+targets (e.g. building only HTML documentation or only the GHC User's Guide)
+are currently not supported.
+
+#### Source distribution
+
+To build a GHC source distribution tarball, run `build sdist-ghc`.
+
+#### Installation
+
+To build and install GHC artifacts, run `build install`.
+
+By default, GHC will be installed to the specified _prefix_ path on your system,
+relative to the root of the file system. For example on UNIX, GHC will be installed
+to `/usr/local/bin`. By setting the command line flag `--install-destdir=[DESTDIR]`,
+you can install GHC to path `DESTDIR/<prefix>` instead. Make sure you use correct
+absolute path as `DESTDIR` on Windows, e.g. `C:/path`, which installs GHC
+into `C:/path/usr/local`.
+
+#### Testing
+
+* `build validate` runs GHC tests by simply executing `make fast` in `testsuite/tests`
+directory. This can be used instead of `sh validate --fast --no-clean` in the existing
+build system. Note: this will rebuild Stage2 GHC, `ghc-pkg` and `hpc` if they are out of date.
+
+* `build test` runs GHC tests by calling the `testsuite/driver/runtests.py` python
+script with appropriate flags. The current implementation is limited and cannot
+replace the `validate` script (see [#187][validation-issue]).
+
+* `build selftest` runs tests of the build system. Current test coverage is close to
+zero (see [#197][test-issue]).
+
+Current limitations
+-------------------
+The new build system still lacks many important features:
+* Validation is not implemented: [#187][validation-issue].
+* Dynamic linking on Windows is not supported [#343][dynamic-windows-issue].
+* There is no support for binary distribution: [#219][bin-dist-issue].
+
+Check out [milestones] to see when we hope to resolve the above limitations.
+
+How to contribute
+-----------------
+
+The best way to contribute is to try the new build system, report the issues
+you found, and attempt to fix them. Please note: the codebase is very unstable
+at present and we expect a lot of further refactoring. If you would like to
+work on a particular issue, please let everyone know by adding a comment about
+this. The issues that are currently on the critical path and therefore require
+particular attention are listed in [#239](https://github.com/snowleopard/hadrian/issues/239).
+Also have a look at [projects](https://github.com/snowleopard/hadrian/projects)
+where open issues and pull requests are grouped into categories.
+
+Acknowledgements
+----------------
+
+I started this project as part of my 6-month research visit to Microsoft
+Research Cambridge, which was funded by Newcastle University, EPSRC, and
+Microsoft Research. I would like to thank Simon Peyton Jones, Neil Mitchell
+and Simon Marlow for kick-starting the project and for their guidance.
+Zhen Zhang has done fantastic work on Hadrian as part of his Summer of
+Haskell 2017 [project](https://summer.haskell.org/ideas.html#hadrian-ghc),
+solving a few heavy and long-overdue issues. Last but not least, big thanks
+to all other project [contributors][contributors], who helped me endure and
+enjoy the project.
+
+[ghc]: https://en.wikipedia.org/wiki/Glasgow_Haskell_Compiler
+[shake]: https://github.com/ndmitchell/shake
+[make]: https://ghc.haskell.org/trac/ghc/wiki/Building/Architecture
+[paper]: https://www.staff.ncl.ac.uk/andrey.mokhov/Hadrian.pdf
+[talk]: https://skillsmatter.com/skillscasts/8722-meet-hadrian-a-new-build-system-for-ghc
+[issues]: https://github.com/snowleopard/hadrian/issues
+[ghc-preparation]: https://ghc.haskell.org/trac/ghc/wiki/Building/Preparation
+[ghc-windows-quick-build]: https://ghc.haskell.org/trac/ghc/wiki/Building/Preparation/Windows#AQuickBuild
+[windows-build]: https://github.com/snowleopard/hadrian/blob/master/doc/windows.md
+[ghc-split-objs-bug]: https://ghc.haskell.org/trac/ghc/ticket/11315
+[test-issue]: https://github.com/snowleopard/hadrian/issues/197
+[validation-issue]: https://github.com/snowleopard/hadrian/issues/187
+[dynamic-windows-issue]: https://github.com/snowleopard/hadrian/issues/343
+[bin-dist-issue]: https://github.com/snowleopard/hadrian/issues/219
+[milestones]: https://github.com/snowleopard/hadrian/milestones
+[contributors]: https://github.com/snowleopard/hadrian/graphs/contributors
diff --git a/build.nix.sh b/build.nix.sh
new file mode 100755
index 0000000000..4b03ea8418
--- /dev/null
+++ b/build.nix.sh
@@ -0,0 +1,35 @@
+#!/usr/bin/env nix-shell
+#! nix-shell -i bash shell.nix
+
+# This script sets up the build environment by invoking nix-shell shell.nix
+# and then runs the hadrian executable.
+
+function rl {
+ TARGET_FILE="$1"
+
+ cd "$(dirname "$TARGET_FILE")"
+ TARGET_FILE="$(basename "$TARGET_FILE")"
+
+ # Iterate down a (possible) chain of symlinks
+ while [ -L "$TARGET_FILE" ]
+ do
+ TARGET_FILE="$(readlink "$TARGET_FILE")"
+ cd "$(dirname "$TARGET_FILE")"
+ TARGET_FILE="$(basename "$TARGET_FILE")"
+ done
+
+ # Compute the canonicalized name by finding the physical path
+ # for the directory we're in and appending the target file.
+ PHYS_DIR="$(pwd -P)"
+ RESULT="$PHYS_DIR/$TARGET_FILE"
+ echo "$RESULT"
+}
+
+absoluteRoot="$(dirname "$(rl "$0")")"
+echo $absoluteRoot
+cd "$absoluteRoot"
+
+hadrian \
+ --lint \
+ --directory="$absoluteRoot/.." \
+ "$@"
diff --git a/hadrian/cabal.project b/hadrian/cabal.project
index 317094fb74..0d2b509daa 100644
--- a/hadrian/cabal.project
+++ b/hadrian/cabal.project
@@ -1,6 +1,5 @@
packages: ./
../libraries/Cabal/Cabal/
- ../libraries/filepath/
- ../libraries/text/
../libraries/hpc/
../libraries/parsec/
+ ../libraries/text/
diff --git a/hadrian/hadrian.cabal b/hadrian/hadrian.cabal
index 389f5530c1..9c170bcd16 100644
--- a/hadrian/hadrian.cabal
+++ b/hadrian/hadrian.cabal
@@ -116,17 +116,17 @@ executable hadrian
, TupleSections
other-extensions: MultiParamTypeClasses
, TypeFamilies
- build-depends: base >= 4.8 && < 5
+ build-depends: base >= 4.8 && < 5
, ansi-terminal == 0.6.*
, Cabal >= 2.0.0.2 && < 2.2
, containers == 0.5.*
- , directory >= 1.2 && < 1.4
+ , directory >= 1.2 && < 1.4
, extra >= 1.4.7
, mtl == 2.2.*
- , QuickCheck >= 2.6 && < 2.10
+ , QuickCheck >= 2.6 && < 2.10
, shake == 0.16.*
- , transformers >= 0.4 && < 0.6
- , unordered-containers == 0.2.*
+ , transformers >= 0.4 && < 0.6
+ , unordered-containers >= 0.2.1 && < 0.3
build-tools: alex >= 3.1
, happy >= 1.19.4
ghc-options: -Wall
diff --git a/hadrian/src/Rules/Compile.hs b/hadrian/src/Rules/Compile.hs
index a4b1278660..b7f3bc8447 100644
--- a/hadrian/src/Rules/Compile.hs
+++ b/hadrian/src/Rules/Compile.hs
@@ -22,8 +22,6 @@ compilePackage rs context@Context {..} = do
path <- buildPath context
(src, deps) <- lookupDependencies (path -/- ".dependencies") obj
need $ src : deps
- when (isLibrary package) $ need =<< return <$> pkgConfFile context
- needLibrary =<< contextDependencies context
buildWithResources rs $ target context (Ghc CompileHs stage) [src] [obj]
priority 2.0 $ do
diff --git a/hadrian/src/Rules/Dependencies.hs b/hadrian/src/Rules/Dependencies.hs
index f27ef0d912..f9d17e93d8 100644
--- a/hadrian/src/Rules/Dependencies.hs
+++ b/hadrian/src/Rules/Dependencies.hs
@@ -19,11 +19,11 @@ buildPackageDependencies rs context@Context {..} =
orderOnly =<< interpretInContext context generatedDependencies
let mk = deps <.> "mk"
if null srcs
- then writeFileChanged mk ""
+ then writeFile' mk ""
else buildWithResources rs $
target context (Ghc FindHsDependencies stage) srcs [mk]
removeFile $ mk <.> "bak"
- mkDeps <- readFile' mk
+ mkDeps <- liftIO $ readFile mk
writeFileChanged deps . unlines
. map (\(src, deps) -> unwords $ src : deps)
. map (bimap unifyPath (map unifyPath))
diff --git a/hadrian/src/Rules/Program.hs b/hadrian/src/Rules/Program.hs
index ba4dab0442..dca177f879 100644
--- a/hadrian/src/Rules/Program.hs
+++ b/hadrian/src/Rules/Program.hs
@@ -92,7 +92,6 @@ buildWrapper context@Context {..} wrapper wrapperPath wrapped = do
putSuccess $ "| Successfully created wrapper for " ++
quote (pkgName package) ++ " (" ++ show stage ++ ")."
--- TODO: Get rid of the Paths_hsc2hs.o hack.
buildBinary :: [(Resource, Int)] -> FilePath -> Context -> Action ()
buildBinary rs bin context@Context {..} = do
binDeps <- if stage == Stage0 && package == ghcCabal
@@ -107,8 +106,6 @@ buildBinary rs bin context@Context {..} = do
cObjs <- mapM (objectPath context) cSrcs
hsObjs <- hsObjects context
return $ cObjs ++ hsObjs
- ++ [ path -/- "Paths_hsc2hs.o" | package == hsc2hs ]
- ++ [ path -/- "Paths_haddock.o" | package == haddock ]
need binDeps
buildWithResources rs $ target context (Ghc LinkHs stage) binDeps [bin]
synopsis <- traverse pkgSynopsis (pkgCabalFile package)
diff --git a/hadrian/src/Settings/Builders/Ghc.hs b/hadrian/src/Settings/Builders/Ghc.hs
index a975e7e799..af78b74637 100644
--- a/hadrian/src/Settings/Builders/Ghc.hs
+++ b/hadrian/src/Settings/Builders/Ghc.hs
@@ -87,10 +87,10 @@ haddockGhcArgs = mconcat [ commonGhcArgs, getPkgDataList HsArgs ]
-- Used in ghcBuilderArgs, ghcCBuilderArgs, ghcMBuilderArgs and haddockGhcArgs.
commonGhcArgs :: Args
commonGhcArgs = do
- way <- getWay
- path <- getBuildPath
- pkg <- getPackage
- when (isLibrary pkg) $ do
+ way <- getWay
+ path <- getBuildPath
+ pkg <- getPackage
+ when (pkg == rts) $ do
context <- getContext
conf <- expr $ pkgConfFile context
expr $ need [conf]
diff --git a/hadrian/src/Settings/Packages/GhcCabal.hs b/hadrian/src/Settings/Packages/GhcCabal.hs
index 0e915b3ea6..c88617b97f 100644
--- a/hadrian/src/Settings/Packages/GhcCabal.hs
+++ b/hadrian/src/Settings/Packages/GhcCabal.hs
@@ -8,10 +8,11 @@ import Utilities
ghcCabalPackageArgs :: Args
ghcCabalPackageArgs = stage0 ? package ghcCabal ? builder Ghc ? do
- cabalDeps <- expr $ stage1Dependencies cabal
+ cabalDeps <- expr $ stage1Dependencies cabal
+ let bootDeps = cabalDeps \\ [integerGmp, integerSimple, mtl, parsec, text]
cabalVersion <- expr $ pkgVersion (unsafePkgCabalFile cabal) -- TODO: improve
mconcat
- [ pure [ "-package " ++ pkgName pkg | pkg <- cabalDeps \\ [parsec, mtl] ]
+ [ pure [ "-package " ++ pkgName pkg | pkg <- bootDeps ]
, arg "--make"
, arg "-j"
, pure ["-Wall", "-fno-warn-unused-imports", "-fno-warn-warnings-deprecations"]
diff --git a/hadrian/src/Utilities.hs b/hadrian/src/Utilities.hs
index 3c61daecfd..fc898c35b9 100644
--- a/hadrian/src/Utilities.hs
+++ b/hadrian/src/Utilities.hs
@@ -24,21 +24,29 @@ buildWithResources rs target = H.buildWithResources rs target getArgs
buildWithCmdOptions :: [CmdOption] -> Target -> Action ()
buildWithCmdOptions opts target = H.buildWithCmdOptions opts target getArgs
--- | Given a 'Context' this 'Action' look up the package dependencies and wrap
+-- TODO: Cache the computation.
+-- | Given a 'Context' this 'Action' looks up the package dependencies and wraps
-- the results in appropriate contexts. The only subtlety here is that we never
-- depend on packages built in 'Stage2' or later, therefore the stage of the
-- resulting dependencies is bounded from above at 'Stage1'. To compute package
--- dependencies we scan package @.cabal@ files, see 'pkgDependencies' defined
--- in "Hadrian.Haskell.Cabal".
+-- dependencies we transitively scan @.cabal@ files using 'pkgDependencies'
+-- defined in "Hadrian.Haskell.Cabal".
contextDependencies :: Context -> Action [Context]
-contextDependencies Context {..} = case pkgCabalFile package of
- Nothing -> return [] -- Non-Cabal packages have no dependencies.
- Just cabalFile -> do
- let depStage = min stage Stage1
- depContext = \pkg -> Context depStage pkg way
- deps <- pkgDependencies cabalFile
- pkgs <- sort <$> stagePackages depStage
- return . map depContext $ intersectOrd (compare . pkgName) pkgs deps
+contextDependencies Context {..} = do
+ depPkgs <- go [package]
+ return [ Context depStage pkg way | pkg <- depPkgs, pkg /= package ]
+ where
+ depStage = min stage Stage1
+ go pkgs = do
+ deps <- concatMapM step pkgs
+ let newPkgs = nubOrd $ sort (deps ++ pkgs)
+ if pkgs == newPkgs then return pkgs else go newPkgs
+ step pkg = case pkgCabalFile pkg of
+ Nothing -> return [] -- Non-Cabal packages have no dependencies.
+ Just cabalFile -> do
+ deps <- pkgDependencies cabalFile
+ active <- sort <$> stagePackages depStage
+ return $ intersectOrd (compare . pkgName) active deps
-- | Lookup dependencies of a 'Package' in the vanilla Stage1 context.
stage1Dependencies :: Package -> Action [Package]
diff --git a/hadrian/stack.yaml b/hadrian/stack.yaml
index a1b7413474..1d3f6e3b38 100644
--- a/hadrian/stack.yaml
+++ b/hadrian/stack.yaml
@@ -7,10 +7,9 @@ resolver: lts-9.0
packages:
- '.'
- '../libraries/Cabal/Cabal'
-- '../libraries/filepath/'
-- '../libraries/text/'
-- '../libraries/hpc/'
-- '../libraries/parsec/'
+- '../libraries/hpc'
+- '../libraries/parsec'
+- '../libraries/text'
extra-deps:
- shake-0.16
diff --git a/shell.nix b/shell.nix
new file mode 100644
index 0000000000..e9a5ecc88e
--- /dev/null
+++ b/shell.nix
@@ -0,0 +1,61 @@
+# Invoking nix-shell sets up an environment where we can build ghc
+# by only invoking hadrian.
+
+
+{ nixpkgs ? import <nixpkgs> {} }:
+
+let
+ haskellPackages = nixpkgs.haskell.packages.ghc821;
+
+ removeBuild = path: type:
+ let baseName = baseNameOf (toString path);
+ in
+ ! (baseName == "_build"
+ || baseName == "dist"
+ || baseName == "dist-newstyle"
+ || baseName == ".stack-work"
+ || baseName == "config.log"
+ || baseName == "config.status"
+ || nixpkgs.lib.hasSuffix ".sh" baseName
+ || !(nixpkgs.lib.cleanSourceFilter path type)) ;
+
+ filterSrc = path: builtins.filterSource removeBuild path;
+
+
+ hadrianPackages = nixpkgs.haskell.packages.ghc821.override {
+ overrides = self: super: let
+ localPackage = name: path: self.callCabal2nix name (filterSrc path) {};
+ in {
+ hadrian = localPackage "hadrian" ./. ;
+ shake = self.callHackage "shake" "0.16" {};
+ Cabal = localPackage "Cabal" ./../libraries/Cabal/Cabal ;
+ filepath = localPackage "filepath" ./../libraries/filepath ;
+ text = localPackage "text" ./../libraries/text ;
+ hpc = localPackage"hpc" ./../libraries/hpc ;
+ parsec = localPackage "parsec" ./../libraries/parsec ;
+ HUnit = nixpkgs.haskell.lib.dontCheck (self.callHackage "HUnit" "1.3.1.2" {});
+ process = localPackage "process" ./../libraries/process ;
+ directory = localPackage "directory" ./../libraries/directory ;
+ }; };
+
+in
+
+ nixpkgs.stdenv.mkDerivation {
+ name = "ghc-dev";
+ buildInputs = [
+ hadrianPackages.hadrian
+ nixpkgs.haskell.compiler.ghc821
+ haskellPackages.alex
+ haskellPackages.happy
+ nixpkgs.python3
+ nixpkgs.git
+ nixpkgs.autoconf
+ nixpkgs.automake
+ nixpkgs.perl
+ nixpkgs.gcc
+ nixpkgs.python3Packages.sphinx
+ nixpkgs.ncurses
+ nixpkgs.m4
+ nixpkgs.gmp
+ nixpkgs.file ];
+ }