cross-compilation mode for hsc2hs
Brian Bloniarz
brian.bloniarz at gmail.com
Thu Dec 23 07:59:20 CET 2010
Hi Ian,
I updated my hsc2hs patch as you suggested -- running
hsc2hs --cross-safe
will check for only the subset of hsc2hs which is
supported by the cross-compilation mode. I also
updated to the newest GHC head. The new patches
are attached, please take a look.
patch.hsc2hs_cross
Patch for ghc/utils/hsc2hs; the main functionality,
adding hsc2hs --cross-compile and hsc2hs --cross-safe.
patch.ghc-mk
Patch for ghc/, passes --cross-safe to hsc2hs in config.mk.in.
patch.base
Patch for libraries/base, updates System/Event/Poll.hsc to
compile correctly under cross-compilation. This is an
unfortunate discrepancy between hsc2hs and hsc2hs --cross-compile:
the original Poll.hsc had the following:
#{enum Event, Event
, pollIn = POLLIN
, pollOut = POLLOUT
#ifdef POLLRDHUP
, pollRdHup = POLLRDHUP
#endif
, pollErr = POLLERR
, pollHup = POLLHUP
}
Placing #ifdefs within an #{enum} *works* in hsc2hs, however
it's only by fragile accident (hsc2hs does not actively try
to handle the #ifdefs, they just get pasted at opportune
places in the .c file). Say, if you move the #ifdef up to
the first element (pollIn), it fails to compile. Rather
than mimic this behavior in hsc2hs --cross-compile, I just
patched Poll.hsc to not do this.
libraries/unix patch.unix
System/Posix/Files.hsc depends on a peculiarity of hsc2hs
-- it checks for an #define (HAVE_LCHOWN) which gets defined
in a header file which is #include'd below the check! This
happens to work for hsc2hs because of the way it does codegen,
but the cross-compile mode doesn't show the same behavior (IMHO,
the cross-compile's behavior is the one that people expect).
So rearrange the lines in Files.hsc so HsUnix.h is included
before HAVE_LCHOWN is checked.
-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: patch.hsc2hs_cross
URL: <http://www.haskell.org/pipermail/cvs-ghc/attachments/20101222/eabaf9b6/attachment-0002.txt>
-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: patch.base
URL: <http://www.haskell.org/pipermail/cvs-ghc/attachments/20101222/eabaf9b6/attachment-0002.asc>
-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: patch.ghc-mk
URL: <http://www.haskell.org/pipermail/cvs-ghc/attachments/20101222/eabaf9b6/attachment-0003.txt>
-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: patch.unix
URL: <http://www.haskell.org/pipermail/cvs-ghc/attachments/20101222/eabaf9b6/attachment-0003.asc>
More information about the Cvs-ghc
mailing list