Skip site navigation (1)Skip section navigation (2)
Date:      Fri, 11 Jan 2019 09:37:24 -0500
From:      Ed Maste <emaste@freebsd.org>
To:        FreeBSD Ports <freebsd-ports@freebsd.org>
Subject:   HEADS-UP: switching i386 to lld as system linker
Message-ID:  <CAPyFy2C7g1Q3=qbgJQAcLwv=hMXACLFuyE9SMuSR%2BzqpEpQttw@mail.gmail.com>

next in thread | raw e-mail | index | archive | help
As you may know I've been working on migrating to LLVM's lld as our
system linker, to replace the outdated GNU binutils ld 2.17.50. lld is
currently the system linker (i.e., is /usr/bin/ld) on amd64, arm64,
and armv7. i386 was not switched over at the same time as the other
architectures because many ports failed to build with lld, primarily
due to linking non-PIC code into shared objects.

Thanks to Antoine's sustained effort we've run through many
exp-runs[1], iterating on addressing ports that fail to build with
lld. The most recent i386 exp-run[2] had a little over 40 new failures
which resulted in about 70 skipped ports; a few of the failing ports
responsible for the most skipped have since been addressed. PRs are
open for the remaining failures and can be found via the dependency
tree[3] for the exp-run PR 214864.

I intend to enable lld as the system linker for i386 in -CURRENT in
the next week or so, and will continue helping address new failures
before and after the default is switched over.

The easiest way to configure an existing -CURRENT i386 system for
testing with lld as the system linker is to run as root:

# ln -fs ld.lld /usr/bin/ld

conversely, to switch (back) to GNU binutils ld:

# ln -fs ld.bfd /usr/bin/ld

There are a few ways to address failures with lld:

1. Add LLD_UNSAFE to the Makefile, which will cause the port to
(attempt to) depend on the binutils port/package and link with GNU ld.
This may not work if the port's build infrastructure does not honour
LD or LDFLAGS environment variables.

2. Add LDFLAGS_i386=-Wl,-z,notext to the Makefile. This will override
lld's default of disallowing .text relocations (and is a no-op with
GNU ld, just reaffirming GNU ld's default). As with #1 above, this may
not work if the port does not properly honour LDFLAGS.

3. Ensure that -fPIC is included in CFLAGS when compiling objects to
be linked into shared objects.

4. Rewrite assembly files to be linked into shared objects to be PIC.

Please let me know if you have any questions or want assistance with a
specific port.

[1] https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=214864
[2] http://package18.nyi.freebsd.org/build.html?mastername=headi386PR214864-default&build=2019-01-05_21h00m02s
[3] https://bugs.freebsd.org/bugzilla/showdependencytree.cgi?id=214864&hide_resolved=1



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?CAPyFy2C7g1Q3=qbgJQAcLwv=hMXACLFuyE9SMuSR%2BzqpEpQttw>