Ian Lynagh wrote,

On Fri, Dec 15, 2006 at 03:08:24PM -0800, Mathew Mills wrote:
I want to be able to build a version of GHC that runs on x86 but
generates binaries that will run natively on x86_64.

I don't think there would be any major technical difficulties in adding support, just a lot of assumptions in the compiler, libraries and build system that we are generating code for the architecture that we are on,
so it could eat quite a bit of time.

Cross compiling using -fvia-C would seem to be easier (assuming your GCC is a cross-compiler) and of course you would have to build an x86_64 version of the RTS and other libraries that may be linked in (currently, statically except on OS X, but that may change soon since Wolfgang Thaller got PIC going in the Native Code Generator (NCG), see Commentary/PositionIndependentCode). As for other settings, the Mangler (driver/mangler/ghc-asm.lprl), for example, runs according to $TargetPlatform, set by the build system into one small Perl script ("ghc-asm")--you would need to change the build system and the compiler commands to use different targets.

One of the worst problems is the NCG: it currently targets only one architecture (machine, OS) as it is pieced together by conditional defines from the build system. The right way to go about doing cross- compilation with the NCG involves moving the architecture specific parts into separate modules and binding them into the compiler with dynamic options. To my knowledge, this is a far-off goal. The benefit (from what I am doing) would be the ability to use a simple cross-compiling assembler to assemble the code generated by the NCG for a number of different architectures (x86, x86_64, including AMD) and different file formats (COFF, Win32-COFF, OBJ, ELF). I am currently modifying GHC to use the Yasm modular assembler <http:// www.tortall.net/projects/yasm/> for Windows-native code but it would also be usable for other x86 architectures.

I have been rooting around in the system for a little while now-- including command options, NCG modifications and the build system, so if you have any questions feel free to ask.

Cheers,
Pete Tanski


_______________________________________________
Cvs-ghc mailing list
[EMAIL PROTECTED]
http://www.haskell.org/mailman/listinfo/cvs-ghc

Reply via email to