Skip to content

Commit

Permalink
Merge pull request #1133 from commercialhaskell/1041-precompile-setup-hs
Browse files Browse the repository at this point in the history
Compile custom Setup.hs instead of interpreting them (fixes #1041)
  • Loading branch information
snoyberg committed Oct 10, 2015
2 parents fb802cc + 747cd0f commit e33975f
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 10 deletions.
1 change: 1 addition & 0 deletions ChangeLog.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ Other enhancements:
* Docker: download or override location of stack executable to re-run in container [#974](https://github.com/commercialhaskell/stack/issues/974)
* Docker: when Docker Engine is remote, don't run containerized processes as host's UID/GID [#194](https://github.com/commercialhaskell/stack/issues/194)
* Docker: `set-user` option to enable/disable running containerized processes as host's UID/GID [#194](https://github.com/commercialhaskell/stack/issues/194)
* Custom Setup.hs files are now precompiled instead of interpreted. This should be a major performance win for certain edge cases (biggest example: [building Cabal itself](https://github.com/commercialhaskell/stack/issues/1041)) while being either neutral or a minor slowdown for more common cases.

Bug fixes:

Expand Down
21 changes: 11 additions & 10 deletions src/Stack/Build/Execute.hs
Original file line number Diff line number Diff line change
Expand Up @@ -694,7 +694,7 @@ withSingleContext runInBase ActionContext {..} ExecuteEnv {..} task@Task {..} md
, esStackExe = False
, esLocaleUtf8 = True
}
getRunhaskellPath <- runOnce $ liftIO $ join $ findExecutable menv "runhaskell"
getGhcPath <- runOnce $ liftIO $ join $ findExecutable menv "ghc"
getGhcjsPath <- runOnce $ liftIO $ join $ findExecutable menv "ghcjs"
distRelativeDir' <- distRelativeDir
esetupexehs <-
Expand Down Expand Up @@ -808,26 +808,27 @@ withSingleContext runInBase ActionContext {..} ExecuteEnv {..} task@Task {..} md
wc <- getWhichCompiler
(exeName, fullArgs) <- case (esetupexehs, wc) of
(Left setupExe, _) -> return (setupExe, setupArgs)
(Right setuphs, Ghc) -> do
exeName <- getRunhaskellPath
let fullArgs = packageArgs ++ (toFilePath setuphs : setupArgs)
return (exeName, fullArgs)
(Right setuphs, Ghcjs) -> do
(Right setuphs, compiler) -> do
distDir <- distDirFromDir pkgDir
let setupDir = distDir </> $(mkRelDir "setup")
outputFile = setupDir </> $(mkRelFile "setup")
createTree setupDir
ghcjsPath <- getGhcjsPath
runExe ghcjsPath $
compilerPath <-
case compiler of
Ghc -> getGhcPath
Ghcjs -> getGhcjsPath
runExe compilerPath $
[ "--make"
, "-odir", toFilePath setupDir
, "-hidir", toFilePath setupDir
, "-i", "-i."
] ++ packageArgs ++
[ toFilePath setuphs
, "-o", toFilePath outputFile
, "-build-runner"
]
] ++
(case compiler of
Ghc -> []
Ghcjs -> ["-build-runner"])
return (outputFile, setupArgs)
runExe exeName $ (if boptsCabalVerbose eeBuildOpts then ("--verbose":) else id) fullArgs

Expand Down

0 comments on commit e33975f

Please sign in to comment.