[Git][ghc/ghc][wip/hadrian-cross-stage2] 13 commits: Read global package database from settings file

Matthew Pickering (@mpickering) gitlab at gitlab.haskell.org
Thu Mar 7 14:24:56 UTC 2024



Matthew Pickering pushed to branch wip/hadrian-cross-stage2 at Glasgow Haskell Compiler / GHC


Commits:
5d441f0a by Matthew Pickering at 2024-03-05T10:57:55+00:00
Read global package database from settings file

Before this patch, the global package database was always assumed to be
in libdir </> package.conf.d.

This causes issues in GHC's build system because there are sometimes
situations where the package database you need to use is not located in
the same place as the settings file.

* The stage1 compiler needs to use stage1 libraries, so we should set
  "Global Package DB" for the stage1 compiler to the stage1 package
  database.
* Stage 2 cross compilers need to use stage2 libraries, so likewise, we
  should set the package database path to `_build/stage2/lib/`

* The normal situation is where the stage2 compiler uses stage1
  libraries. Then everything lines up.

* When installing we have rearranged everything so that the settings
  file and package database line up properly, so then everything should
  continue to work as before. In this case we set the relative package
  db path to `package.conf.d`, so it resolves the same as before.

* ghc-pkg needs to be modified as well to look in the settings file fo
  the package database rather than assuming the global package database
  location relative to the lib folder.

* Cabal/cabal-install will work correctly because they query the global
  package database using `--print-global-package-db`.

A reasonable question is why not generate the "right" settings files in
the right places in GHC's build system. In order to do this you would
need to engineer wrappers for all executables to point to a specific
libdir. There are also situations where the same package db is used by
two different compilers with two different settings files (think stage2
cross compiler and stage3 compiler).

In short, this 10 line patch allows for some reasonable simplifications
in Hadrian at very little cost to anything else.

Fixes #24502

- - - - -
8e3cb48c by Matthew Pickering at 2024-03-05T10:58:29+00:00
hadrian: Remove stage1 testsuite wrappers logic

Now instead of producing wrappers which pass the global package database
argument to ghc and ghc-pkg, we write the location of the correct
package database into the settings file so you can just use the intree
compiler directly.

- - - - -
69a784c5 by Matthew Pickering at 2024-03-05T10:58:30+00:00
Add missing req_interp modifier to T18441fail3 and T18441fail19

These tests require the interpreter but they were failing in a different
way with the javascript backend because the interpreter was disabled and
stderr is ignored by the test.

- - - - -
6f5a6e84 by Matthew Pickering at 2024-03-05T10:58:30+00:00
Use explicit syntax rather than pure

- - - - -
f41941e2 by Matthew Pickering at 2024-03-05T10:58:30+00:00
ci: Fail when bindist configure fails when installing bindist

It is better to fail earlier if the configure step fails rather than
carrying on for a more obscure error message.

- - - - -
18d982b3 by Matthew Pickering at 2024-03-05T10:58:30+00:00
packaging: correctly propagate build/host/target to bindist configure script

At the moment the host and target which we will produce a compiler for
is fixed at the initial configure time. Therefore we need to persist
the choice made at this time into the installation bindist as well so we
look for the right tools, with the right prefixes at install time.

In the future, we want to provide a bit more control about what kind of
bindist we produce so the logic about what the host/target will have to
be written by hadrian rather than persisted by the configure script. In
particular with cross compilers we want to either build a normal stage 2
cross bindist or a stage 3 bindist, which creates a bindist which has a
native compiler for the target platform.

Fixes #21970

- - - - -
5d495163 by Matthew Pickering at 2024-03-05T10:58:31+00:00
hadrian: Fill in more of the default.host toolchain file

When you are building a cross compiler this file will be used to build
stage1 and it's libraries, so we need enough information here to work
accurately. There is still more work to be done (see for example, word
size is still fixed).

- - - - -
a6b154ea by Matthew Pickering at 2024-03-05T10:58:31+00:00
hadrian: Disable docs when cross compiling

Before there were a variety of ad-hoc places where doc building was
disabled when cross compiling.

* Some CI jobs sets --docs=none in gen_ci.hs
* Some CI jobs set --docs=none in .gitlab/ci.sh
* There was some logic in hadrian to not need the ["docs"] target when
  making a bindist.

Now the situation is simple:

* If you are cross compiling then defaultDocsTargets is empty by
  default.

