This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC 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: [PATCH] Support -fuse-ld=bfd and -fuse-ld=gold


On 2012.11.29 at 09:43 +0100, Richard Biener wrote:
> On Thu, Nov 29, 2012 at 5:18 AM, H.J. Lu <hjl.tools@gmail.com> wrote:
> > From: "H.J. Lu" <hjl.tools@gmail.com>
> > To: gcc-patches@gcc.gnu.org
> > Cc: Joseph Myers  <joseph@codesourcery.com>, Paolo Bonzini <bonzini@gnu.org>
> > Bcc:
> > Subject: [PATCH] Support -fuse-ld=bfd and -fuse-ld=gold
> > Reply-To:
> >
> > Hi,
> >
> > Binutils supports 2 linkers, ld.gold and ld.bfd.  One of them is
> > configured as the default linker, ld, which is used by GCC.  Sometimes,
> > we want to use the alternate linker with GCC at run-time.  This patch
> > adds -fuse-ld=bfd and -fuse-ld=gold options to GCC driver.  It changes
> > collect2.c to pick either ld.bfd or ld.gold.  It also adds
> > ORIGINAL_LD_BFD_FOR_TARGET and ORIGINAL_LD_GOLD_FOR_TARGET to
> > exec-tool.in to add -fuse-ld=bfd and -fuse-ld=gold support to
> > collect-ld.  Since ld.bfd nor ld.gold know the new options, you
> > will get
> >
> > # ./xgcc -B./  /tmp/x.c -fuse-ld=gold -v
> > ...
> > ./collect-ld --eh-frame-hdr -m elf_x86_64 -dynamic-linker /lib64/ld-linux-x86-64.so.2 -fuse-ld=gold /lib/../lib64/crt1.o /lib/../lib64/crti.o ./crtbegin.o -L. -L/lib/../lib64 -L/usr/lib/../lib64 /tmp/cclVWcGz.o -v -lgcc --as-needed -lgcc_s --no-as-needed -lc -lgcc --as-needed -lgcc_s --no-as-needed ./crtend.o /lib/../lib64/crtn.o
> > GNU gold (Linux/GNU Binutils 2.23.51.0.7.20121127) 1.11
> > /usr/local/bin/ld.gold: fatal error: -f/--auxiliary may not be used without -shared
> > collect2: error: ld returned 1 exit status
> >
> > This is because we pass everything to ld and ld.bfd/ld.gold doesn't
> > understand -fuse-ld=bfd/-fuse-ld=gold.  It isn't a problem for collect2
> > since it will filter-out -fuse-ld=bfd/-fuse-ld=gold.  I will submit a
> > binutils patch to ignore -fuse-ld=bfd/-fuse-ld=gold, similar to -flto
> > options.
> >
> > OK to install?
> 
> Do we need to consider GNU ld and gold coming from different binutils versions
> and thus do we need two sets of linker feature tests at configure
> time?  Eventually
> also if GNU ld and gold are not in feature-parity for the same binutils version?
> 
> That is, isn't this going to create hard to debug issues for users?

Additionally, what is the rationale for this patch? IOW why isn't the following
enough?

x4 ~ # ln -f /usr/x86_64-pc-linux-gnu/binutils-bin/git/ld.gold  /usr/x86_64-pc-linux-gnu/binutils-bin/git/ld
x4 ~ # ld -v
GNU gold (GNU Binutils 2.23.51.20121126) 1.11
x4 ~ # ln -f /usr/x86_64-pc-linux-gnu/binutils-bin/git/ld.bfd  /usr/x86_64-pc-linux-gnu/binutils-bin/git/ld
x4 ~ # ld -v
GNU ld (GNU Binutils) 2.23.51.20121126

Or is this meant as a temporary workaround hack for gold bugs?

-- 
Markus


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