[Git][ghc/ghc][wip/toolchain-selection] 2 commits: Split ghc-toolchain executable to new packge

Rodrigo Mesquita (@alt-romes) gitlab at gitlab.haskell.org
Wed Jul 19 14:22:16 UTC 2023



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


Commits:
d9f01323 by Rodrigo Mesquita at 2023-07-19T15:15:33+01:00
Split ghc-toolchain executable to new packge

In light of #23690, we split the ghc-toolchain executable out of the
library package to be able to ship it in the bindist using Hadrian.

Ideally, we eventually revert this commit.

- - - - -
10e2f0fe by Rodrigo Mesquita at 2023-07-19T15:19:24+01:00
Ship ghc-toolchain in the bindist

Add the ghc-toolchain binary to the binary distribution we ship to
users, and teach the bindist configure to use the existing ghc-toolchain.

- - - - -


8 changed files:

- configure.ac
- distrib/configure.ac.in
- hadrian/src/Packages.hs
- hadrian/src/Settings/Default.hs
- m4/ghc_toolchain.m4
- utils/ghc-toolchain/Main.hs → utils/ghc-toolchain/exe/Main.hs
- + utils/ghc-toolchain/exe/ghc-toolchain.cabal
- utils/ghc-toolchain/ghc-toolchain.cabal


Changes:

=====================================
configure.ac
=====================================
@@ -1177,7 +1177,7 @@ checkMake380 gmake
 
 # Toolchain target files
 PREP_TARGET_FILE
-FIND_GHC_TOOLCHAIN([hadrian/cfg])
+FIND_GHC_TOOLCHAIN([hadrian/cfg],[NO])
 
 AC_CONFIG_FILES(
 [ mk/project.mk


=====================================
distrib/configure.ac.in
=====================================
@@ -312,7 +312,7 @@ checkMake380 gmake
 
 # Toolchain target files
 PREP_TARGET_FILE
-FIND_GHC_TOOLCHAIN([.])
+FIND_GHC_TOOLCHAIN([.],[YES])
 
 VALIDATE_GHC_TOOLCHAIN([default.target],[default.target.ghc-toolchain])
 


=====================================
hadrian/src/Packages.hs
=====================================
@@ -5,7 +5,8 @@ module Packages (
     checkExact, countDeps,
     compareSizes, compiler, containers, deepseq, deriveConstants, directory, dumpDecls,
     exceptions, filepath, genapply, genprimopcode, ghc, ghcBignum, ghcBoot, ghcBootTh, ghcPlatform,
-    ghcCompact, ghcConfig, ghcHeap, ghci, ghciWrapper, ghcPkg, ghcPrim, haddock, haskeline,
+    ghcCompact, ghcConfig, ghcHeap, ghci, ghciWrapper, ghcPkg, ghcPrim, ghcToolchain,
+    haddock, haskeline,
     hsc2hs, hp2ps, hpc, hpcBin, integerGmp, integerSimple, iserv, iservProxy,
     libffi, mtl, parsec, pretty, primitive, process, remoteIserv, rts,
     runGhc, semaphoreCompat, stm, templateHaskell, terminfo, text, time, timeout, touchy,
@@ -37,7 +38,8 @@ ghcPackages =
     [ array, base, binary, bytestring, cabalSyntax, cabal, checkPpr, checkExact, countDeps
     , compareSizes, compiler, containers, deepseq, deriveConstants, directory, dumpDecls
     , exceptions, filepath, genapply, genprimopcode, ghc, ghcBignum, ghcBoot, ghcBootTh, ghcPlatform
-    , ghcCompact, ghcConfig, ghcHeap, ghci, ghciWrapper, ghcPkg, ghcPrim, haddock, haskeline, hsc2hs
+    , ghcCompact, ghcConfig, ghcHeap, ghci, ghciWrapper, ghcPkg, ghcPrim, ghcToolchain
+    , haddock, haskeline, hsc2hs
     , hp2ps, hpc, hpcBin, integerGmp, integerSimple, iserv, libffi, mtl
     , parsec, pretty, process, rts, runGhc, stm, semaphoreCompat, templateHaskell
     , terminfo, text, time, touchy, transformers, unlit, unix, win32, xhtml
@@ -53,7 +55,8 @@ isGhcPackage = (`elem` ghcPackages)
 array, base, binary, bytestring, cabalSyntax, cabal, checkPpr, checkExact, countDeps,
   compareSizes, compiler, containers, deepseq, deriveConstants, directory, dumpDecls,
   exceptions, filepath, genapply, genprimopcode, ghc, ghcBignum, ghcBoot, ghcBootTh, ghcPlatform,
-  ghcCompact, ghcConfig, ghcHeap, ghci, ghciWrapper, ghcPkg, ghcPrim, haddock, haskeline, hsc2hs,
+  ghcCompact, ghcConfig, ghcHeap, ghci, ghciWrapper, ghcPkg, ghcPrim, ghcToolchain,
+  haddock, haskeline, hsc2hs,
   hp2ps, hpc, hpcBin, integerGmp, integerSimple, iserv, iservProxy, remoteIserv, libffi, mtl,
   parsec, pretty, primitive, process, rts, runGhc, semaphoreCompat, stm, templateHaskell,
   terminfo, text, time, touchy, transformers, unlit, unix, win32, xhtml,
@@ -93,6 +96,7 @@ ghciWrapper         = prg  "ghci-wrapper"    `setPath` "driver/ghci"
                       -- See Note [Hadrian's ghci-wrapper package]
 ghcPkg              = util "ghc-pkg"
 ghcPrim             = lib  "ghc-prim"
+ghcToolchain        = prg  "ghc-toolchain"   `setPath` "utils/ghc-toolchain/exe" -- workaround for #23690
 haddock             = util "haddock"
 haskeline           = lib  "haskeline"
 hsc2hs              = util "hsc2hs"


=====================================
hadrian/src/Settings/Default.hs
=====================================
@@ -146,6 +146,7 @@ stage1Packages = do
         , semaphoreCompat
         , stm
         , unlit
+        , ghcToolchain
         , xhtml
         , if winTarget then win32 else unix
         ]


=====================================
m4/ghc_toolchain.m4
=====================================
@@ -33,21 +33,38 @@ AC_DEFUN([INVOKE_GHC_TOOLCHAIN],
         while read -r arg; do
             set -- "[$]@" "$arg"
         done
-        # For now, we don't exit even if ghc-toolchain fails. We don't want to
+        # For now, we don't 'exit' even if ghc-toolchain fails. We don't want to
         # fail configure due to it, since the target file is still being generated by configure.
-        ./acghc-toolchain -v2 "[$]@" # || exit 1
-        python3 -c 'import sys; print(sys.argv)' "[$]@"
-    ) <acargs || exit 1
+        "$GHC_TOOLCHAIN_BIN" -v2 "[$]@"
+    ) <acargs
 ])
 
 dnl $1 is the path to the directory where to put the configured default.host.target.ghc-toolchain and default.target.ghc-toolchain
+dnl $2 is YES or NO,
+dnl     * YES means we're calling GHC_TOOLCHAIN from the bindist configure script,
+dnl         and that ghc-toolchain is already an available binary
+dnl     * NO means we're calling GHC_TOOLCHAIN from the source tree configure script,
+dnl         and that we must compile ghc-toolchain before invoking it
 AC_DEFUN([FIND_GHC_TOOLCHAIN],
 [
-    "$GHC" -v0 \
-        -ilibraries/ghc-platform/src -iutils/ghc-toolchain/src \
-        -XNoImplicitPrelude \
-        -odir actmp-ghc-toolchain -hidir actmp-ghc-toolchain \
-        utils/ghc-toolchain/Main.hs -o acghc-toolchain
+    case "$2" in
+        YES)
+            # We're configuring the bindist, and the binary is already available
+            GHC_TOOLCHAIN_BIN="bin/ghc-toolchain"
+            ;;
+        NO)
+            # We're in the source tree, so compile ghc-toolchain
+            "$GHC" -v0 \
+                -ilibraries/ghc-platform/src -iutils/ghc-toolchain/src \
+                -XNoImplicitPrelude \
+                -odir actmp-ghc-toolchain -hidir actmp-ghc-toolchain \
+                utils/ghc-toolchain/exe/Main.hs -o acghc-toolchain
+            GHC_TOOLCHAIN_BIN="./acghc-toolchain"
+            ;;
+        *)
+            AC_MSG_ERROR([In m4/ghc_toolchain.m4, expecting $2 to be either YES or NO.])
+            ;;
+    esac
 
     # (1) Configure a toolchain for the build and host platform (we require that BUILD=HOST, so one toolchain suffices)
     rm -f acargs


