From 8da7f047ad667730694a95fe37926ea1ea3fa099 Mon Sep 17 00:00:00 2001 From: Michael Snoyman Date: Mon, 25 Mar 2019 10:58:57 +0200 Subject: [PATCH] Apply GHC options when building Setup.hs (fixes #4526) --- ChangeLog.md | 2 ++ src/Stack/Build/Execute.hs | 12 +++++++++++- 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/ChangeLog.md b/ChangeLog.md index a5f6b1b356..951dd03972 100644 --- a/ChangeLog.md +++ b/ChangeLog.md @@ -166,6 +166,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 eefc5e9b6e..9b91f6fa0e 100644 --- a/src/Stack/Build/Execute.hs +++ b/src/Stack/Build/Execute.hs @@ -1245,7 +1245,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