Re: Compiling to ANSI C

2009-11-09 Thread Simon Marlow

On 07/11/2009 18:48, Daniel Peebles wrote:

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 :)


We already compile in all the NCG backends, so that should be quite 
straightforward.  What's much harder is arranging the rest of your 
cross-compilation environment - assembler, linker etc., and making sure 
you're using the right configuration parameters from the target machine 
for the build.  It's generally easier to get an unregisterised port 
working first, and then use that to bootstrap an NCG/registerised version.



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.


Interesting, I didn't know that.  There's also the iPhone GHC port, 
which is unregisterised, I believe.


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)


Definitely, I think that will be a nice side-effect of the LLVM backend.

Cheers,
Simon
___
Glasgow-haskell-users mailing list
Glasgow-haskell-users@haskell.org
http://www.haskell.org/mailman/listinfo/glasgow-haskell-users


Re: Compiling to ANSI C

2009-11-08 Thread Matthias Kilian
On Sun, Nov 08, 2009 at 10:19:26AM +0300, Bulat Ziganshin wrote:
 seems that wizards are on holiday ATM, so i will help a little - ghc
 ports are divided into registerized (working with cpu registers)
 and unregisterized (just a C code generated).

I wouldn't touch the *registerized* variant using intermediate C
files, because that means you probably would also have to modify
the evil mangler, which is -- evil.

Ciao,
Kili
___
Glasgow-haskell-users mailing list
Glasgow-haskell-users@haskell.org
http://www.haskell.org/mailman/listinfo/glasgow-haskell-users


Compiling to ANSI C

2009-11-07 Thread han
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@haskell.org
http://www.haskell.org/mailman/listinfo/glasgow-haskell-users


Re: Compiling to ANSI C

2009-11-07 Thread Thomas DuBuisson
If I were you, I'd look at using the recent LLVM backend work as a
means to translate Haskell - ARM.

Thomas

On Sat, Nov 7, 2009 at 9:08 AM, han e...@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@haskell.org
 http://www.haskell.org/mailman/listinfo/glasgow-haskell-users

___
Glasgow-haskell-users mailing list
Glasgow-haskell-users@haskell.org
http://www.haskell.org/mailman/listinfo/glasgow-haskell-users


Re: Compiling to ANSI C

2009-11-07 Thread Daniel Peebles
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...@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@haskell.org
 http://www.haskell.org/mailman/listinfo/glasgow-haskell-users

___
Glasgow-haskell-users mailing list
Glasgow-haskell-users@haskell.org
http://www.haskell.org/mailman/listinfo/glasgow-haskell-users


Re: Compiling to ANSI C

2009-11-07 Thread scooter . phd
Do we have a native LLVM bitcode writer or is it still FFI?

--Original Message--
From: Thomas DuBuisson
Sender: glasgow-haskell-users-boun...@haskell.org
To: han
Cc: glasgow-haskell-users@haskell.org
Subject: Re: Compiling to ANSI C
Sent: Nov 7, 2009 09:56

If I were you, I'd look at using the recent LLVM backend work as a
means to translate Haskell - ARM.

Thomas

On Sat, Nov 7, 2009 at 9:08 AM, han e...@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@haskell.org
 http://www.haskell.org/mailman/listinfo/glasgow-haskell-users

___
Glasgow-haskell-users mailing list
Glasgow-haskell-users@haskell.org
http://www.haskell.org/mailman/listinfo/glasgow-haskell-users


Sent from my Verizon Wireless BlackBerry___
Glasgow-haskell-users mailing list
Glasgow-haskell-users@haskell.org
http://www.haskell.org/mailman/listinfo/glasgow-haskell-users


Re: Compiling to ANSI C

2009-11-07 Thread Thomas DuBuisson
On Sat, Nov 7, 2009 at 11:16 AM,  scooter@gmail.com wrote:
 Do we have a native LLVM bitcode writer or is it still FFI?

I was referring to a paper [1] I just ran into on reddit.  I only
skimmed it, but it seems they (or just he?) integrated LLVM as a new
backend for GHC.

Thomas

[1] http://www.cse.unsw.edu.au/~pls/thesis/davidt-thesis.pdf
___
Glasgow-haskell-users mailing list
Glasgow-haskell-users@haskell.org
http://www.haskell.org/mailman/listinfo/glasgow-haskell-users


Re: Compiling to ANSI C

2009-11-07 Thread scooter . phd
Believe it when it shows up in GHC pristine.

--Original Message--
From: Thomas DuBuisson
To: scooter@gmail.com
Cc: han
Cc: glasgow-haskell-users@haskell.org
Subject: Re: Compiling to ANSI C
Sent: Nov 7, 2009 11:28

On Sat, Nov 7, 2009 at 11:16 AM,  scooter@gmail.com wrote:
 Do we have a native LLVM bitcode writer or is it still FFI?

I was referring to a paper [1] I just ran into on reddit.  I only
skimmed it, but it seems they (or just he?) integrated LLVM as a new
backend for GHC.

Thomas

[1] http://www.cse.unsw.edu.au/~pls/thesis/davidt-thesis.pdf


Sent from my Verizon Wireless BlackBerry
___
Glasgow-haskell-users mailing list
Glasgow-haskell-users@haskell.org
http://www.haskell.org/mailman/listinfo/glasgow-haskell-users


Re: Compiling to ANSI C

2009-11-07 Thread John Meacham
Jhc compiles to ANSI C and has been tested with other ARM targets and
works fine. It may be suitable for your needs.

John

-- 
John Meacham - ⑆repetae.net⑆john⑈ - http://notanumber.net/
___
Glasgow-haskell-users mailing list
Glasgow-haskell-users@haskell.org
http://www.haskell.org/mailman/listinfo/glasgow-haskell-users


Re: Compiling to ANSI C

2009-11-07 Thread Bulat Ziganshin
Hello han,

Saturday, November 7, 2009, 8:08:51 PM, you 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.

seems that wizards are on holiday ATM, so i will help a little - ghc
ports are divided into registerized (working with cpu registers)
and unregisterized (just a C code generated). for the fist time, you
need to make unregisterized port of course. nevertheless, ghc doesn't
generate portable C afaik, but you will have much less work to do -
i.e. tune wordsizes and so on. sorry, i don't know more, google for
unregisterized ghc


-- 
Best regards,
 Bulatmailto:bulat.zigans...@gmail.com

___
Glasgow-haskell-users mailing list
Glasgow-haskell-users@haskell.org
http://www.haskell.org/mailman/listinfo/glasgow-haskell-users