Skip to content

Commit

Permalink
Allow rules to override -O2 with their own compiler_flags. (#373)
Browse files Browse the repository at this point in the history
* Allow rules to override -O2 with their own compiler_flags.

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 authored and mrkkrp committed Jul 27, 2018
1 parent 7344ddb commit 979de15
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions haskell/private/actions/compile.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -275,12 +275,13 @@ def _compilation_defaults(hs, cc, java, dep_info, srcs, import_dir_map, extra_sr
ghc_args += unit_id_args

args = hs.actions.args()
args.add(ghc_args)

# Compilation mode and explicit user flags
# Compilation mode. Allow rule-supplied compiler flags to override it.
if hs.mode == "opt":
args.add("-O2")

args.add(ghc_args)

args.add(["-static"])

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

0 comments on commit 979de15

Please sign in to comment.