I've been investigating building the ports tree with LLVM's lld installed as /usr/bin/ld (via the exp-run in PR 214864). As of today lang/fpc fails when linked with lld, and of those failing it is responsible for the largest number of skipped ports (110). When linking with lld (with LD=ld.bfd in the environment) the build failed with: /usr/bin/ld: error: x86_64/units/x86_64-freebsd/i_linux.o: invalid alignment of section headers pp.pas(247,1) Error: Error while linking pp.pas(247,1) Fatal: There were 1 errors compiling module, stopping Fatal: Compilation aborted I think this may be coming from fpc-3.0.2/compiler/systems/t_bsd.pas from ExeCmd and DllCmd like so: 149 ExeCmd[1]:='ld $TARGET $EMUL $OPT $DYNLINK $STATIC $GCSECTIONS $STRIP -L. -o $EXE $CATRES'; 150 DllCmd[1]:='ld $TARGET $EMUL $OPT -shared -L. -o $EXE $CATRES' I'll try to have an attempt at a patch.
% readelf -h compiler/x86_64/units/x86_64-freebsd/i_linux.o | grep 'section headers' Start of section headers: 5997 (bytes into file) Size of section headers: 64 (bytes) Number of section headers: 18
Bug report submitted to fpc for the misaligned section header issue: https://bugs.freepascal.org/view.php?id=32900
Misaligned section header issue is now resolved upstream.
Failure log from most recent exp-run: http://package18.nyi.freebsd.org/data/headamd64PR214864-default/2018-03-21_17h43m11s/logs/errors/fpc-3.0.4.log
Via tobik@ in ports r465725, BINARY_ALIAS=ld=ld.bfd may be an effective workaround if LLD_UNSAFE does not work.
BINARY_ALIAS=ld=ld.bfd seems to work.
A commit references this bug: Author: emaste Date: Thu Mar 29 15:40:06 UTC 2018 New revision: 465903 URL: https://svnweb.freebsd.org/changeset/ports/465903 Log: lang/fpc: Set LLD_UNSAFE fpc produces and needs to link an object file with invalid section header alignment, which lld refuses to do. The build fails with: /usr/bin/ld: error: x86_64/units/x86_64-freebsd/i_linux.o: \ invalid alignment of section headers Setting LLD_UNSAFE makes the port link with ld.bfd instead. PR: 222172 Approved by: portmgr (LLD_UNSAFE blanket) Sponsored by: The FreeBSD Foundation Changes: head/lang/fpc/Makefile
Workaround committed.