<div dir="ltr">Hi,<div><br></div><div>Normally when you build a cross compiler, you build the GHC sources configured for the target platform. Your GHC.Prim would already expect 32 bit, so the hook is not needed. However if you want to use the ghc library to build a non-standard cross compiler (GHCJS in my case), it may be useful. I added the `ghcPrimIface` hook for this purpose: GHCJS essentially targets a 32 bit platform, and it's a standalone program that uses the existing (already installed) `ghc` library.</div><div><br></div><div>But this is really a stop-gap solution. Besides replacing the GHC.Prim interface, you also need to make sure that the name cache in the GHC session doesn't contain entries referring to the built-in version, and the built-in rewrite rules also need to be avoided. And apparently there are more places: In GHCJS on GHC 8.0 it is possible to get type errors that shouldn't have been there, caused by differences between the original and replaced GHC.Prim module.<br></div><div><br></div><div>For GHC 8.2 I made the decision to abandon the use of the ghcPrimIface hook, instead building GHCJS against a "private" ghc library (under the cabal package name `ghc-api-ghcjs` ). The `ghc-api-ghcjs` library always targets 32 bit. Once we have a better way to dynamically change the target in the `ghc` library, GHCJS can drop the customized library.</div><div><br></div><div>Luite</div><div><br><div class="gmail_quote"><div dir="ltr">On Fri, Mar 16, 2018 at 6:12 AM Shao Cheng <<a href="mailto:astrohavoc@gmail.com">astrohavoc@gmail.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Hi all, is it possible for a 64-bit ghc to emit 32-bit code, if I supply a custom ghcPrimIface via Hooks and also modify the platform flags in DynFlags? The module does not import Prelude and has no dependencies other than GHC.Prim.
_______________________________________________<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-bin/mailman/listinfo/ghc-devs</a><br>
</blockquote></div></div></div>