[Git][ghc/ghc][wip/fendor/ghci-multiple-home-units] Update "loading compiled code" GHCi documentation

Hannes Siebenhandl pushed to branch wip/fendor/ghci-multiple-home-units at Glasgow Haskell Compiler / GHC Commits: b1feabf0 by fendor at 2025-05-27T17:57:05+02:00 Update "loading compiled code" GHCi documentation To use object code in GHCi, the module needs to be compiled for use in GHCi. To do that, users need to compile their modules with: * `-dynamic` * `-this-unit-id interactive-session` Otherwise, the interface files will not match. - - - - - 1 changed file: - docs/users_guide/ghci.rst Changes: ===================================== docs/users_guide/ghci.rst ===================================== @@ -251,8 +251,8 @@ We can compile ``D``, then load the whole program, like this: .. code-block:: none - ghci> :! ghc -c -dynamic D.hs - ghci> :load A + ghci> :! ghc -c -this-unit-id interactive-session -dynamic D.hs + ghci> :load A B C D Compiling B ( B.hs, interpreted ) Compiling C ( C.hs, interpreted ) Compiling A ( A.hs, interpreted ) @@ -268,6 +268,10 @@ Note the :ghc-flag:`-dynamic` flag to GHC: GHCi uses dynamically-linked object code (if you are on a platform that supports it), and so in order to use compiled code with GHCi it must be compiled for dynamic linking. +Also, note the :ghc-flag:`-this-unit-id ⟨unit-id⟩` `interactive-session` to GHC: GHCi +can only use the object code of a module loaded via :ghci-cmd:`:load`, +if the object code has been compiled for the `interactive-session`. + At any time you can use the command :ghci-cmd:`:show modules` to get a list of the modules currently loaded into GHCi: @@ -301,8 +305,8 @@ So let's try compiling one of the other modules: .. code-block:: none - *ghci> :! ghc -c C.hs - *ghci> :load A + *ghci> :! ghc -c -this-unit-id interactive-session -dynamic C.hs + *ghci> :load A B C D Compiling D ( D.hs, interpreted ) Compiling B ( B.hs, interpreted ) Compiling C ( C.hs, interpreted ) @@ -316,7 +320,7 @@ rejected ``C``\'s object file. Ok, so let's also compile ``D``: .. code-block:: none - *ghci> :! ghc -c D.hs + *ghci> :! ghc -c -this-unit-id interactive-session -dynamic D.hs *ghci> :reload Ok, modules loaded: A, B, C, D. @@ -325,7 +329,7 @@ picked up by :ghci-cmd:`:reload`, only :ghci-cmd:`:load`: .. code-block:: none - *ghci> :load A + *ghci> :load A B C D Compiling B ( B.hs, interpreted ) Compiling A ( A.hs, interpreted ) Ok, modules loaded: A, B, C (C.o), D (D.o). View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/b1feabf08cafcd5b77985e1b57f7b2b0... -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/b1feabf08cafcd5b77985e1b57f7b2b0... You're receiving this email because of your account on gitlab.haskell.org.
participants (1)
-
Hannes Siebenhandl (@fendor)