summaryrefslogtreecommitdiff
path: root/compiler/main/DynFlags.hs
diff options
context:
space:
mode:
authorRyan Scott <ryan.gl.scott@gmail.com>2019-08-08 13:26:13 -0400
committerMarge Bot <ben+marge-bot@smart-cactus.org>2019-09-26 14:04:38 -0400
commit4f81fab062e521b6b59f3f7b93bc410fd1111166 (patch)
tree41d55a2c4c9a4ba9e3e19d8168138228e4e31c4c /compiler/main/DynFlags.hs
parent0b5eede97804ec3dfbfa9df9f97bcfe2aa369f6b (diff)
downloadhaskell-4f81fab062e521b6b59f3f7b93bc410fd1111166.tar.gz
Make -fbyte-code prevent unboxed tuples/sums from implying object code (#16876)
This resolves #16876 by making the explicit use of `-fbyte-code` prevent code that enables `UnboxedTuples` or `UnboxedSums` from automatically compiling to object code. This allows for a nice middle ground where most code that enables `UnboxedTuples`/-`Sums` will still benefit from automatically enabling `-fobject-code`, but allows power users who wish to avoid this behavior in certain corner cases (such as `lens`, whose use case is documented in #16876) to do so. Along the way, I did a little cleanup of the relevant code and documentation: * `enableCodeGenForUnboxedTuples` was only checking for the presence of `UnboxedTuples`, but `UnboxedSums` has the same complications. I fixed this and renamed the function to `enableCodeGenForUnboxedTuplesOrSums`. * I amended the users' guide with a discussion of these issues.
Diffstat (limited to 'compiler/main/DynFlags.hs')
-rw-r--r--compiler/main/DynFlags.hs6
1 files changed, 5 insertions, 1 deletions
diff --git a/compiler/main/DynFlags.hs b/compiler/main/DynFlags.hs
index 07b266d24b..429857ad62 100644
--- a/compiler/main/DynFlags.hs
+++ b/compiler/main/DynFlags.hs
@@ -654,6 +654,7 @@ data GeneralFlag
| Opt_SingleLibFolder
| Opt_KeepCAFs
| Opt_KeepGoing
+ | Opt_ByteCode
-- output style opts
| Opt_ErrorSpans -- Include full span info in error messages,
@@ -3744,7 +3745,10 @@ dynamic_flags_deps = [
, make_ord_flag defFlag "fno-code" (NoArg ((upd $ \d ->
d { ghcLink=NoLink }) >> setTarget HscNothing))
- , make_ord_flag defFlag "fbyte-code" (NoArg (setTarget HscInterpreted))
+ , make_ord_flag defFlag "fbyte-code"
+ (noArgM $ \dflags -> do
+ setTarget HscInterpreted
+ pure $ gopt_set dflags Opt_ByteCode)
, make_ord_flag defFlag "fobject-code" $ NoArg $ do
dflags <- liftEwM getCmdLineState
setTarget $ defaultObjectTarget dflags