This is the mail archive of the binutils@sources.redhat.com mailing list for the binutils project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: ld resulting long command line arguments when calling collect2 workaround


"J. Grant" <jg-lists@jguk.org> writes:

> I think this is a binutils query, as it relates to ld calling collect2.
> collect2 is part of gcc I noticed, so if this is a query for gcc please
> let me know.

Note that it's the other way around.  gcc calls collect2 (which is
actually installed under the name ld) which then calls ld (the real
ld).  You can see this by using -Wl,-debug when you run gcc.

> However, the problem is that ld/g++ seems to "expand" the @make.objects
> file and pass all the filenames to the objects again on the command line
> to collect2 (which appears to do the final linking and creation of elf
> etc).  collect2 has the same problem with command line argument limit

I don't know what expands the @make.objects argument.  I very much
doubt that there is any code in gcc or collect2 or ld which expands
that argument.  If you are using cygwin, then perhaps the cygwin shell
expands it.

Presumably you run gcc with @make.objects.  gcc will then run
collect2.  My guess is that when gcc calls collect2, it passes all the
objects on the command line.  My guess is that that fails.  Since gcc
and collect2 are both part of gcc, I think that in order to change
this behaviour you will need to patch gcc.  I don't think that this is
a binutils issue, since I don't think there is anything you can change
in the binutils which will help.

> The other idea I had was to put all the objects in several smaller libs,
> and then link those resulting libs.  However this is causing link
> problems (some code seems to go missing, so I wanted to try linking all
> the objects at the same time).

Using --whole-archive might help when using archives.

Ian


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]