David Eichmann pushed to branch wip/davide/hadrian_avoid_response_files at Glasgow Haskell Compiler / GHC Commits: 52935fea by David Eichmann at 2026-05-29T17:19:55+01:00 Hadrian: disable response files for GHC/Haddock builders on non-Windows This makes debugging build errors easier on non-windows hosts. See issue #27230 - - - - - 2 changed files: - hadrian/src/Builder.hs - hadrian/src/Hadrian/Utilities.hs Changes: ===================================== hadrian/src/Builder.hs ===================================== @@ -346,7 +346,16 @@ instance H.Builder Builder where Haddock BuildPackage -> runHaddock path buildArgs buildInputs - Ghc _ _ -> runGhcWithResponse path buildArgs buildInputs buildOptions + Ghc _ _ -> + -- Use a response file for ghc invocations to avoid issues with command line + -- size limit on Windows (#26637). + -- Note we can't put the buildArgs in a response file, because some flags require + -- empty arguments (such as the -dep-suffix flag), but that isn't supported + -- yet due to #26560. + withResponseFileOnWindows + buildInputs + (escapeArgs buildInputs) + (\buildInputs' -> cmd [path] buildArgs buildInputs' buildOptions) HsCpp -> captureStdout @@ -386,23 +395,10 @@ runHaddock :: FilePath -- ^ path to @haddock@ -> [String] -> [FilePath] -- ^ input file paths -> Action () -runHaddock haddockPath flagArgs fileInputs = withResponseFile $ \tmp -> do - writeFile' tmp $ escapeArgs fileInputs - cmd [haddockPath] flagArgs ('@' : tmp) - --- | Use a response file for ghc invocations to avoid issues with command line --- size limit on Windows (#26637). -runGhcWithResponse :: FilePath -- ^ Path to ghc - -> [String] -- ^ Arguments passed on the command line - -> [FilePath] -- ^ Input file paths (passed via response file) - -> [CmdOption] - -> Action () -runGhcWithResponse ghcPath buildArgs buildInputs buildOptions = withResponseFile $ \tmp -> do - -- We can't put the buildArgs in a response file, because some flags require - -- empty arguments (such as the -dep-suffix flag), but that isn't supported - -- yet due to #26560. - writeFile' tmp (escapeArgs buildInputs) - cmd [ghcPath] buildArgs ('@' : tmp) buildOptions +runHaddock haddockPath flagArgs fileInputs = withResponseFileOnWindows + fileInputs + (escapeArgs fileInputs) + (\fileInputs' -> cmd [haddockPath] flagArgs fileInputs') -- TODO: Some builders are required only on certain platforms. For example, -- 'Objdump' is only required on OpenBSD and AIX. Add support for platform ===================================== hadrian/src/Hadrian/Utilities.hs ===================================== @@ -14,7 +14,7 @@ module Hadrian.Utilities ( -- * Paths BuildRoot (..), buildRoot, buildRootRules, isGeneratedSource, - KeepResponseFiles (..), keepResponseFiles, withResponseFile, + KeepResponseFiles (..), keepResponseFiles, withResponseFile, withResponseFileOnWindows, -- * File system operations copyFile, copyFileUntracked, createFileLink, fixFile, @@ -49,7 +49,9 @@ import Development.Shake hiding (Normal) import Development.Shake.Classes import Development.Shake.FilePath import System.Environment (lookupEnv) +import System.Info.Extra (isWindows) import System.IO (hClose, openTempFile) +import System.IO.Error (isPermissionError) import qualified Data.ByteString as BS import qualified Control.Exception.Base as IO @@ -57,8 +59,7 @@ import qualified Data.HashMap.Strict as Map import qualified System.Directory.Extra as IO import qualified System.Info.Extra as IO import qualified System.IO as IO -import System.IO.Error (isPermissionError) -import qualified System.FilePath.Posix as Posix +import qualified System.FilePath.Posix as Posix -- | Extract a value from a singleton list, or terminate with an error message -- if the list does not contain exactly one value. @@ -328,6 +329,23 @@ keepResponseFiles = do KeepResponseFiles keep <- userSetting (KeepResponseFiles False) return keep +-- | Run an action either with command arguments direcly or by, on windows, +-- placing those arguments into a response file (initialized to some string). +-- +-- With @--keep-response-files@, the file is left on disk (if used) +withResponseFileOnWindows :: + [String] -- ^ Command arguments + -> String -- ^ Response file content (the command arguments converted to the response file format). + -> ([String] -> Action a) -- ^ Perform an action with the given command arguments or, on windows, the with the + -- response file initialized and the passed argument is in the form ["@reponseFilePath"] + -> Action a +withResponseFileOnWindows commandArgs responseFileContent action = do + if isWindows + then withResponseFile $ \tmp -> do + writeFile' tmp responseFileContent + action ['@' : tmp] + else action commandArgs + -- | Run an action with a response file path. -- -- With @--keep-response-files@, the file is left on disk. View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/52935feab3cdf20cc7c98f6214c38b4e... -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/52935feab3cdf20cc7c98f6214c38b4e... You're receiving this email because of your account on gitlab.haskell.org.
participants (1)
-
David Eichmann (@DavidEichmann)