Skip to content
GitLab
Projects Groups Snippets
  • /
  • Help
    • Help
    • Support
    • Community forum
    • Submit feedback
  • Sign in / Register
  • GHC GHC
  • Project information
    • Project information
    • Activity
    • Labels
    • Members
  • Repository
    • Repository
    • Files
    • Commits
    • Branches
    • Tags
    • Contributors
    • Graph
    • Compare
    • Locked Files
  • Issues 5,252
    • Issues 5,252
    • List
    • Boards
    • Service Desk
    • Milestones
    • Iterations
  • Merge requests 561
    • Merge requests 561
  • CI/CD
    • CI/CD
    • Pipelines
    • Jobs
    • Schedules
    • Test Cases
  • Deployments
    • Deployments
    • Releases
  • Analytics
    • Analytics
    • Value stream
    • CI/CD
    • Code review
    • Insights
    • Issue
    • Repository
  • Wiki
    • Wiki
  • Snippets
    • Snippets
  • Activity
  • Graph
  • Create a new issue
  • Jobs
  • Commits
  • Issue Boards
Collapse sidebar
  • Glasgow Haskell CompilerGlasgow Haskell Compiler
  • GHCGHC
  • Issues
  • #19994
Closed
Open
Issue created Jun 16, 2021 by Moritz Angermann@angermanDeveloper

Darwin x86_64 fails during tests with out-of-memory

While debugging the odd test failure issues on macOS (x86_64) with @mpickering we came up with the following test-program (against 8.10.5), that illustrates the issue:

module Main where

import Outputable
import GHC.IO
import SysTools.Process

import Data.List ( isInfixOf, isPrefixOf )
import Data.IORef

import System.IO
import System.Process
import System.Environment
import Exception

-- See Note [Run-time linker info].
getCompilerInfo' :: String -> IO String
getCompilerInfo' pgm = do
  let -- Try to grab the info from the process output.
      parseCompilerInfo _stdo stde _exitc
        -- Regular GCC
        | any ("gcc version" `isInfixOf`) stde =
          return "GCC"
        -- Regular clang
        | any ("clang version" `isInfixOf`) stde =
          return "Clang"
        -- FreeBSD clang
        | any ("FreeBSD clang version" `isInfixOf`) stde =
          return "Clang"
        -- Xcode 5.1 clang
        | any ("Apple LLVM version 5.1" `isPrefixOf`) stde =
          return "AppleClang51"
        -- Xcode 5 clang
        | any ("Apple LLVM version" `isPrefixOf`) stde =
          return "AppleClang"
        -- Xcode 4.1 clang
        | any ("Apple clang version" `isPrefixOf`) stde =
          return "AppleClang"
         -- Unknown compiler.
        | otherwise = fail $ "invalid -v output, or compiler is unsupported (" ++ pgm ++ "): " ++ unlines stde

  -- Process the executable call
  catchIO (do
      (exitc, stdo, stde) <- do
          env <- getEnvironment
	  readCreateProcessWithExitCode ((proc pgm ["-v"]) { env = Just env }) ""
      env <- show <$> getEnvironment
      print $ length env
      -- Split the output by lines to make certain kinds
      -- of processing easier.
      parseCompilerInfo (lines stdo) (lines stde) exitc
      )
      (\err -> do
          print $ "Warning:\nCouldn't figure out C compiler information!\nMake sure you're using GNU gcc, or clang\n" ++ show err
          return "UnknownCC"
      )

main = do
  print =<< getCompilerInfo' "clang"
  main

fundamentally the issue appears to be due to the large ENV in a nix shell and readCreateProcessWithExitCode not handling large env strings. Notabley the lengh of the show on env is 29299.

To upload designs, you'll need to enable LFS and have an admin enable hashed storage. More information
Assignee
Assign to
Time tracking