Opened 4 weeks ago

Closed 6 days ago

Last modified 33 hours ago

#16069 closed bug (fixed)

Proposal to resolve some confusion about stages in Hadrian

Reported by: mpickering Owned by:
Priority: normal Milestone:
Component: Compiler Version: 8.6.3
Keywords: Cc: snowleopard, alpmestan, harpocrates
Operating System: Unknown/Multiple Architecture: Unknown/Multiple
Type of failure: None/Unknown Test Case:
Blocked By: Blocking:
Related Tickets: Differential Rev(s):
Wiki Page:

Description

The current situation with hadrian is that

  1. We build libraries required to build the stage2 compiler with stage1 and place them in _build/stage1.
  2. The stage2 compiler is built with stage1 and then placed in _build/stage1.
  3. Executables built using the stage2 compiler such as haddock then also

use the libraries built by the stage1 compiler even though they are being built with the stage2 compiler.

However, this is problematic because when you want to build a stage3 compiler, we want to actually build the libraries again using the stage2 compiler and place them in _build/stage2. If we follow the existing logic for executables built using the stage2 compiler then in order to build a stage3 compiler we would just reuse all the libraries from _build/stage1 which seems incorrect.

The proposal is simply thus:

  1. When building an executable at stageN, we use libraries also built at stageN. Concretely, if we want to build haddock, a stage2 executable, then we also have to build all the libraries it needs with the stage2 compiler and install them into a package database in _build/stage2.
  2. The definition of "build" can be configured. By default, in order to "build" a stage2 library we copy it from the stage1 database but it is configurable to rebuild it with the stage2 compiler as we would want to for stage3.

Change History (5)

comment:1 Changed 4 weeks ago by alpmestan

Cc: alpmestan added

comment:2 Changed 4 weeks ago by harpocrates

Cc: harpocrates added

comment:3 Changed 4 weeks ago by snowleopard

This simplification is something I wanted to do for a while, but there is an important question to answer: are we going to build Haddock using Stage1 GHC or Stage2 GHC?

The Make build system builds Haddock using Stage2 GHC. I therefore copy my question from the GitHub issue (https://github.com/snowleopard/hadrian/issues/661):

We know that building Haddock with Stage1 GHC works, but is this the right thing to do? Why does the Make build system uses the Stage2 GHC to build Haddock? Is it OK for Hadrian to deviate from Make in this respect?

If the answer to the above is "It is OK for Hadrian to use Stage1 GHC to build Haddock" then I'll happily support this proposal.

However, if the answer is "Hadrian must also use Stage2 GHC to build Haddock" then I'm afraid this proposal means significantly longer build times, since now we'll need to build Stage2 libraries, just in order to build Haddock and docs.

comment:4 Changed 6 days ago by mpickering

Resolution: fixed
Status: newclosed

comment:5 Changed 33 hours ago by Matthew Pickering <matthewtpickering@…>

In 6486c6e4/ghc:

Hadrian: Add support for building stage3

This ticket enables the building of a `stage3` compiler by making the
build logic more consistent and predictable in Hadrian.

Two of the main changes are:

1. In order to build anything at stageN we use the package database
present at stageN. Fixing #16069
2. `haddock` and `ghc-tags` are built
as stage1 executables (with the stage1 compiler) rather than as
stage2 compiler. Fixing
[hadrian#661](https://github.com/snowleopard/hadrian/issues/661)

In order to build a stage3 compiler, you have to set the new `finalStage` hadrian option to `Stage3`.
Note: See TracTickets for help on using tickets.