Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Using ghc-paths makes downstream executables non portable #96

Open
jneira opened this issue Nov 12, 2020 · 4 comments
Open

Using ghc-paths makes downstream executables non portable #96

jneira opened this issue Nov 12, 2020 · 4 comments

Comments

@jneira
Copy link
Contributor

jneira commented Nov 12, 2020

  • The solution could be try to get the libdir at runtime and only use ghc-paths as last resort, like it is done in hie-bios:

https://github.com/mpickering/hie-bios/blob/5eede133dbe82d158591a2c8d0361b3d188192ed/src/HIE/Bios/Environment.hs#L66-L81

But is supposes a runtime call to ghc, that in turn could need be called through stack or cabal, maybe too much.

Or take the way of let downstream packages inform the libdir location, or the ghcWrapperas a callback... 🤔

@jneira
Copy link
Contributor Author

jneira commented Nov 16, 2020

As the package is using the libdir only in the public function withDynFlags, remove its use downstream should fix the issue

withDynFlags :: (GHC.DynFlags -> a) -> IO a
withDynFlags action = ghcWrapper $ do
dflags <- GHC.getSessionDynFlags
void $ GHC.setSessionDynFlags dflags
return (action dflags)

@zliu41
Copy link
Collaborator

zliu41 commented Nov 24, 2020

Besides withDynFlags, ghcWrapper is also used in some parse functions like parseModuleApiAnnsWithCpp.

If such functions take an additional libdir parameter, does that solve your problem?

ghc-exactprint doesn't know the path to the ghc executable, so I'm not sure how "a runtime call to ghc" would work.

@jneira
Copy link
Contributor Author

jneira commented Nov 24, 2020

ghc-exactprint doesn't know the path to the ghc executable, so I'm not sure how "a runtime call to ghc" would work.

the direct solution i can think off is pushing the ghc wrapper (better then the libdir location imo) or the data that is extracted using it (dynflags and...) downstream and require client code to provide it, in a new function (or several), falling back to the actual one

EDIT: whoops you were suggesting just that 😄

@jneira
Copy link
Contributor Author

jneira commented Jan 15, 2021

Tbh i think #98 only can be a temporary workaround, as the code using env it is not thread safe anymore (among other considerations).
Not sure if it worths start to work in a better solution for the lib, given it will be included in ghc sooner or later.
@alanz iirc you put a link in irc with a new solution for the ghc wrapper but i cant find it out right now, sorry, maybe we could port that one.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants