compiling 32 bits haskell program on 64 bits linux

Hi Cafe, I was looking for a way to generate 32 bits haskell binary on a 64 bits linux. I've looked at the user guide and tried to use the -fvia-C with -optc -m32 but the generated C file doesn't compile with lots of error messages like the following: $ ghc -o hello hello.hs -fvia-C -optc "-m32" In file included from /usr/lib/ghc-6.10.4/include/Stg.h:206, from /tmp/ghc15772_0/ghc15772_0.hc:3:0: /usr/lib/ghc-6.10.4/include/Regs.h:235:0: error: invalid register name for ‘R4’ I can't find any others parameters that seems to do anythings about the code generation or around the C compiler. so, does anyone knows if it's possible ? or have some documentation/link about this kind of things ? Thanks, -- Vincent

I think you need to install the 32bit ghc first, because you'll need all the 32bit haskell libs. At least I was able to use the 32bit ghc (version 6.8.2) on a 64 bit linux by changing the script in the bin directory from exec $GHCBIN $TOPDIROPT ${1+"$@"} to exec $GHCBIN -optc-m32 -opta-m32 -optl-m32 $TOPDIROPT ${1+"$@"} (no -fvia-C) HTH Christian Vincent Hanquez schrieb:
Hi Cafe,
I was looking for a way to generate 32 bits haskell binary on a 64 bits linux. I've looked at the user guide and tried to use the -fvia-C with -optc -m32 but the generated C file doesn't compile with lots of error messages like the following:
$ ghc -o hello hello.hs -fvia-C -optc "-m32" In file included from /usr/lib/ghc-6.10.4/include/Stg.h:206, from /tmp/ghc15772_0/ghc15772_0.hc:3:0:
/usr/lib/ghc-6.10.4/include/Regs.h:235:0: error: invalid register name for ‘R4’
I can't find any others parameters that seems to do anythings about the code generation or around the C compiler. so, does anyone knows if it's possible ? or have some documentation/link about this kind of things ?
Thanks,

On Tue, Mar 16, 2010 at 06:27:42PM +0100, Christian Maeder wrote:
I think you need to install the 32bit ghc first, because you'll need all the 32bit haskell libs. At least I was able to use the 32bit ghc (version 6.8.2) on a 64 bit linux by changing the script in the bin directory from exec $GHCBIN $TOPDIROPT ${1+"$@"} to exec $GHCBIN -optc-m32 -opta-m32 -optl-m32 $TOPDIROPT ${1+"$@"}
(no -fvia-C)
That seems to do what i want, I'll look into this solution. Thanks you, -- Vincent

Vincent Hanquez wrote:
I was looking for a way to generate 32 bits haskell binary on a 64 bits linux.
Once absolutely reliable and foolproof way of doing this is to run a 32 bit chroot within your 64 bit system and then then install the 32 bit vesion of GHC in the chroot. In Debian (and Ubuntu), the debootstrap and schroot packages are two tools that make the creation and management of chroots trivial. HTH, Erik -- ---------------------------------------------------------------------- Erik de Castro Lopo http://www.mega-nerd.com/

On Wed, Mar 17, 2010 at 08:18:50AM +1100, Erik de Castro Lopo wrote:
Vincent Hanquez wrote:
I was looking for a way to generate 32 bits haskell binary on a 64 bits linux.
Once absolutely reliable and foolproof way of doing this is to run a 32 bit chroot within your 64 bit system and then then install the 32 bit vesion of GHC in the chroot.
That's what i do on a personal system, but we're looking for a way that doesn't requires root priviledge/chroot to integrate into an openembedded (target is i386) type build. Thanks, -- Vincent

On Mar 17, 2010, at 06:08 , Vincent Hanquez wrote:
On Wed, Mar 17, 2010 at 08:18:50AM +1100, Erik de Castro Lopo wrote:
Vincent Hanquez wrote:
I was looking for a way to generate 32 bits haskell binary on a 64 bits linux.
Once absolutely reliable and foolproof way of doing this is to run a 32 bit chroot within your 64 bit system and then then install the 32 bit vesion of GHC in the chroot.
That's what i do on a personal system, but we're looking for a way that doesn't requires root priviledge/chroot to integrate into an openembedded (target is i386) type build.
Follow the directions for Haskell on Snow Leopard; the 64-bit version doesn't work there yet, so the install instructions force it into 32- bit mode. (This involves putting -m32 options in strategic places, so it should work on any Intel platform.) -- brandon s. allbery [solaris,freebsd,perl,pugs,haskell] allbery@kf8nh.com system administrator [openafs,heimdal,too many hats] allbery@ece.cmu.edu electrical and computer engineering, carnegie mellon university KF8NH
participants (4)
-
Brandon S. Allbery KF8NH
-
Christian Maeder
-
Erik de Castro Lopo
-
Vincent Hanquez