Skip to content

Commit

Permalink
Allow rules to override -O2 with their own compiler_flags.
Browse files Browse the repository at this point in the history
Currently, `-c opt` will turn on optimization for all Haskell
rules with no way to disable it.  Previously, it was possible
to do so with `compiler_flags = ["-O0"]`, but that behavior was
changed in #342:
https://github.com/tweag/rules_haskell/pull/342/files#diff-33a8c46955e2a9917090b5258346aee2L247

Some Haskell packages take a *lot* of memory and a lot longer to compile with
optimizations.  So it's useful for us to be able to control this tradeoff.
  • Loading branch information
judah committed Jul 26, 2018
1 parent f724288 commit e455e51
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions haskell/private/actions/compile.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -236,6 +236,11 @@ def _compilation_defaults(hs, cc, java, dep_info, srcs, extra_srcs, cpp_defines,

# Default compiler flags.
ghc_args += hs.toolchain.compiler_flags

# Compilation mode. Allow rule-supplied compiler flags to override it.
if hs.mode == "opt":
ghc_args += ["-O2"]

ghc_args += compiler_flags
ghc_args.append("-hide-all-packages")

Expand Down Expand Up @@ -426,10 +431,6 @@ def _compilation_defaults(hs, cc, java, dep_info, srcs, extra_srcs, cpp_defines,
args = hs.actions.args()
args.add(ghc_args)

# Compilation mode and explicit user flags
if hs.mode == "opt":
args.add("-O2")

args.add(["-static"])

# NOTE We can't have profiling and dynamic code at the same time, see:
Expand Down

0 comments on commit e455e51

Please sign in to comment.