
I seem to be having some trouble doing this and have a couple of questions..
The first question is how do you use --make option when doing this? Section 4.5 of the users guide seems to contradictory to me.
It states.. "The command line must contain one source file or module name"
This is wrong (or at least, out of date). I'll fix it. You can now specify any number of source files, module names, linkable objects and libraries on the command line in --make mode or GHCi.
and later.. "If the program needs to be linked with additional objects (say, some auxilliary C code), these can be specified on the command line as usual."
ghc Main.hs foo.o is OK, but whenever I try this...
ghc --make Main.hs foo.o I get the error.. can't find module 'foo.o'
I think you must be using a version of GHC prior to 5.04.2. This functionality was fixed in 5.04.2.
The second question is what object formats does ghc understand and is the object file suffix significant? If I try elf format, this is accepted without complaint but I get a broken executable (though this could well be because my assembler has generated a broken elf file). Using coff format seems OK. The files have a ".o" suffix in both cases.
FWIW, I'm using ghc 5.04.2 on Win32 with the nasm assembler.
I'm not sure about this one - any Windows experts out there like to comment? My guess is that GHCi should load COFF objects only, but other kinds of objects might work when using the system linker (i.e. in batch mode). Cheers, Simon