This is the mail archive of the 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 Thu, Nov 29, 2012 at 12:43 AM, Richard Biener
<> wrote:
> On Thu, Nov 29, 2012 at 5:18 AM, H.J. Lu <> wrote:
>> From: "H.J. Lu" <>
>> To:
>> Cc: Joseph Myers  <>, Paolo Bonzini <>
>> Bcc:
>> Subject: [PATCH] Support -fuse-ld=bfd and -fuse-ld=gold
>> Reply-To:
>> Hi,
>> Binutils supports 2 linkers, 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  It also adds
>> to add -fuse-ld=bfd and -fuse-ld=gold support to
>> collect-ld.  Since ld.bfd nor 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/ -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 1.11
>> /usr/local/bin/ 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/ 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?

Actually, it helps to debug issues for users.  At the moment, we don't
know which linker is the default linker.  With -fuse-ld, we can specify
which linker to use.


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