=====================================
utils/ghc-toolchain/Main.hs → utils/ghc-toolchain/exe/Main.hs
=====================================


=====================================
utils/ghc-toolchain/exe/ghc-toolchain.cabal
=====================================
@@ -0,0 +1,22 @@
+cabal-version:      2.4
+name:               ghc-toolchain
+version:            0.1.0.0
+synopsis:           Utility for managing GHC target toolchains
+description:
+bug-reports:        https://gitlab.haskell.org/ghc/ghc/-/issues
+author:             Ben Gamari
+maintainer:         ben at well-typed.com
+copyright:          (c) The GHC Developers
+
+executable ghc-toolchain
+    main-is:          Main.hs
+    ghc-options:      -Wall
+    default-extensions: NoImplicitPrelude
+    build-depends:    base,
+                      directory,
+                      filepath,
+                      process,
+                      transformers,
+                      ghc-platform,
+                      ghc-toolchain
+    default-language: Haskell2010


=====================================
utils/ghc-toolchain/ghc-toolchain.cabal
=====================================
@@ -40,16 +40,3 @@ library
                       ghc-platform
     hs-source-dirs:   src
     default-language: Haskell2010
-
-executable ghc-toolchain
-    main-is:          Main.hs
-    ghc-options:      -Wall
-    default-extensions: NoImplicitPrelude
-    build-depends:    base,
-                      directory,
-                      filepath,
-                      process,
-                      transformers,
-                      ghc-platform,
-                      ghc-toolchain
-    default-language: Haskell2010



View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/69674fb29e312015d81b4710b18e9b6b7fbdf5e6...10e2f0fe251970d8444e67790714fc0248fbb7cb

-- 
View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/69674fb29e312015d81b4710b18e9b6b7fbdf5e6...10e2f0fe251970d8444e67790714fc0248fbb7cb
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/20230719/df1d06df/attachment-0001.html>


More information about the ghc-commits mailing list