fpc creates objects with invalid header alignment, fails to link with LLVM's lld linker
Original Reporter info from Mantis: emaste
-
Reporter name: Ed Maste
Original Reporter info from Mantis: emaste
- Reporter name: Ed Maste
Description:
FreeBSD is in the process of switching to LLVM's lld linker as /usr/bin/ld, and we are testing ports builds with lld. Free Pascal failed in that test build. Our first-pass workaround for failures like this is to set LD=ld.bfd to use the GNU bfd linker instead, but fpc doesn't use the LD environment variable (FreeBSD bug report https://bugs.freebsd.org/222172)
I reproduced the issue with an upstream checkout, which fails with:
...
gmake[6]: Leaving directory '/tank/emaste/src/freepascal/compiler/utils'
/bin/rm -rf x86_64/units
/bin/rm -f x86_64/.o x86_64/.ppu x86_64/.rst x86_64/.s x86_64/.a x86_64/.so x86_64/*.ppl
/bin/rm -f x86_64/ppc386 x86_64/ppc68k x86_64/ppcx64 x86_64/ppcppc x86_64/ppcsparc
/bin/rm -f x86_64/ppcppc64 x86_64/ppcarm x86_64/ppcmips x86_64/ppcmipsel x86_64/ppcjvm x86_64/ppc8086 x86_64/ppca64 x86_64/ppcx64
/bin/rm -f ppcx64
/usr/local/bin/gmkdir -p x86_64/units/x86_64-freebsd
/tank/emaste/src/freepascal/compiler/ppc1 -Ur -Xs -O2 -n -Fux86_64 -Fusystems -Fu/tank/emaste/src/freepascal/rtl/units/x86_64-freebsd -Fix86_64 -FE. -FUx86_64/units/x86_64-freebsd -Cg -dRELEASE -dx86_64 -dGDB -dBROWSERLOG -Fux86 -Sew pp.pas
/usr/bin/ld: error: /tank/emaste/src/freepascal/rtl/units/x86_64-freebsd/unicodenumtable.o: invalid alignment of section headers
pp.pas(264,1) Error: Error while linking
pp.pas(264,1) Fatal: There were 1 errors compiling module, stopping
Fatal: Compilation aborted
And indeed the unicodenumtable.o file has a misaligned section header:
% readelf -h rtl/units/x86_64-freebsd/unicodenumtable.o | grep 'section header'
Start of section headers: 1515 (bytes into file)
Size of section headers: 64 (bytes)
Number of section headers: 8
My bootstrap fpc is installed from the FreeBSD package:
Free Pascal Compiler version 3.0.2 [2017/12/10] for x86_64
Copyright (c) 1993-2017 by Florian Klaempfl and others
Fatal: No source file name in command line
Fatal: Compilation aborted
Error: /usr/local/bin/ppcx64 returned an error exitcode
Mantis conversion info:
- Mantis ID: 32900
- OS: FreeBSD
- OS Build: 11-stable
- Build: r37866
- Platform: amd64 (x86_64)
- Fixed in revision: 38251 (#9a136836)
- Monitored by: » acm (Alonso Cárdenas Márquez)