[Git][ghc/ghc][master] hadrian: enable terminfo if --with-curses-* flags are given

Marge Bot pushed to branch master at Glasgow Haskell Compiler / GHC Commits: 2157db2d by sterni at 2025-08-08T15:32:39-04:00 hadrian: enable terminfo if --with-curses-* flags are given The GHC make build system used to support WITH_TERMINFO in ghc.mk which allowed controlling whether to build GHC with terminfo or not. hadrian has replaced this with a system where this is effectively controlled by the cross-compiling setting (the default WITH_TERMINFO value was bassed on CrossCompiling, iirc). This behavior is undesireable in some cases and there is not really a good way to work around it. Especially for downstream packagers, modifying this via UserSettings is not really feasible since such a source file has to be kept in sync with Settings/Default.hs manually since it can't import Settings.Default or any predefined Flavour definitions. To avoid having to add a new setting to cfg/system.config and/or a new configure flag (though I'm happy to implement both if required), I've chosen to take --with-curses-* being set explicitly as an indication that the user wants to have terminfo enabled. This would work for Nixpkgs which sets these flags [1] as well as haskell.nix [2] (which goes to some extreme measures [3] [4] to force terminfo in all scenarios). In general, I'm an advocate for making the GHC build be the same for native and cross insofar it is possible since it makes packaging GHC and Haskell related things while still supporting cross much less compilicated. A more minimal GHC with reduced dependencies should probably be a specific flavor, not the default. Partially addresses #26288 by forcing terminfo to be built if the user explicitly passes configure flags related to it. However, it isn't built by default when cross-compiling yet nor is there an explicit way to control the package being built. [1]: https://github.com/NixOS/nixpkgs/blob/3a7266fcefcb9ce353df49ba3f292d06443760... [2]: https://github.com/input-output-hk/haskell.nix/blob/6eaafcdf04bab7be745d1aa4... [3]: https://github.com/input-output-hk/haskell.nix/blob/6eaafcdf04bab7be745d1aa4... [4]: https://github.com/input-output-hk/haskell.nix/blob/6eaafcdf04bab7be745d1aa4... - - - - - 2 changed files: - hadrian/src/Settings/Default.hs - hadrian/src/Settings/Packages.hs Changes: ===================================== hadrian/src/Settings/Default.hs ===================================== @@ -80,6 +80,7 @@ stageBootPackages = return stage0Packages :: Action [Package] stage0Packages = do cross <- flag CrossCompiling + haveCurses <- any (/= "") <$> traverse setting [ CursesIncludeDir, CursesLibDir ] return $ [ cabalSyntax , cabal , compiler @@ -116,8 +117,8 @@ stage0Packages = do -- that confused Hadrian, so we must make those a stage0 package as well. -- Once we drop `Win32`/`unix` it should be possible to drop those too. ] - ++ [ terminfo | not windowsHost, not cross ] - ++ [ timeout | windowsHost ] + ++ [ terminfo | not windowsHost, (not cross || haveCurses) ] + ++ [ timeout | windowsHost ] -- | Packages built in 'Stage1' by default. You can change this in "UserSettings". stage1Packages :: Action [Package] ===================================== hadrian/src/Settings/Packages.hs ===================================== @@ -24,6 +24,7 @@ packageArgs = do -- immediately and may lead to cyclic dependencies. -- See: https://gitlab.haskell.org/ghc/ghc/issues/16809. cross = flag CrossCompiling + haveCurses = any (/= "") <$> traverse setting [ CursesIncludeDir, CursesLibDir ] -- Check if the bootstrap compiler has the same version as the one we -- are building. This is used to build cross-compilers @@ -85,7 +86,7 @@ packageArgs = do -- backends at the moment, so we might as well disable it -- for cross GHC. [ andM [expr (ghcWithInterpreter stage), notCross] `cabalFlag` "internal-interpreter" - , notM cross `cabalFlag` "terminfo" + , orM [ notM cross, haveCurses ] `cabalFlag` "terminfo" , arg "-build-tool-depends" , flag UseLibzstd `cabalFlag` "with-libzstd" -- ROMES: While the boot compiler is not updated wrt -this-unit-id @@ -120,7 +121,7 @@ packageArgs = do -------------------------------- ghcPkg -------------------------------- , package ghcPkg ? - builder (Cabal Flags) ? notM cross `cabalFlag` "terminfo" + builder (Cabal Flags) ? orM [ notM cross, haveCurses ] `cabalFlag` "terminfo" -------------------------------- ghcBoot ------------------------------ , package ghcBoot ? @@ -202,10 +203,10 @@ packageArgs = do , package haskeline ? builder (Cabal Flags) ? arg "-examples" -- Don't depend upon terminfo when cross-compiling to avoid unnecessary - -- dependencies. - -- TODO: Perhaps the user should rather be responsible for this? + -- dependencies unless the user provided ncurses explicitly. + -- TODO: Perhaps the user should be able to explicitly enable/disable this. , package haskeline ? - builder (Cabal Flags) ? notM cross `cabalFlag` "terminfo" + builder (Cabal Flags) ? orM [ notM cross, haveCurses ] `cabalFlag` "terminfo" -------------------------------- terminfo ------------------------------ , package terminfo ? View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/2157db2d5da391ca77eac156a6787e12... -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/2157db2d5da391ca77eac156a6787e12... You're receiving this email because of your account on gitlab.haskell.org.
participants (1)
-
Marge Bot (@marge-bot)