@@ -305,164 +305,13 @@ compiler: ghc-9.10.2
305305compiler-check : match-exact
306306~~~
307307
308- # ## Building GHC from source
309-
310308:octicons-beaker-24 : Experimental
311309
312310[:octicons-tag-24 : 2.1.1](https://github.com/commercialhaskell/stack/releases/tag/v2.1.1)
313311
314- Stack supports building the GHC compiler from source, using
315- [Hadrian](https://gitlab.haskell.org/ghc/ghc/blob/master/hadrian/README.md) (the
316- build system for GHC). The GHC version to build and to use is defined by a a Git
317- commit ID and a Hadrian "flavour", with the following syntax :
318-
319- ~~~yaml
320- compiler : ghc-git-<commit_id>-<Hadrian_flavour>
321- ~~~
322-
323- In the following example the commit ID is "5be7ad..." and the flavour is
324- " quick " :
325-
326- ~~~yaml
327- compiler : ghc-git-5be7ad7861c8d39f60b7101fd8d8e816ff50353a-quick
328- ~~~
329-
330- By default, the code is retrieved from the main GHC repository. If you want to
331- select another repository, use the `compiler-repository` option :
332-
333- ~~~yaml
334- compiler-repository : git://my/ghc/repository
335- # default
336- # compiler-repository: https://gitlab.haskell.org/ghc/ghc.git
337- ~~~
338-
339- Stack does not check the compiler version when it uses a compiler built from
340- source. It is assumed that the built compiler is recent enough as Stack does not
341- enable any known workaround to make older compilers work.
342-
343- Building the compiler can take a very long time (more than one hour). For faster
344- build times, use Hadrian flavours that disable documentation generation.
345-
346- ### Bootstrap compiler
347-
348- Building GHC from source requires a working GHC (known as the bootstrap
349- compiler). As we use a Stack based version of Hadrian (` hadrian/build-stack ` in
350- GHC sources), the bootstrap compiler is configured into ` hadrian/stack.yaml ` and
351- fully managed by Stack.
352-
353- !!! note
354-
355- For some commit IDs, the snapshot specified in `hadrian/stack.yaml`
356- specifies a version of GHC that cannot be used to build GHC. This results in
357- GHC's `configure` script reporting messages similar to the following before
358- aborting:
359-
360- ~~~text
361- checking version of ghc... 9.0.2
362- configure: error: GHC version 9.2 or later is required to compile GHC.
363- ~~~
364-
365- The resolution is: (1) to specify an alternative snapshot (one that
366- specifies a sufficiently recent version of GHC) on the command line, using
367- Stack's option `--snapshot <snapshot>`. Stack will use that snapshot when
368- running GHC's `configure` script; and (2) to set the contents of the `STACK`
369- environment variable to be `stack --snapshot <snapshot>`. Hadrian's
370- `build-stack` script wil refer to that environment variable for the Stack
371- command it uses.
372-
373- ### Hadrian prerequisites
374-
375- The Hadrian build system has certain
376- [ prerequisites] ( https://gitlab.haskell.org/ghc/ghc/-/wikis/building/preparation ) .
377- It requires certain versions of the ` happy ` and ` alex ` executables on the PATH.
378- Stack will build and install ` happy ` and ` alex ` , if not already on the PATH.
379-
380- === "macOS"
381-
382- Hadrian requires, or case use, certain tools or Python packages that do not
383- come with macOS by default and that need to be installed using `brew` or
384- `pip3` (Python). Hadrian's LaTeX documentation also requires the
385- [DejaVu fonts](https://dejavu-fonts.github.io/) to be installed.
386-
387- ~~~zsh
388- 389- # GHC uses a Python script named `boot`.
390- brew install automake
391- # Tool for generating GNU Standards-compliant Makefiles.
392- brew install texinfo
393- # Official documentation format of the GNU project.
394- pip3 install -U sphinx
395- # Sphinx is the Python documentation generator.
396- brew install --cask mactex
397- # MacTeX: Full TeX Live distribution with GUI applications
398- ~~~
399-
400- === "Windows"
401-
402- Hadrian requires, or can use, certain MSYS2 or Python packages that do not
403- come with the Stack-supplied MSYS2 by default and need to be installed
404- using `pacman` (MSYS2) or `pip` (Python). Hadrian's LaTeX documentation also
405- requires the [DejaVu fonts](https://dejavu-fonts.github.io/) to be
406- installed.
407-
408- ~~~pwsh
409- stack exec -- pacman --sync --refresh
410- # Synchronize MSYS2 package databases
411- stack exec -- pacman --sync mingw-w64-x86_64-python-pip
412- # The PyPA recommended tool (pip) for installing Python packages. Also
413- # installs Python as a dependency. GHC uses a Python script named `boot`.
414- # The package must be the one from the `mingw64` MSYS2 repository, as Python
415- # from the `msys` repository cannot interpret Windows file paths correctly.
416- stack exec -- pacman --sync mingw-w64-x86_64-autotools
417- # The GNU autotools build system, including `autoreconf`, `aclocal`
418- # and `make`. GHC uses a sh script named `configure` which is itself created
419- # from a file named `configure.ac`.
420- stack exec -- pacman --sync patch
421- # A utility to apply patch files to original sources.
422- stack exec -- pacman --sync texinfo
423- # Utilities to work with and produce manuals, ASCII text, and on-line
424- # documentation from a single source file, including `makeinfo`.
425- stack exec -- pacman --sync mingw-w64-x86_64-ca-certificates
426- # Common CA (certificate authority) certificates.
427- stack exec -- pip install -U sphinx
428- # Sphinx is the Python documentation generator.
429- ~~~
430-
431- Hadrian may require certain LaTeX packages and may prompt for these to be
432- installed duing the build process.
433-
434- ### Global packages
435-
436- The GHC compiler you build from sources may depend on unreleased versions of
437- some global packages (e.g. Cabal). It may be an issue if a package you try to
438- build with this compiler depends on such global packages because Stack may not
439- be able to find versions of those packages (on Hackage, etc.) that are
440- compatible with the compiler.
441-
442- The easiest way to deal with this issue is to use the
443- [ ` drop-packages ` ] ( project.md#drop-packages ) project-specific configuration
444- option to drop the offending packages as follows. Instead of using the packages
445- specified in the snapshot, the global packages bundled with GHC will be used.
446-
447- ~~~ yaml
448- drop-packages :
449- - Cabal
450- - ...
451- ~~~
452-
453- Another way to deal with this issue is to add the relevant packages as
454- [`extra-deps`](project.md#extra-deps) built from source. To avoid mismatching
455- versions, you can use exactly the same commit id you used to build GHC as
456- follows :
457-
458- ~~~
459- extra-deps :
460- - git : https://gitlab.haskell.org/ghc/ghc.git
461- commit : ' 5be7ad7861c8d39f60b7101fd8d8e816ff50353a'
462- subdirs :
463- - libraries/Cabal/Cabal
464- - libraries/...
465- ~~~
312+ Stack also supports building the GHC compiler from source. For further
313+ information, see the [building GHC from source](../../topics/GHC_from_source.md)
314+ documentation.
466315
467316# # compiler-check
468317
@@ -915,7 +764,7 @@ Command line equivalent (takes precedence):
915764Specifies the number of concurrent jobs (principally, Stack actions during
916765building - see further below) to run.
917766
918- When [ building GHC from source] ( #building-ghc-from-source ) , specifies the
767+ When [ building GHC from source] ( ../../topics/GHC_from_source.md ) , specifies the
919768` -j[<n>] ` flag of GHC's Hadrian build system.
920769
921770In some circumstances, the default can cause some machines to run out of memory
0 commit comments