Bug 227302 - lang/gcc: import Debian patch to support -fuse-ld=lld
Summary: lang/gcc: import Debian patch to support -fuse-ld=lld
Status: Closed FIXED
Alias: None
Product: Ports & Packages
Classification: Unclassified
Component: Individual Port(s) (show other bugs)
Version: Latest
Hardware: Any Any
: --- Affects Only Me
Assignee: Gerald Pfeifer
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2018-04-05 18:05 UTC by Ed Maste
Modified: 2018-12-03 01:20 UTC (History)
2 users (show)

See Also:
gerald: maintainer-feedback+


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Ed Maste freebsd_committer 2018-04-05 18:05:13 UTC
We're migrating to lld as the base system linker in FreeBSD, and for testing and development it's useful to be able to explicitly choose a linker for testing via -fuse-ld=<linker> flag, regardless of what the system linker is.

Clang supports arbitrary linkers, and -fuse-ld=bfd, -fuse-ld=lld, and -fuse-ld=gold all work. GCC supports only -fuse-ld=bfd and -fuse-ld=gold. Upstream support for -fuse-ld=lld did not go anywhere: https://gcc.gnu.org/ml/gcc-patches/2016-07/msg00155.html.

Debian has patched GCC to add -fuse-ld=lld: https://anonscm.debian.org/viewvc/gcccvs/branches/sid/gcc-6/debian/patches/gcc-fuse-ld-lld.diff?revision=9366&view=markup

Can we apply the patch to FreeBSD's GCC as well?
Comment 1 Gerald Pfeifer freebsd_committer 2018-10-21 20:29:45 UTC
I've been thinking about this on and off (not ignoring it, though I
should have given you feedback).  And given the relatively limited
amount of contribution we have around GCC on FreeBSD (including my
own bandwidth and skills) and how strenuous maintaining at the base
level has been proving, I'd prefer not to pick up extra complexity
- both in terms of options and local patches.

That said, when/if this becomes available upstream, happy to look
into it again, and in fact just yesterday a patch for GCC 9 was
submitted upstream, cf.
https://gcc.gnu.org/ml/gcc-patches/2018-10/msg01240.html and I'll
keep an eye on that.
Comment 2 Ed Maste freebsd_committer 2018-11-23 01:49:10 UTC
Patch brought in PR 233174
Comment 3 Ed Maste freebsd_committer 2018-11-23 01:51:57 UTC
(In reply to Ed Maste from comment #2)
For riscv64-gcc that is, and it is the patch that was committed upstream. Perhaps we can apply it to the main gcc ports?
Comment 4 Gerald Pfeifer freebsd_committer 2018-11-25 15:30:32 UTC
(In reply to Ed Maste from comment #3)
> For riscv64-gcc that is, and it is the patch that was committed upstream.
> Perhaps we can apply it to the main gcc ports?

I'll do so for lang/gcc8 which soon is going to become the default
flavor or GCC in the Ports Collection.
Comment 5 commit-hook freebsd_committer 2018-11-25 21:08:45 UTC
A commit references this bug:

Author: gerald
Date: Sun Nov 25 21:08:01 UTC 2018
New revision: 485902
URL: https://svnweb.freebsd.org/changeset/ports/485902

Log:
  Add support for -fuse-ld=lld, backported from GCC mainline which is
  going to become GCC 9 (in form of files/patch-fuse-ld=lld borrowed
  from devel/riscv64-gcc).

  PR:		227302

Changes:
  head/lang/gcc8/Makefile
  head/lang/gcc8/files/patch-fuse-ld=lld
Comment 6 Gerald Pfeifer freebsd_committer 2018-11-25 21:13:50 UTC
lang/gcc8 is patched now.
Comment 7 Jan Beich freebsd_committer 2018-12-03 01:20:52 UTC
Does it actually work?

$ pkg install gcc8
$ ktrace -i gcc8 -fuse-ld=lld -Wl,--version
[...]
GNU ld (GNU Binutils) 2.30
[...]
$ kdump -r | fgrep -A1 lld
 48521 collect2 NAMI  "/usr/local/bin/ld.lld"
 48521 collect2 RET   access -1 errno 2 No such file or directory