Compiling to ANSI C

Daniel Peebles pumpkingod at gmail.com
Sat Nov 7 13:48:14 EST 2009


You can use -fvia-C and -keep-hc-files but the generated C code is
pretty platform-dependent (at least in terms of word sizes and so
on... it may be possible to port across platforms with the same word
sizes?), and probably won't help you cross-compile. It also doesn't
look much like any c code any human would have written, and I think
there are plans to deprecate the via-C compilation pathway eventually.

If you are looking to add cross-compilation to GHC, the first thing
I'd look at is detaching the choice of native code generator from the
preprocessor and hooking it up to a front-end command-line option
instead :) Someone on IRC (his username is dumael, not sure what his
real name is) has already been working on an ARM native code generator
for GHC recently. The recent LLVM back-end development should also
make it pretty simple to generate code for other platforms (especially
if we have a nice way to pass front-end options to the code
generators)

Dan

On Sat, Nov 7, 2009 at 12:08 PM, han <e at xtendo.org> wrote:
> I am (in fact we are) working to make Haskell code to run on an ARM
> Linux machine called GP2X Wiz, the open-source based handheld game
> console.
>
> I wish to finally make a Haskell cross-compiler for ARM Linux, and for
> now I am trying to make
>
> main = putStrLn "Hello, World!"
>
> to run on the machine. At first I did
>
> $ ghc hello.hs -o hello -fvia-C -keep-hc-files
>
> and tried to use the generated hc file, but figured that the code is
> (or at least some code in the included headers is) x86-dependent.
>
> I heard that the GHC can compile to ANSI C, and I want to use it as an
> intermediate code to ARM Linux before we can actually port the GHC to
> it.
>
> Is there any specific option I have to give in order to generate an
> ANSI C code from a Haskell source code?
> _______________________________________________
> Glasgow-haskell-users mailing list
> Glasgow-haskell-users at haskell.org
> http://www.haskell.org/mailman/listinfo/glasgow-haskell-users
>


More information about the Glasgow-haskell-users mailing list