Jon Grant <j...@jguk.org> writes:

> I see that some of the files are located in the -L library directory
> specified, crtbegin.o, crtend.o in which case, perhaps they both do
> not need their full long path specified.

Most linkers do not use the -L path to search for file names on the
command line.


>>> Also I notice lots of duplicate parameters:
>>>
>>> Is this directory really needed twice?
>>> -L/usr/lib/gcc/i486-linux-gnu/4.3.3 -L/usr/lib/gcc/i486-linux-gnu/4.3.3
>>
>> No.  I would encourage you to investigate why it is happening.
>
> i tried: gcc -o t -Wl,-debug test.c, I see collect2 gets the
> duplicates passed to it, and then it passes it on to ld. I would have
> thought that if collect2 was compiled with define
> LINK_ELIMINATE_DUPLICATE_LDIRECTORIES it would strip out the duplicate
> parameters before calling ld.  It does not appear to be switched on in
> this Ubuntu package I am using though. Is it on by default?

No.  It was introduced only to avoid an error in the linker in some
version of SGI Irix.  Generally the duplicate -L option does no harm.

I was actually thinking along of the lines of eliminating it earlier
in the process.  Why does the directory get in there twice in the
first place?


>> To see what collect2 is doing, use -Wl,-debug
>
> If I add this to my existing command line I see there not any output:
> $ gcc -### -o t -Wl,-debug test.c
>
> If I change to not have -### I see it does work, not sure why.

-### controls the gcc driver, not the collect2 program.


> So I understand that this passes -debug to collect2. As collect2 only
> has -v mode to display version. Would a patch to add --help to it be
> supported? Also could describe something about collect2's purpose at
> the top of that --help output.

I think that ordinary uses of -Wl,--help will expect to see the --help
option for the linker, not for collect2.  That said, I think it would
be OK to add a --help option for collect2 which issued some output and
then went on to invoke the linker.


> 1) collect.c:scan_libraries may not find ldd, in which case it
> displays message on output, and returns as normal. Should it not be
> fatal if ldd is required?

It seems to me that it gives an error message, which should cause
collect2 to exit with a non-zero status.  Does that not happen for
you?  Note that ldd is only required on HP/UX.


> 2) in collect2.c:main "-debug" is checked, and variable debug set to 1
> (perhaps that should be "true" to match the style of other flags)

Yes, and debug should be changed from int to bool.

Ian

Reply via email to