Support loading dynamic haskell (package) libraries for TH/GHCi with a statically linked exe on Linux
Motivation
For ease of distribution the Haskell language server wants to statically link the exe. Currently this means HLS will use the RTS linker to load haskell packages when encountering TH or evaluating code. This causes many problems for users, some examples here: https://github.com/haskell/haskell-language-server/labels/type%3A%20template%20haskell%20related
Proposal
Allow a user of the GHC api to choose whether to use the RTS loader/linker or the system dynamic loader/linker. Maybe also allow a user of GHC the program to make the same choice.
I've made a proof of concept demonstrating this is possible (https://github.com/haskell/haskell-language-server/issues/2000#issuecomment-962112000), but I'm sure there are problems and the API has to be worked out too.
The approach I've demonstrated requires that you link the GHC api using exe with -export-dynamic
or -Wl,--dynamic-list=...
to make the RTS (and possibly other) symbols visible to the dynamic loader. This necessarily makes this a feature that is quite tricky to use.