[Git][ghc/ghc][wip/toolchain-selection] 2 commits: ghc-toolchain: Toolchain Selection

Rodrigo Mesquita (@alt-romes) gitlab at gitlab.haskell.org
Mon Jul 17 16:57:38 UTC 2023



Rodrigo Mesquita pushed to branch wip/toolchain-selection at Glasgow Haskell Compiler / GHC


Commits:
2fbbecc5 by Rodrigo Mesquita at 2023-07-17T17:56:34+01:00
ghc-toolchain: Toolchain Selection

This commit integrates ghc-toolchain, the brand new way of configuring
toolchains for GHC, with the Hadrian build system, with configure, and
extends and improves the first iteration of ghc-toolchain.

The general overview is

* We introduce a program invoked `ghc-toolchain --triple=...` which, when run,
  produces a file with a `Target`. A `GHC.Toolchain.Target.Target`
  describes the properties of a target and the toolchain (executables
  and configured flags) to produce code for that target

* Hadrian was modified to read Target files, and will both
  * Invoke the toolchain configured in the Target file as needed
  * Produce a `settings` file for GHC based on the Target file for that stage

* `./configure` will invoke ghc-toolchain to generate target files, but
  it will also generate target files based on the flags configure itself
  configured (through `.in` files that are substituted)

  * By default, the Targets generated by configure are still (for now) the ones used by Hadrian

  * But we additionally validate the Target files generated by
    ghc-toolchain against the ones generated by configure, to get a head
    start on catching configuration bugs before we transition
    completely.

  * When we make that transition, we will want to drop a lot of the
    toolchain configuration logic from configure, but keep it otherwise.

