
Hi, Am Donnerstag, den 13.10.2011, 22:26 +0400 schrieb Michael Lazarev:
It turns out that it is also possible to compile a 32-bit executable by 32-bit ghc under Ubuntu 11.10 x64. First, additional files supporting compilation for different architectures in gcc must be installed by "sudo apt-get install g++multilib". Second, one need to pass additional arguments to ghc: "-opta -m32 -optl -m32". They are, in turn, passed to gcc assembler and linker, respectively, telling them to build for 32-bit architecture.
Complete example:
----------------------------------------------------------------------
$ sudo apt-get install lib32gmp-dev g++multilib
$ cat ./Test.hs module Main where
import Control.Monad
getR :: Read r => IO r getR = liftM read getLine
main = liftM2 (+) getR getR >>= print
$ /home/ml/local/ghc/7.0.4-32/bin/ghc --make ./Test.hs -opta -m32 -optl -m32 Linking Test ...
$ file ./Test ./Test: ELF 32-bit LSB executable, Intel 80386, version 1 (SYSV), dynamically linked (uses shared libs), for GNU/Linux 2.6.15, not stripped
----------------------------------------------------------------------
Did you build the boot libraries and possible ghc also with these flags? Greetings, Joachim -- Joachim "nomeata" Breitner mail@joachim-breitner.de | nomeata@debian.org | GPG: 0x4743206C xmpp: nomeata@joachim-breitner.de | http://www.joachim-breitner.de/