Marge Bot pushed to branch master at Glasgow Haskell Compiler / GHC

Commits:

4 changed files:

Changes:

  • hadrian/src/Builder.hs
    ... ... @@ -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,14 +389,19 @@ runHaddock haddockPath flagArgs fileInputs = withResponseFile $ \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 = withResponseFile $ \tmp -> do
    
    398
    -    writeFile' tmp $ escapeArgs fileInputs
    
    399
    -    -- We can't put the flags in a response file, because some flags
    
    400
    -    -- require empty arguments (such as the -dep-suffix flag), but
    
    401
    -    -- that isn't supported yet due to #26560.
    
    402
    -    cmd [ghcPath] flagArgs ('@' : tmp)
    
    403
    -
    
    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 = withResponseFile $ \tmp -> do
    
    400
    +  -- We can't put the buildArgs in a response file, because some flags require
    
    401
    +  -- empty arguments (such as the -dep-suffix flag), but that isn't supported
    
    402
    +  -- yet due to #26560.
    
    403
    +  writeFile' tmp (escapeArgs buildInputs)
    
    404
    +  cmd [ghcPath] buildArgs ('@' : tmp) buildOptions
    
    404 405
     
    
    405 406
     -- TODO: Some builders are required only on certain platforms. For example,
    
    406 407
     -- 'Objdump' is only required on OpenBSD and AIX. Add support for platform
    

  • hadrian/src/Hadrian/Builder.hs
    ... ... @@ -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],
    

  • hadrian/src/Hadrian/Utilities.hs
    ... ... @@ -334,13 +334,23 @@ keepResponseFiles = do
    334 334
     withResponseFile :: (FilePath -> Action a) -> Action a
    
    335 335
     withResponseFile action = do
    
    336 336
         keep <- keepResponseFiles
    
    337
    +    let putVerboseResponseFile tmp = do
    
    338
    +            verbosity <- getVerbosity
    
    339
    +            when (verbosity >= Verbose) $ do
    
    340
    +                tmpContent <- liftIO (readFile tmp)
    
    341
    +                putVerbose (tmp <> " (use hadrian flag --keep-response-files to keep this file):\n" <> tmpContent)
    
    337 342
         if keep
    
    338 343
             then do
    
    339 344
                 (tmp, h) <- liftIO $ openTempFile "." "hadrian-rsp"
    
    340 345
                 liftIO $ hClose h
    
    341 346
                 putInfo $ "Keeping response file: " ++ tmp
    
    342
    -            action tmp
    
    343
    -        else withTempFile action
    
    347
    +            result <- action tmp
    
    348
    +            putVerboseResponseFile tmp
    
    349
    +            return result
    
    350
    +        else withTempFile $ \tmp -> do
    
    351
    +            result <- action tmp
    
    352
    +            putVerboseResponseFile tmp
    
    353
    +            return result
    
    344 354
     
    
    345 355
     -- | Link a file tracking the link target. Create the target directory if
    
    346 356
     -- missing.
    

  • 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