This is the mail archive of the
mailing list for the binutils project.
Re: The difference in behavior between ld and gold when processing "start group/end group" option
- From: Cary Coutant <ccoutant at google dot com>
- To: Nikola Ikonic <Nikola dot Ikonic at rt-rk dot com>, Binutils <binutils at sourceware dot org>, Petar Jovanovic <Petar dot Jovanovic at rt-rk dot com>
- Date: Wed, 4 Mar 2015 10:47:32 -0800
- Subject: Re: The difference in behavior between ld and gold when processing "start group/end group" option
- Authentication-results: sourceware.org; auth=none
- References: <626f-54f5ed00-13-159dfd60 at 105572234> <20150303231626 dot GA26435 at bubble dot grove dot modra dot org>
Gold flattens the nested groups, by design:
// Called by the bison parser to start a group. If we are already in
// a group, that means that this script was invoked within a
// --start-group --end-group sequence on the command line, or that
// this script was found in a GROUP of another script. In that case,
// we simply continue the existing group, rather than starting a new
// one. It is possible to construct a case in which this will do
// something other than what would happen if we did a recursive group,
// but it's hard to imagine why the different behaviour would be
// useful for a real program. Avoiding recursive groups is simpler
// and more efficient.
If you try to nest a --start-group option within another, you'll get
an error, but if you use a script with a GROUP inside a --start-group,
we simply flatten it.
How much sympathy I have for builds that break because of this: none, sorry.
On Tue, Mar 3, 2015 at 3:16 PM, Alan Modra <email@example.com> wrote:
> On Tue, Mar 03, 2015 at 06:19:45PM +0100, Nikola Ikonic wrote:
>> Which of these linkers behave correctly?
> I would say, GNU ld. The innermost group ought to be repeatedly
> searched until no new objects are extracted from libraries, before
> looking at any other input files. GROUP ( libtest2.a libdummy.a )
> ought to cause head_dummy.o to be extracted from libdummy.a then
> test2.o from libtest2.a, before the linker considers libtest.a.
> Alan Modra
> Australia Development Lab, IBM