In theory, there is no reason why we can't build documentation for cross
compiler bindists, but this is left to future work to generalise the
documentation building rules to allow this (#24289)

- - - - -
af1c68f1 by Matthew Pickering at 2024-03-05T10:58:31+00:00
hadrian: Build stage 2 cross compilers

* Most of hadrian is abstracted over the stage in order to remove the
  assumption that the target of all stages is the same platform. This
  allows the RTS to be built for two different targets for example.
* Abstracts the bindist creation logic to allow building either normal
  or cross bindists. Normal bindists use stage 1 libraries and a stage 2
  compiler. Cross bindists use stage 2 libararies and a stage 2
  compiler.
* hadrian: Make binary-dist-dir the default build target. This allows us
  to have the logic in one place about which libraries/stages to build
  with cross compilers. Fixes #24192

New hadrian target:

* `binary-dist-dir-cross`: Build a cross compiler bindist (compiler =
  stage 1, libraries = stage 2)

-------------------------
Metric Decrease:
    T10421a
    T10858
    T11195
    T11276
    T11374
    T11822
    T15630
    T17096
    T18478
    T20261
Metric Increase:
    parsing001
-------------------------

- - - - -
9061af22 by Matthew Pickering at 2024-03-05T10:58:31+00:00
ci: Test cross bindists

We remove the special logic for testing in-tree cross
compilers and instead test cross compiler bindists, like we do for all
other platforms.

- - - - -
e0c65d20 by Matthew Pickering at 2024-03-05T10:58:31+00:00
ci: Javascript don't set CROSS_EMULATOR

There is no CROSS_EMULATOR needed to run javascript binaries, so we
don't set the CROSS_EMULATOR to some dummy value.

- - - - -
5788d3d8 by Matthew Pickering at 2024-03-05T10:58:31+00:00
ci: Introduce CROSS_STAGE variable

In preparation for building and testing stage3 bindists we introduce the
CROSS_STAGE variable which is used by a CI job to determine what kind of
bindist the CI job should produce.

At the moment we are only using CROSS_STAGE=2 but in the future we will
have some jobs which set CROSS_STAGE=3 to produce native bindists for a
target, but produced by a cross compiler, which can be tested on by
another CI job on the native platform.

CROSS_STAGE=2: Build a normal cross compiler bindist
CROSS_STAGE=3: Build a stage 3 bindist, one which is a native compiler and library for the target

- - - - -
effc3666 by Matthew Pickering at 2024-03-07T14:17:22+00:00
Split up system.config into host/target config files

There were a number of settings which were not applied per-stage, for
example if you specified `--ffi-include-dir` then that was applied to
both host and target. Now this will just be passed when building the
crosscompiler.

The solution for now is to separate these two files into host/target and
the host file contains very bare-bones . There isn't currently a way to
specify with configure anything in the host file, so if you are building
a cross-compiler and you need to do that, you have to modify the file
yourself.

- - - - -


30 changed files:

- .gitlab/ci.sh
- .gitlab/generate-ci/gen_ci.hs
- .gitlab/jobs.yaml
- compiler/GHC/Driver/Session.hs
- compiler/GHC/Settings/IO.hs
- configure.ac
- distrib/configure.ac.in
- hadrian/bindist/Makefile
- hadrian/bindist/config.mk.in
- hadrian/cfg/default.host.target.in
- hadrian/cfg/system.config.in
- hadrian/hadrian.cabal
- hadrian/src/Base.hs
- + hadrian/src/BindistConfig.hs
- hadrian/src/Builder.hs
- hadrian/src/Context.hs
- hadrian/src/Expression.hs
- hadrian/src/Flavour.hs
- hadrian/src/Flavour/Type.hs
- hadrian/src/Hadrian/Expression.hs
- hadrian/src/Hadrian/Haskell/Hash.hs
- hadrian/src/Hadrian/Oracles/TextFile.hs
- hadrian/src/Oracles/Flag.hs
- hadrian/src/Oracles/Flavour.hs
- hadrian/src/Oracles/Setting.hs
- hadrian/src/Oracles/TestSettings.hs
- hadrian/src/Packages.hs
- hadrian/src/Rules.hs
- hadrian/src/Rules/BinaryDist.hs
- hadrian/src/Rules/CabalReinstall.hs


The diff was not included because it is too large.


View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/69d8b51b500b8b879413feb552c1b7bd9125e120...effc3666a001efbf9f8e9c9c0416a7b4573f52ad

-- 
View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/69d8b51b500b8b879413feb552c1b7bd9125e120...effc3666a001efbf9f8e9c9c0416a7b4573f52ad
You're receiving this email because of your account on gitlab.haskell.org.


-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.haskell.org/pipermail/ghc-commits/attachments/20240307/53cf9ffe/attachment-0001.html>


More information about the ghc-commits mailing list