diff options
author | Ryan Scott <ryan.gl.scott@gmail.com> | 2019-08-08 13:26:13 -0400 |
---|---|---|
committer | Marge Bot <ben+marge-bot@smart-cactus.org> | 2019-09-26 14:04:38 -0400 |
commit | 4f81fab062e521b6b59f3f7b93bc410fd1111166 (patch) | |
tree | 41d55a2c4c9a4ba9e3e19d8168138228e4e31c4c /docs/users_guide/ghci.rst | |
parent | 0b5eede97804ec3dfbfa9df9f97bcfe2aa369f6b (diff) | |
download | haskell-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 'docs/users_guide/ghci.rst')
-rw-r--r-- | docs/users_guide/ghci.rst | 25 |
1 files changed, 20 insertions, 5 deletions
diff --git a/docs/users_guide/ghci.rst b/docs/users_guide/ghci.rst index 9138f1d774..10a9358a6f 100644 --- a/docs/users_guide/ghci.rst +++ b/docs/users_guide/ghci.rst @@ -3429,14 +3429,29 @@ The interpreter can't load modules with foreign export declarations! need to go fast, rather than interpreting them with optimisation turned on. -Modules using unboxed tuples will automatically enable `-fobject-code` - The interpreter doesn't support unboxed tuples, so GHCi will - automatically compile these modules, and all modules they depend - on, to object code instead of bytecode. +Modules using unboxed tuples or sums will automatically enable :ghc-flag:`-fobject-code` + + .. index:: + single: unboxed tuples, sums; and GHCi + + The bytecode interpreter doesn't support most uses of unboxed tuples or + sums, so GHCi will automatically compile these modules, and all modules + they depend on, to object code instead of bytecode. + + GHCi checks for the presence of unboxed tuples and sums in a somewhat + conservative fashion: it simply checks to see if a module enables the + :extension:`UnboxedTuples` or :extension:`UnboxedSums` language extensions. + It is not always the case that code which enables :extension:`UnboxedTuples` + or :extension:`UnboxedSums` requires :ghc-flag:`-fobject-code`, so if you + *really* want to compile + :extension:`UnboxedTuples`/:extension:`UnboxedSums`-using code to + bytecode, you can do so explicitly by enabling the :ghc-flag:`-fbyte-code` + flag. If you do this, do note that bytecode interpreter will throw an error + if it encounters unboxed tuple/sum–related code that it cannot handle. Incidentally, the previous point, that :ghc-flag:`-O` is incompatible with GHCi, is because the bytecode compiler can't - deal with unboxed tuples. + deal with unboxed tuples or sums. Concurrent threads don't carry on running when GHCi is waiting for input. This should work, as long as your GHCi was built with the |