* For each compiler stage we should have 1 target file (up to a stage compiler we can't run in our machine)
  * We just have a HOST target file, which we use as the target for stage0
  * And a TARGET target file, which we use for stage1 (and later stages, if not cross compiling)
  * Note there is no BUILD target file, because we only support cross compilation where BUILD=HOST
  * (for more details on cross-compilation see discussion on !9263)

Ticket: #19877
MR: !9263

---

ghc-toolchain: Rename readProcess to readProcessStdout

Fixes bugs regarding a translation from the original autconf program
that failed to account for the exit code.

The longer name reenforces that we really only care about the stdout,
and the exit code and stderr of the program are irrelevant for the case.

Fixes

Re-introduce ld-override option

ghc-toolchain library and usage in hadrian flags

Re-introduce flags in hadrian config

ghc-toolchain: UseLibFFI, LdCompactUnwind, LdFileList

A more complete ghc-toolchain.
Added configuration of:

* Use libffi for adjustors
* Supports compact unwind
* Supports filelist

Handle passing CPP cmd and flags from configure to ghc-toolchain

Rip more of configure that is no longer being used

Remove configure checks of GNUnoexecStack and ident directive

And fix bug in ghc-toolchain respective code

Rip out more from hadrians system.config.in

Configure CLink supports response files

Read deleted keys from host and target's target

Delete CMD_OPTS_STAGEX

Instead of having configure configure different options for different
programs depend on the stage, we delete this completely and have hadrian
select the correct target toolchain configuration file depending on the
stage, from which it can read those options.

Fix [host|target]-[os|arch] vs [host|target]-haskell-[os|arch]

Handle unspecified vs specified flags and commands better

Configure Cpp and HsCpp separately

Fixes for compilation

Link is GNU linkerg

Revert "Rip more of configure that is no longer being used"

I realized we still need this function in rts/configure.ac

This reverts commit 01f5d4b4.

Revert get_arm_isa deletion from 74f03f24

As in the previous commit, we still need this info from the rts
configure script.

I suppose it could be useful for the rts to also read somehow the
toolchain information...

helper AC function for enable/disable

Delete unused imports of SysTools.Info

Drop PROG_CPP in distrib/autoconf too

Get rid of MonadCatch instances and dependencies

ghc-toolchain: Check Cc supports extra-via-c-flags

Consider empty programs as non-specified programs

Cpp and HsCpp cleanup

Add comment from check for gold t22266

Remove more settings bits from hadrian/cfg

Use llvm target from ghc-toolchain

Print default.target

Fix bugs in MergeTool and Ar

Add check and log errors on error

X

Revert LLVMTarget deletion in mkprojectmkin

Fix stack job

Fixes for ghc-toolchain to match configure output

ghc-toolchain: Fix ar supports at file

Fixes

ghc-toolchain: Fix check for gold bug

ghc-toolchain: configure linker options correctly

Support more targets and dont use llvmtarget

allow duplos in place of triples

A TODO comment

ghc-toolchain: set CC LD plat. dependent flags

A lot to be said about the approach of configuring linker flags (what
used to be SET CC LD platform dependent flags in configure), we might
want to re-do this all eventually...
Perhaps I ought to add a TODO at the top level of these functions?

We might also not do it altogether, some of these might be outdated?

Move osElfTarget from GHC.Platform to GHC.Platform.ArchOS, to use it in
Toolchain.Tools.Link to correctly determine if -Wl,--no-as-needed is required

Windows bundled toolchain, output path, etc

Add windows bundled toolchain specific flags

refactor on hadrian handling of toolchains

Fixes to hadrian and ghc-toolchain

Create ghc_toolchain.m4

Don't pass options to ghc-toolchain, it should arrive at the same conclusion as configure for now

Don't crash on ghc-toolchain failure

Mingw bundled toolchain

leftovers

Delete a part

Use ghc-platform instead of ghc-boot

configure: Create and validate toolchain target file

Interpolate LeadingUnderscore in distrib/configure.ac.in

Rename target files to hadrian/cfg (not on bindist)

Add Note [How we configure the bundled windows toolchain]

Add Note [ghc-toolchain consistency checking]

Fix hadrian 99974tooldir substituttion

- - - - -
ddc899b3 by Rodrigo Mesquita at 2023-07-17T17:56:36+01:00
Add flag to enable/disable ghc-toolchain based configurations

This flag is disabled by default, and we'll use the
configure-generated-toolchains by default until we remove the toolchain
configuration logic from configure.

- - - - -


30 changed files:

- + TODO
- compiler/GHC/Linker/Static.hs
- compiler/GHC/Platform.hs
- configure.ac
- distrib/configure.ac.in
- hadrian/.gitignore
- hadrian/bindist/Makefile
- hadrian/bindist/config.mk.in
- hadrian/cabal.project
- + hadrian/cfg/default.host.target.in
- + hadrian/cfg/default.target.in
- hadrian/cfg/system.config.in
- hadrian/hadrian.cabal
- hadrian/src/Base.hs
- hadrian/src/Builder.hs
- hadrian/src/Context.hs
- hadrian/src/Flavour.hs
- hadrian/src/Hadrian/Haskell/Hash.hs
- hadrian/src/Hadrian/Oracles/TextFile.hs
- hadrian/src/Oracles/Flag.hs
- hadrian/src/Oracles/Setting.hs
- hadrian/src/Rules/BinaryDist.hs
- hadrian/src/Rules/Generate.hs
- hadrian/src/Rules/Gmp.hs
- hadrian/src/Rules/Libffi.hs
- hadrian/src/Rules/Lint.hs
- hadrian/src/Rules/Test.hs
- hadrian/src/Settings.hs
- hadrian/src/Settings/Builders/Cabal.hs
- hadrian/src/Settings/Builders/Cc.hs


The diff was not included because it is too large.


View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/78de5dae63c77ef4c317e4b47beab12527908a7a...ddc899b34cd534f3e3af9e94f2fbbbf53c89aa4b

-- 
View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/78de5dae63c77ef4c317e4b47beab12527908a7a...ddc899b34cd534f3e3af9e94f2fbbbf53c89aa4b
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/20230717/cd201105/attachment.html>


More information about the ghc-commits mailing list