diff --git a/ChangeLog.md b/ChangeLog.md index 238fa566fd..4c77719c10 100644 --- a/ChangeLog.md +++ b/ChangeLog.md @@ -174,6 +174,8 @@ Bug fixes: See [#4453](https://github.com/commercialhaskell/stack/issues/4453). * Extra include and lib dirs are now order-dependent. See [#4527](https://github.com/commercialhaskell/stack/issues/4527). +* Apply GHC options when building a `Setup.hs` file. See + [#4526](https://github.com/commercialhaskell/stack/issues/4526). ## v1.9.3 diff --git a/src/Stack/Build/Execute.hs b/src/Stack/Build/Execute.hs index 9950ab400f..31d72621ea 100644 --- a/src/Stack/Build/Execute.hs +++ b/src/Stack/Build/Execute.hs @@ -1246,7 +1246,17 @@ withSingleContext ActionContext {..} ExecuteEnv {..} task@Task {..} mdeps msuffi ] ++ (case compiler of Ghc -> [] - Ghcjs -> ["-build-runner"]) + Ghcjs -> ["-build-runner"]) ++ + + -- Apply GHC options + -- https://github.com/commercialhaskell/stack/issues/4526 + map T.unpack ( + Map.findWithDefault [] AGOEverything (configGhcOptionsByCat config) ++ + case configApplyGhcOptions config of + AGOEverything -> boptsCLIGhcOptions eeBuildOptsCLI + AGOTargets -> [] + AGOLocals -> []) + liftIO $ atomicModifyIORef' eeCustomBuilt $ \oldCustomBuilt -> (Set.insert (packageName package) oldCustomBuilt, ()) return outputFile