<div dir="ltr"><div>I'm not sure how you could make DYNAMIC_GHC_PROGRAMS into a runtime flag, since it controls whether GHC itself (and the other tools) are built as dynamic executables. If GHC is a dynamic executable, then it can only load -fPIC code to link at runtime.<br></div><div><br></div><div>Cheers</div><div>Simon<br></div></div><div class="gmail_extra"><br><div class="gmail_quote">On 13 June 2018 at 02:30, Moritz Angermann <span dir="ltr"><<a href="mailto:moritz.angermann@gmail.com" target="_blank">moritz.angermann@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="auto">Thank you both for the replies.<div><br></div><div>My issue with the current situation is that I can navigate myself into a situation where I’m stuck. By asking ghc to build static libraries, it will later fall over when it tries to load those.</div><div><br></div><div>Guess what I really want is to turn the DYNAMIC_GHC_PROGRAMS into a runtime flag.</div><div><br></div><div>That might help with getting out of the situation without resorting to building two ghcs.</div><div><br></div><div>Cheers,</div><div> Moritz<br><br><div id="m_176608120128956485AppleMailSignature">Sent from my iPhone</div><div><div class="h5"><div><br>On 12 Jun 2018, at 9:07 PM, Phyx <<a href="mailto:lonetiger@gmail.com" target="_blank">lonetiger@gmail.com</a>> wrote:<br><br></div><blockquote type="cite"><div>You could work around the dlopen issue as long as the static library is compiled with -fPIC by using  --whole-archive (assuming you permit dangling references which will need to be resolved later) and making a shared library out of the static code. But you'd have to create one shared library per static library and preserve the order so you don't end up with symbol collisions. <div><br></div><div>And you'd likely not want to do it this on every relink. But i think the - fPIC is a much greater hurdle. Very few of the static libraries a user may want to use would have this likely.</div><div><br></div><div>I think it'll end up being quite a messy situation.. </div><div><div dir="auto"><br></div><div dir="auto"><br><div class="gmail_quote"><div dir="ltr">On Thu, Jun 7, 2018, 22:01 Simon Marlow <<a href="mailto:marlowsd@gmail.com" target="_blank">marlowsd@gmail.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"><div>There's a technical restriction. The static code would be compiled with the small memory model, so it would have 32-bit relocations for external references, assuming that those references would resolve to something in the low 2GB of the address space. But we would be trying to link it against shared libraries which could be loaded anywhere in the address space.</div><div><br></div><div>If the static code was compiled with -fPIC then it might be possible, but there's also the restriction that we wouldn't be able to dlopen() a shared library that depends on the statically linked code, because the system linker can't see the symbols that the RTS linker has loaded. GHC doesn't currently know about this restriction, so it would probably go ahead and try, and things would break.</div><div><br></div><div>Cheers</div></div><div dir="ltr"><div>Simon<br></div><div><div><br></div></div></div><div class="gmail_extra"><br><div class="gmail_quote">On 29 May 2018 at 04:05, Moritz Angermann <span dir="ltr"><<a href="mailto:moritz@lichtzwerge.de" target="_blank">moritz@lichtzwerge.de</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Dear friends,<br>
<br>
when we build GHC with DYNAMIC_GHC_PROGRAMS=YES, we essentially prevent ghc/ghci<br>
from using archives (.a).  Is there a technical reason behind this?  The only<br>
only reasoning so far I've came across was: insist on using dynamic/shared objects,<br>
because the user said so when building GHC.<br>
<br>
In that case, we don't however prevent GHC from building archive (static) only<br>
libraries.  And as a consequence when we later try to build another archive of<br>
a different library, that depends via TH on the former library, GHC will bail<br>
and complain that we don't have the relevant dynamic/shared object.  Of course we<br>
don't we explicitly didn't build it.  But the linker code we have in GHC is<br>
perfectly capable of loading archives.  So why don't we want to fall back to<br>
archives?<br>
<br>
Similarly, as @deech asked on twitter[1], why we prevent GHCi from loading static<br>
libraries?<br>
<br>
I'd like to understand the technical reason/rational for this behavior.  Can<br>
someone help me out here?  If there is no fundamental reason for this behavior, <br>
I'd like to go ahead and try to lift it.<br>
<br>
Thank you!<br>
<br>
Cheers,<br>
 Moritz<br>
<br>
---<br>
[1]: <a href="https://twitter.com/deech/status/1001182709555908608" rel="noreferrer" target="_blank">https://twitter.com/deech/<wbr>status/1001182709555908608</a><br>
______________________________<wbr>_________________<br>
ghc-devs mailing list<br>
<a href="mailto:ghc-devs@haskell.org" target="_blank">ghc-devs@haskell.org</a><br>
<a href="http://mail.haskell.org/cgi-bin/mailman/listinfo/ghc-devs" rel="noreferrer" target="_blank">http://mail.haskell.org/cgi-<wbr>bin/mailman/listinfo/ghc-devs</a><br>
</blockquote></div><br></div>
______________________________<wbr>_________________<br>
ghc-devs mailing list<br>
<a href="mailto:ghc-devs@haskell.org" target="_blank">ghc-devs@haskell.org</a><br>
<a href="http://mail.haskell.org/cgi-bin/mailman/listinfo/ghc-devs" rel="noreferrer" target="_blank">http://mail.haskell.org/cgi-<wbr>bin/mailman/listinfo/ghc-devs</a><br>
</blockquote></div></div></div>
</div></blockquote><blockquote type="cite"><div><span>______________________________<wbr>_________________</span><br><span>ghc-devs mailing list</span><br><span><a href="mailto:ghc-devs@haskell.org" target="_blank">ghc-devs@haskell.org</a></span><br><span><a href="http://mail.haskell.org/cgi-bin/mailman/listinfo/ghc-devs" target="_blank">http://mail.haskell.org/cgi-<wbr>bin/mailman/listinfo/ghc-devs</a></span><br></div></blockquote></div></div></div></div></blockquote></div><br></div>