Opened 18 months ago

Closed 18 months ago

Last modified 18 months ago

#8734 closed bug (invalid)

7.8.1 rc1 ghci won't load compiled files

Reported by: George Owned by:
Priority: high Milestone: 7.8.1
Component: Documentation Version: 7.8.1-rc1
Keywords: Cc: hvr
Operating System: MacOS X Architecture: Unknown/Multiple
Type of failure: Incorrect result at runtime Test Case:
Blocked By: Blocking:
Related Tickets: Differential Revisions:

Description


Change History (8)

comment:1 Changed 18 months ago by George

Following is script showing that 7.8.1-rc1 ghci won't load compiled files on Mac

 /usr/local/bin/ghc Bug.hs
[1 of 1] Compiling Main             ( Bug.hs, Bug.o )
Linking Bug ...
bash-3.2$ /usr/local/bin/ghci
GHCi, version 7.8.20140130: http://www.haskell.org/ghc/  :? for help
Loading package ghc-prim ... linking ... done.
Loading package integer-gmp ... linking ... done.
Loading package base ... linking ... done.
Prelude> :load bug
[1 of 1] Compiling Main             ( bug.hs, interpreted )
Ok, modules loaded: Main.
*Main> :show modules
Main             ( bug.hs, interpreted )
*Main> 

but it did load .o files on 7.6.3:

 /usr/bin/ghc Bug.hs
[1 of 1] Compiling Main             ( Bug.hs, Bug.o )
Linking Bug ...
bash-3.2$ /usr/bin/ghci
GHCi, version 7.6.3: http://www.haskell.org/ghc/  :? for help
Loading package ghc-prim ... linking ... done.
Loading package integer-gmp ... linking ... done.
Loading package base ... linking ... done.
Prelude> :load Bug
Ok, modules loaded: Main.
Prelude Main> :show modules
Main             ( Bug.hs, Bug.o )

comment:2 Changed 18 months ago by hvr

...that's actually by design, as 7.8.1 switched to using the system linker in combination with DSOs

comment:3 Changed 18 months ago by thoughtpolice

  • Resolution set to invalid
  • Status changed from new to closed

Herbert is correct. This is by design - GHCi now loads dynamic object files, not static object files. But GHC itself still defaults to static linking.

However, there is still a bug here: GHCi doesn't handle .dyn_o correctly. I've filed #8736 for that.

Thanks for the report.

Last edited 18 months ago by thoughtpolice (previous) (diff)

comment:4 Changed 18 months ago by George

  • Component changed from GHCi to Documentation

Then perhaps this is a doc bug? The GHC users guide. Ch.2, sec 3 on loading compiled code (../ghc-7.8.20140130/docs/users_guide/users_guide/ghci-compiled.html) has: "When loading up source modules with :load, GHCi normally looks for any corresponding compiled object files, and will use one in preference to interpreting the source if possible.

Is there any design doc on the dynamic linking changes that you could point me to? Also some user documentation on how to use dyn_o files in conjunction with ghci?

Thanks for everybody's quick response. I;m hoping there is some documentation that you can point me at to get up too speed. I've probably missed some obvious things. Thanks again.

comment:5 Changed 18 months ago by thoughtpolice

We highlighted it in the release notes ("As a result of this, GHCi (and Template Haskell) must now load dynamic object files...") but it perhaps warrants a bigger mention. I do think the part you quoted should be changed.

The basic idea is pretty simple: GHC now just uses the system dynamic linker to load code. That's all. So it needs dynamically linked object files. GHC normally compiles statically, though (and there are advantages to this.) So now you need to compile "statically and dynamically at the same time."

I'll revise this in the user manual.

comment:6 Changed 18 months ago by George

Thanks, makes sense. Can you confirm my understanding? to load (compiled) object files into ghci users must compile with the -dynamic-too option. Once bug #8736 is fixed, assuming the source file was compiled with that option then :load will load a (dynamic) object file into ghci.

If so then the release note might say:

On Linux, FreeBSD and Mac OS X, GHCi now uses the system dynamic linker by default, instead of its built in (static) object linker. This is more robust cross-platform, and fixes many long-standing bugs (for example: constructors and destructors, weak symbols, etc work correctly, and several edge cases in the RTS are fixed.)

As a result of this, GHCi (and Template Haskell) must now load dynamic object files, not static ones. To get dynamic object files, you must compile with the new compilation flag, -dynamic-too, which causes GHC to emit both static and dynamic object files. GHC itself still defaults to static linking.

Last edited 18 months ago by George (previous) (diff)

comment:7 Changed 18 months ago by George

I understand now that compiling with -dynamic allows object files to be loaded into gchi. It would be good to improve doc. Looks like gnu emacs package should be changed to use that. I'll file a bug with them on that

comment:8 Changed 18 months ago by George

gnu emacs haskell package works fine

Note: See TracTickets for help on using tickets.