Bug 226984

Summary: devel/ztcl: fails to link with lld as the system linker
Product: Ports & Packages Reporter: Ed Maste <emaste>
Component: Individual Port(s)Assignee: freebsd-ports-bugs (Nobody) <ports-bugs>
Status: Closed FIXED    
Severity: Affects Only Me    
Priority: ---    
Version: Latest   
Hardware: Any   
OS: Any   
Bug Depends on:    
Bug Blocks: 214864    

Description Ed Maste freebsd_committer 2018-03-27 15:40:01 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 -Bshareable -x -o libztcl1.0.4.so.0 init.o commands.o channel.o transform.o gzfile.o stream.o compress.o miscellaneous.o ztclStubInit.o  -lz  -L/usr/local/lib -ltclstub86 
ld: error: unable to find library -lz

Known issues in this port or in lld that affect this port:

(2) lld has no built-in search paths (/lib, /usr/lib). Normally the linker is invoked from the compiler driver, and the search paths are added by the compiler. If lld is invoked directly library search paths must be specified explicitly, with -L/lib -L/usr/lib.

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/ztcl-1.0.b4_1.log
Comment 1 Ed Maste freebsd_committer 2018-03-27 20:57:17 UTC
Via tobik@ in ports r465725, BINARY_ALIAS=ld=ld.bfd may be an effective workaround if LLD_UNSAFE does not work.
Comment 2 Ed Maste freebsd_committer 2018-03-27 21:17:44 UTC
Via tobik@ in ports r465725, BINARY_ALIAS=ld=ld.bfd may be an effective workaround if LLD_UNSAFE does not work.
Comment 3 Ed Maste freebsd_committer 2018-03-28 01:06:28 UTC
Followup, if BINARY_ALIAS is used it should be in addition to LLD_UNSAFE, so that architectures without a /usr/bin/ld.bfd (arm64) work. If possible LLD_UNSAFE=yes should imply BINARY_ALIAS=ld=ld.bfd, under discussion on the ports mailing list.
Comment 4 commit-hook freebsd_committer 2018-03-29 10:51:55 UTC
A commit references this bug:

Author: krion
Date: Thu Mar 29 10:51:39 UTC 2018
New revision: 465883
URL: https://svnweb.freebsd.org/changeset/ports/465883

  Switch to ld.bfd by default as ld.ldd doesn't have built-in default
  output target.

  PR:		226984
  Submitted by:	emaste
  Approved by:	portmgr (LLD_UNSAFE blanket)