David Eichmann pushed to branch wip/27162/hadrian-linkhs-response-file at Glasgow Haskell Compiler / GHC

Commits:

2 changed files:

Changes:

  • hadrian/src/Builder.hs
    ... ... @@ -345,11 +345,8 @@ 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
    +
    
    349
    +                Ghc _ _ -> runGhcWithResponse path buildArgs buildInputs buildOptions
    
    353 350
     
    
    354 351
                     HsCpp    -> captureStdout
    
    355 352
     
    
    ... ... @@ -393,16 +390,18 @@ runHaddock haddockPath flagArgs fileInputs = withTempFile $ \tmp -> do
    393 390
         writeFile' tmp $ escapeArgs fileInputs
    
    394 391
         cmd [haddockPath] flagArgs ('@' : tmp)
    
    395 392
     
    
    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
    -
    
    393
    +-- | Use a response file for ghc invocations to avoid issues with command line
    
    394
    +-- size limit on Windows (#26637).
    
    395
    +runGhcWithResponse :: FilePath -- ^ Path to ghc
    
    396
    +  -> [String] -- ^ Arguments passed on the command line
    
    397
    +  -> [FilePath] -- ^ Input file paths (passed via response file)
    
    398
    +  -> [CmdOption]
    
    399
    +  -> Action ()
    
    400
    +runGhcWithResponse ghcPath buildArgs buildInputs buildOptions = withTempFile $ \tmp -> do
    
    401
    +  let tmpContents = escapeArgs buildInputs
    
    402
    +  putVerbose $ "Build Inputs (" <> tmp <> "): " <> show buildInputs
    
    403
    +  writeFile' tmp tmpContents
    
    404
    +  cmd [ghcPath] buildArgs ('@' : tmp) buildOptions
    
    406 405
     
    
    407 406
     -- TODO: Some builders are required only on certain platforms. For example,
    
    408 407
     -- 'Objdump' is only required on OpenBSD and AIX. Add support for platform
    

  • hadrian/src/Settings/Builders/Ghc.hs
    ... ... @@ -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