Hadrian: support dynamically linking ghc

Authored by DavidEichmann on Oct 29 2018, 10:45 AM.


  • (Trac #15837 point 5) Use the -rpath gcc option and using the $ORIGIN

variable which the dynamic linker sets to the location of the ghc

  • (Trac #15837 point 4) "-fPIC -dynamic" options are used when building ghc when either ghc or the rts have a dynamic way.
  • (Trac #15837 point 7) "-shared -dynload deploy" options are only used when linking a library (no longer when linking a program).

Diff Detail

rGHC Glasgow Haskell Compiler
Automatic diff as part of commit; lint not applicable.
Automatic diff as part of commit; unit tests not applicable.
DavidEichmann created this revision.Oct 29 2018, 10:45 AM

Minor cleanup.

LGTM. It's a little annoying that you have to define makeRelativeNoSysLink and handle all those things in Hadrian itself. Perhaps could we at least throw that function's definition in a dedicated module (or in Utilities or something). And indeed what about Windows?

Note to others: this is all part of a larger plan described at https://ghc.haskell.org/trac/ghc/ticket/15837 and should probably not be merged right away.

adamse added a subscriber: adamse.Nov 7 2018, 4:17 PM
adamse added inline comments.

Should this perhaps be a and b?

DavidEichmann added inline comments.Nov 23 2018, 3:14 AM

Absolutely, this needs to be fixed.

Build ghc with -fPIC -dynamic if RTS has a dynamic way.
Don't link executables with -shared -dynload deploy.
These changes are all in hadrian/src/Settings/Builders/Ghc.hs

Also refactor makeRelativeNoSysLink

alpmestan accepted this revision.Nov 29 2018, 6:34 AM

Looks great!


I think we just don't support dlls on Windows at the moment?

Dynamic ways are all guarded against platformSupportsSharedLibs, which excludes mingw: https://git.haskell.org/ghc.git/blob/1235ca956c80d7035e1a6c50501a97de66d32b92:/hadrian/src/Oracles/Flag.hs#l48

Regarding OS X, it would be great to find someone to test this for us.

This revision is now accepted and ready to land.Nov 29 2018, 6:34 AM
DavidEichmann retitled this revision from Dynamically linked ghc uses relative path to shared objects. to [Merge after D5385] Hadrian: support dynamically linking ghc.Nov 29 2018, 6:47 AM
DavidEichmann edited the summary of this revision. (Show Details)
DavidEichmann retitled this revision from [Merge after D5385] Hadrian: support dynamically linking ghc to Hadrian: support dynamically linking ghc.Nov 29 2018, 10:20 AM
This revision was automatically updated to reflect the committed changes.