Re: Can I get the internal name of a package at runtime?

2017-10-15 Thread MarLinn
Hi Daniel, that looks very interesting. I think it'll take some time to understand what's going on, but I already got some good parts. And even if I won't end up using it, this seems like a good way to learn some stuff. So thanks a lot! For now I don't need the full power, so I think I'll

Re: Can I get the internal name of a package at runtime?

2017-10-14 Thread Daniel Gröber
Hi, I think you might be interrested in my rts-loader package, particularly the [mkSymbol function](https://github.com/DanielG/rts-loader/blob/master/System/Loader/RTS.hs#L275). It should demonstrate how you can construct the symbol names for dynamic loading and how to coax the information

Re: Can I get the internal name of a package at runtime?

2017-10-14 Thread Brandon Allbery
Oh, wait, that won;t work because you're trying to find the name of something to load at runtime. But you can still z-encode the known parts of the name and look for files starting and ending with those components; the ABI hash won't matter because a dynamically loaded plugin can't use the

Re: Can I get the internal name of a package at runtime?

2017-10-14 Thread Brandon Allbery
On Sat, Oct 14, 2017 at 3:59 PM, MarLinn wrote: > That sounds reasonable, but also like there *can not be* a way to obtain > that hash at runtime. And therefore, no way to discover the true package > name. > I can think of a hacky way: make sure the symbol table is still

Re: Can I get the internal name of a package at runtime?

2017-10-14 Thread MarLinn
That sounds reasonable, but also like there *can not be* a way to obtain that hash at runtime. And therefore, no way to discover the true package name. Which in turn makes discovery and loading of plug-ins a bit harder. Well, I guess it's for a good reason so I'll have to work around it.

Re: Can I get the internal name of a package at runtime?

2017-10-14 Thread Brandon Allbery
On Sat, Oct 14, 2017 at 12:48 PM, MarLinn wrote: > So the "actual" package name seems to be "Plugin-0.0.0.0-2QaFQQzYhnKJSP > RXA7VtPe". > That leaves the random(?) characters behind the version number to be > explained. > ABI hash of that specific package build, which is

Re: Can I get the internal name of a package at runtime?

2017-10-14 Thread MarLinn
Hi Edward, thank you. That knowledge revealed that the "Ozi" part was actually the version number. So the "actual" package name seems to be "Plugin-0.0.0.0-2QaFQQzYhnKJSPRXA7VtPe". That leaves the random(?) characters behind the version number to be explained. But at least now I can exploit

Re: Can I get the internal name of a package at runtime?

2017-10-14 Thread Edward Z. Yang
Hi MarLinn, The mangling name is "z-encoded". It is documented here: https://ghc.haskell.org/trac/ghc/wiki/Commentary/Compiler/SymbolNames Edward Excerpts from MarLinn's message of 2017-10-14 17:35:28 +0200: > Hi. > > I'm experimenting with plug-ins right now. I did manage to dynamically >

Can I get the internal name of a package at runtime?

2017-10-14 Thread MarLinn
Hi. I'm experimenting with plug-ins right now. I did manage to dynamically load functions at runtime. The caveat: Something (cabal? ghc?) mangles the package names. For example, to load a function called "theFunction" from a module called "Callee" in a package "Plugin", I had to address it