Bug 226986 - lang/myrddin: fails to link with lld as the system linker
Summary: lang/myrddin: fails to link with lld as the system linker
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: Tobias Kortkamp
Depends on:
Blocks: 214864
  Show dependency treegraph
Reported: 2018-03-27 15:47 UTC by Ed Maste
Modified: 2018-03-27 17:46 UTC (History)
0 users

See Also:
bugzilla: maintainer-feedback? (tobik)


Note You need to log in before you can comment on or make changes to this bug.
Description Ed Maste freebsd_committer 2018-03-27 15:47:47 UTC
I'm working on switching to LLVM's lld linker as the FreeBSD system linker (/usr/bin/ld)[1], and the port in this PR is reported as a new failure in the exp-run, PR 214864.

An excerpt from the build log[2]:
+ ld -o mbld/mbld /wrkdirs/usr/ports/lang/myrddin/work/mc/rt/_myrrt.o mbld/deps.o mbld/main.o mbld/util.o mbld/libs.o mbld/syssel.o mbld/config.o mbld/opts.o mbld/subtest.o mbld/types.o mbld/test.o mbld/install.o mbld/parse.o mbld/build.o -Llib/thread -lthread -Llib/bio -lbio -Llib/regex -lregex -Llib/std -lstd -Llib/sys -lsys
ld: error: <internal>: section sh_addralign is not a power of 2
+ true
./mbldwrap.sh: mbld/mbld: not found
Unable to run mbld ; have you build successfully

lld is more strict about invalid data in ELF objects.

FreeBSD 11 and later have lld available as /usr/bin/ld.lld, so one simple option for testing is to just symlink /usr/bin/ld to ld.lld (and restore it to ld.bfd).

A port Makefile knob, LLD_UNSAFE=yes, exists to indicate that a port does not work with lld, and requires either /usr/bin/ld.bfd or binutils from ports. This should work for the common case of ports written in C using GNU autoconf; it may have no effect on other ports.

[1] https://lists.freebsd.org/pipermail/freebsd-current/2018-March/068985.html
[2] http://package18.nyi.freebsd.org/data/headamd64PR214864-default/2018-03-21_17h43m11s/logs/errors/myrddin-0.2.0.log
Comment 1 commit-hook freebsd_committer 2018-03-27 17:46:03 UTC
A commit references this bug:

Author: tobik
Date: Tue Mar 27 17:45:30 UTC 2018
New revision: 465725
URL: https://svnweb.freebsd.org/changeset/ports/465725

  lang/myrddin: Fix build when ld is ld.lld

  ld: error: <internal>: section sh_addralign is not a power of 2

  Myrddin's build system directly calls ld so LLD_UNSAFE can't work
  here.  Workaround the issue by adding a binary alias to ld.bfd to fix
  the build for now.

  PR:		226986
  Reported by:	emaste