[mercury-users] compilation problem, all, some

Zoltan Somogyi zs at cs.mu.OZ.AU
Mon Jul 19 12:29:27 AEST 2004


On 16-Jul-2004, David Overton <dmo at cs.mu.OZ.AU> wrote:
> > main_init.o(.text+0x179): In function `mercury_init':
> > : undefined reference to `<predicate 'main'/2 mode 0>'
> > collect2: ld returned 1 exit status
> 
> I don't know what's causing the link error.

I think I do. The code generated by Mercury contains a bunch of functions
that we never call; instead, we jump around inside and between those functions
using nonlocal gotos. We got gcc up to and including 3.2 to leave the functions
alone by taking their addresses. However, we took their addresses inside the
functions themselves, and gcc 3.4 is smart enough to figure out that the code
that takes the addresses of those functions itself won't be executed, and thus
eliminates the functions as dead code. I bet the same problem affects gcc 3.3.

I fixed the problem by taking the addresses of the container functions
outside the functions themselves. I committed the fix in the CVS repository
last week or the week before, so it should be in recent releases of the day.
Maurizio is probably using something older.

A workaround that doesn't require installing a new rotd would be to use grade
reg.gc.

Zoltan.
--------------------------------------------------------------------------
mercury-users mailing list
post:  mercury-users at cs.mu.oz.au
administrative address: owner-mercury-users at cs.mu.oz.au
unsubscribe: Address: mercury-users-request at cs.mu.oz.au Message: unsubscribe
subscribe:   Address: mercury-users-request at cs.mu.oz.au Message: subscribe
--------------------------------------------------------------------------



More information about the users mailing list