David Eichmann pushed to branch wip/27162/hadrian-linkhs-response-file at Glasgow Haskell Compiler / GHC
Commits:
-
fbce2c50
by Duncan Coutts at 2026-04-14T13:43:20+01:00
3 changed files:
Changes:
| ... | ... | @@ -345,11 +345,7 @@ instance H.Builder Builder where |
| 345 | 345 | |
| 346 | 346 | Haddock BuildPackage -> runHaddock path buildArgs buildInputs
|
| 347 | 347 | |
| 348 | - Ghc FindHsDependencies _ -> do
|
|
| 349 | - -- Use a response file for ghc -M invocations, to
|
|
| 350 | - -- avoid issues with command line size limit on
|
|
| 351 | - -- Windows (#26637)
|
|
| 352 | - runGhcWithResponse path buildArgs buildInputs
|
|
| 348 | + Ghc _ _ -> runGhcWithResponse path buildArgs buildInputs buildOptions
|
|
| 353 | 349 | |
| 354 | 350 | HsCpp -> captureStdout
|
| 355 | 351 | |
| ... | ... | @@ -393,16 +389,18 @@ runHaddock haddockPath flagArgs fileInputs = withTempFile $ \tmp -> do |
| 393 | 389 | writeFile' tmp $ escapeArgs fileInputs
|
| 394 | 390 | cmd [haddockPath] flagArgs ('@' : tmp)
|
| 395 | 391 | |
| 396 | -runGhcWithResponse :: FilePath -> [String] -> [FilePath] -> Action ()
|
|
| 397 | -runGhcWithResponse ghcPath flagArgs fileInputs = withTempFile $ \tmp -> do
|
|
| 398 | - |
|
| 399 | - writeFile' tmp $ escapeArgs fileInputs
|
|
| 400 | - |
|
| 401 | - -- We can't put the flags in a response file, because some flags
|
|
| 402 | - -- require empty arguments (such as the -dep-suffix flag), but
|
|
| 403 | - -- that isn't supported yet due to #26560.
|
|
| 404 | - cmd [ghcPath] flagArgs ('@' : tmp)
|
|
| 405 | - |
|
| 392 | +-- | Use a response file for ghc invocations to avoid issues with command line
|
|
| 393 | +-- size limit on Windows (#26637).
|
|
| 394 | +runGhcWithResponse :: FilePath -- ^ Path to ghc
|
|
| 395 | + -> [String] -- ^ Arguments passed on the command line
|
|
| 396 | + -> [FilePath] -- ^ Input file paths (passed via response file)
|
|
| 397 | + -> [CmdOption]
|
|
| 398 | + -> Action ()
|
|
| 399 | +runGhcWithResponse ghcPath buildArgs buildInputs buildOptions = withTempFile $ \tmp -> do
|
|
| 400 | + let tmpContents = escapeArgs buildInputs
|
|
| 401 | + putVerbose $ "Build Inputs (" <> tmp <> "): " <> show buildInputs
|
|
| 402 | + writeFile' tmp tmpContents
|
|
| 403 | + cmd [ghcPath] buildArgs ('@' : tmp) buildOptions
|
|
| 406 | 404 | |
| 407 | 405 | -- TODO: Some builders are required only on certain platforms. For example,
|
| 408 | 406 | -- 'Objdump' is only required on OpenBSD and AIX. Add support for platform
|
| ... | ... | @@ -29,7 +29,9 @@ import Hadrian.Utilities |
| 29 | 29 | |
| 30 | 30 | -- | This data structure captures all information relevant to invoking a builder.
|
| 31 | 31 | data BuildInfo = BuildInfo {
|
| 32 | - -- | Command line arguments.
|
|
| 32 | + -- | Command line arguments. Some builders (e.g. Ar, Ghc, Haddock) omit
|
|
| 33 | + -- buildInputs from buildArgs so that buildInputs can be passed separately
|
|
| 34 | + -- using a response file.
|
|
| 33 | 35 | buildArgs :: [String],
|
| 34 | 36 | -- | Input files.
|
| 35 | 37 | buildInputs :: [FilePath],
|
| ... | ... | @@ -62,7 +62,6 @@ compileAndLinkHs = (builder (Ghc CompileHs) ||^ builder (Ghc LinkHs)) ? do |
| 62 | 62 | [ arg "-fwrite-ide-info"
|
| 63 | 63 | , arg "-hiedir", arg hie_path
|
| 64 | 64 | ]
|
| 65 | - , getInputs
|
|
| 66 | 65 | , arg "-o", arg =<< getOutput ]
|
| 67 | 66 | |
| 68 | 67 | compileC :: Args
|
| ... | ... | @@ -78,7 +77,6 @@ compileC = builder (Ghc CompileCWithGhc) ? do |
| 78 | 77 | , mconcat (map (map ("-optc" ++) <$>) ccArgs)
|
| 79 | 78 | , defaultGhcWarningsArgs
|
| 80 | 79 | , arg "-c"
|
| 81 | - , getInputs
|
|
| 82 | 80 | , arg "-o"
|
| 83 | 81 | , arg =<< getOutput ]
|
| 84 | 82 | |
| ... | ... | @@ -95,7 +93,6 @@ compileCxx = builder (Ghc CompileCppWithGhc) ? do |
| 95 | 93 | , mconcat (map (map ("-optcxx" ++) <$>) ccArgs)
|
| 96 | 94 | , defaultGhcWarningsArgs
|
| 97 | 95 | , arg "-c"
|
| 98 | - , getInputs
|
|
| 99 | 96 | , arg "-o"
|
| 100 | 97 | , arg =<< getOutput ]
|
| 101 | 98 |