Skip to content

Commit

Permalink
Replace runghc with ghc -e Main.main
Browse files Browse the repository at this point in the history
Motivation: if you call `runghc`, that process continues to live on
separate from the actual `ghc` process that interprets the code. That's
inefficient. But more worryingly: the `runghc` process itself can cause
major problems in Docker images, since it ends up swallowing SIGINTs as
the PID-1 process. This was discussed quite a bit on Twitter:

https://twitter.com/argumatronic/status/763418990982991872
  • Loading branch information
snoyberg committed Aug 11, 2016
1 parent 4be2916 commit 195bfbf
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/main/Main.hs
Original file line number Diff line number Diff line change
Expand Up @@ -715,7 +715,7 @@ execCmd ExecOpts {..} go@GlobalOpts{..} =
(cmd, args) <- case (eoCmd, eoArgs) of
(ExecCmd cmd, args) -> return (cmd, args)
(ExecGhc, args) -> return ("ghc", args)
(ExecRunGhc, args) -> return ("runghc", args)
(ExecRunGhc, args) -> return ("ghc", "-e" : "Main.main" : args)
(manager,lc) <- liftIO $ loadConfigWithOpts go
withUserFileLock go (configStackRoot $ lcConfig lc) $ \lk -> do
compilerVersion <- loadCompilerVersion manager go lc
Expand All @@ -742,7 +742,7 @@ execCmd ExecOpts {..} go@GlobalOpts{..} =
(ExecGhc, args) -> execCompiler "" args
-- NOTE: this won't currently work for GHCJS, because it doesn't have
-- a runghcjs binary. It probably will someday, though.
(ExecRunGhc, args) -> execCompiler "run" args
(ExecRunGhc, args) -> execCompiler "" ("-e" : "Main.main" : args)
let targets = concatMap words eoPackages
unless (null targets) $
Stack.Build.build (const $ return ()) lk defaultBuildOptsCLI
Expand Down

0 comments on commit 195bfbf

Please sign in to comment.