RE: Linking with object files

2003-01-09 Thread Simon Marlow

> On Wednesday 08 January 2003  5:00 pm, Simon Marlow wrote:
> > What command line are you using?  Here's what I did:
> >
> > ~/scratch > cat  >foo.c
> > ~/scratch > gcc -c foo.c
> > ~/scratch > ghc --make hello.hs foo.o
> > ghc-5.04.2: chasing modules from: hello.hs
> > Skipping  Main ( hello.hs, ./hello.o )
> > ghc: linking ...
> > ~/scratch >
> 
> The exact command line I'm using is..
>  ghc --make -fglasgow-exts -Wall -o Main.exe Main.hs Fill.o Render.o
> which gives..
>  ghc-5.04.2: chasing modules from: Main.hs,Fill.o,Render.o
>  ghc-5.04.2: can't find module `Fill.o' (while processing "Fill.o")
> 
> But playing about a bit, I found the solution. It doesn't like
> upper case object file names. Not sure if that's by design or an
> oversight. I've changed them to lower case and it works fine now.

Eek!  That's a bug, thanks!

Cheers,
Simon
___
Glasgow-haskell-users mailing list
[EMAIL PROTECTED]
http://www.haskell.org/mailman/listinfo/glasgow-haskell-users



Re: Linking with object files

2003-01-08 Thread Adrian Hey
On Wednesday 08 January 2003  5:00 pm, Simon Marlow wrote:
> What command line are you using?  Here's what I did:
>
> ~/scratch > cat  >foo.c
> ~/scratch > gcc -c foo.c
> ~/scratch > ghc --make hello.hs foo.o
> ghc-5.04.2: chasing modules from: hello.hs
> Skipping  Main ( hello.hs, ./hello.o )
> ghc: linking ...
> ~/scratch >

The exact command line I'm using is..
 ghc --make -fglasgow-exts -Wall -o Main.exe Main.hs Fill.o Render.o
which gives..
 ghc-5.04.2: chasing modules from: Main.hs,Fill.o,Render.o
 ghc-5.04.2: can't find module `Fill.o' (while processing "Fill.o")

But playing about a bit, I found the solution. It doesn't like
upper case object file names. Not sure if that's by design or an
oversight. I've changed them to lower case and it works fine now.

Regards
--
Adrian Hey 

___
Glasgow-haskell-users mailing list
[EMAIL PROTECTED]
http://www.haskell.org/mailman/listinfo/glasgow-haskell-users



RE: Linking with object files

2003-01-08 Thread Simon Marlow

> On Wednesday 08 January 2003 10:04 am, Simon Marlow wrote:
> > > I get the error.. can't find module 'foo.o'  processing "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.
> 
> I just checked, it really is (or claims to be:-) version 5.04.2.
> I get the same error using 5.04.2 under Linux too.

What command line are you using?  Here's what I did:

~/scratch > cat  >foo.c
~/scratch > gcc -c foo.c
~/scratch > ghc --make hello.hs foo.o
ghc-5.04.2: chasing modules from: hello.hs
Skipping  Main ( hello.hs, ./hello.o )
ghc: linking ...
~/scratch >

Actually I was incorrect before: this has worked fine in 5.04, 5.04.1
and 5.04.2.  The fix made in 5.04.2 was to pass files without a
recognised extension through to the linker, to match the behaviour
without --make.

Cheers,
Simon
___
Glasgow-haskell-users mailing list
[EMAIL PROTECTED]
http://www.haskell.org/mailman/listinfo/glasgow-haskell-users



Re: Linking with object files

2003-01-08 Thread Adrian Hey
Thanks for your answers

On Wednesday 08 January 2003 10:04 am, Simon Marlow wrote:
> > 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.

I just checked, it really is (or claims to be:-) version 5.04.2.
I get the same error using 5.04.2 under Linux too.

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

I've now tried a variety of formats on both win32 and Linux, the answer
seems to be:

On Linux using ld version 2.10.91
-
aout format works.

coff,as86,obj,win32,rdf formats all give the error..
foo.o: file not recognized: File format not recognized

elf format gives the error..
/usr/bin/ld: foo.o: invalid section symbol index 0xfff1 (*ABS*) ingored
It does indeed "ingore" the error and go on to produce an executable, but
this time it works.


On Win32 using ld version 2.11.90 (as shipped with ghc)
---
coff and win32 formats work.

as86,obj,rdf formats all give the error..
foo.o: file not recognized: File format not recognized

elf format gives no error, but the executable is broken

This was all with .o suffix, dunno if changing it to something else
might get rid some of these errors. 

Don't know if any of this is any help. It seems there's something
dodgy with elf format, either in nasm or ld (not sure which).

Regards
--
Adrian Hey
___
Glasgow-haskell-users mailing list
[EMAIL PROTECTED]
http://www.haskell.org/mailman/listinfo/glasgow-haskell-users



RE: Linking with object files

2003-01-08 Thread Simon Marlow
> 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
___
Glasgow-haskell-users mailing list
[EMAIL PROTECTED]
http://www.haskell.org/mailman/listinfo/glasgow-haskell-users



Linking with object files

2003-01-06 Thread Adrian Hey
Hello,

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"

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' 

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.

Thanks
--
Adrian Hey  

___
Glasgow-haskell-users mailing list
[EMAIL PROTECTED]
http://www.haskell.org/mailman/listinfo/glasgow-haskell-users