[Git][ghc/ghc][wip/toolchain-selection] 2 commits: hadrian: Allow multiple components per package
Rodrigo Mesquita (@alt-romes)
gitlab at gitlab.haskell.org
Tue Jul 18 18:30:31 UTC 2023
Rodrigo Mesquita pushed to branch wip/toolchain-selection at Glasgow Haskell Compiler / GHC
Commits:
a951af96 by Ben Gamari at 2023-07-18T19:30:21+01:00
hadrian: Allow multiple components per package
Historically hadrian has supported only one component per `Package`.
However, recently both `ghc-toolchain` and `hpc` have run into this
limitation. Here we lift this limitation in a minimal manner, using the
declared `PackageType` to choose between the components provided by the
package.
Fixes #23690.
- - - - -
69674fb2 by Rodrigo Mesquita at 2023-07-18T19:30:21+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.
- - - - -
6 changed files:
- configure.ac
- distrib/configure.ac.in
- hadrian/src/Hadrian/Haskell/Cabal/Parse.hs
- hadrian/src/Packages.hs
- hadrian/src/Settings/Default.hs
- m4/ghc_toolchain.m4
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/Hadrian/Haskell/Cabal/Parse.hs
=====================================
@@ -104,12 +104,15 @@ parsePackageData pkg = do
parseCabalPkgId :: FilePath -> IO String
parseCabalPkgId file = C.display . C.package . C.packageDescription <$> C.readGenericPackageDescription C.silent file
-biModules :: C.PackageDescription -> (C.BuildInfo, [C.ModuleName], Maybe [C.ModuleName], Maybe (C.ModuleName, String))
-biModules pd = go [ comp | comp@(bi,_,_,_) <-
- (map libBiModules . maybeToList $ C.library pd) ++
- (map exeBiModules $ C.executables pd)
- , C.buildable bi ]
+biModules :: Package -> C.PackageDescription -> (C.BuildInfo, [C.ModuleName], Maybe [C.ModuleName], Maybe (C.ModuleName, String))
+biModules pkg pd =
+ go [ comp | comp@(bi,_,_,_) <- candidateComponents
+ , C.buildable bi ]
where
+ candidateComponents
+ | isLibrary pkg = map libBiModules . maybeToList $ C.library pd
+ | otherwise = map exeBiModules $ C.executables pd
+
libBiModules lib = (C.libBuildInfo lib, C.explicitLibModules lib, Just (map C.moduleReexportName (C.reexportedModules lib)), Nothing)
exeBiModules exe = (C.buildInfo exe,
-- If "main-is: ..." is not a .hs or .lhs file, do not
@@ -246,7 +249,8 @@ resolveContextData context at Context {..} = do
-- @library-dirs@ here.
_ -> error "No (or multiple) GHC rts package is registered!"
- (buildInfo, modules, rexport_modules, mainIs) = biModules (C.localPkgDescr lbi')
+ (buildInfo, modules, rexport_modules, mainIs) =
+ biModules package (C.localPkgDescr lbi')
classifyMain :: FilePath -> MainSourceType
classifyMain fp
=====================================
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 = util "ghc-toolchain"
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/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
View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/4b8c05537c789f50182799ee18394c3ba974a621...69674fb29e312015d81b4710b18e9b6b7fbdf5e6
--
View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/4b8c05537c789f50182799ee18394c3ba974a621...69674fb29e312015d81b4710b18e9b6b7fbdf5e6
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/20230718/7957b2bc/attachment-0001.html>
More information about the ghc-commits
mailing list