Bug 233413 - lld does not accept -format arg used by lazarus build system
Summary: lld does not accept -format arg used by lazarus build system
Status: Closed FIXED
Alias: None
Product: Base System
Classification: Unclassified
Component: bin (show other bugs)
Version: CURRENT
Hardware: i386 Any
: --- Affects Only Me
Assignee: freebsd-bugs (Nobody)
URL:
Keywords:
Depends on:
Blocks: 214864
  Show dependency treegraph
 
Reported: 2018-11-22 20:45 UTC by Ed Maste
Modified: 2019-09-03 15:56 UTC (History)
4 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Ed Maste freebsd_committer freebsd_triage 2018-11-22 20:45:04 UTC

    
Comment 1 Ed Maste freebsd_committer freebsd_triage 2018-11-22 20:50:05 UTC
(Accidentally submitted early)

See PR 214864; on i386 many ports failed to build with lld with an error like:

(9022) Compiling resource cqrlog.or
(9015) Linking cqrlog
/usr/bin/ld: error: unknown -format value: elf32-i386-freebsd (supported formats: elf, default, binary) <<<<<
/wrkdirs/usr/ports/comms/cqrlog/work-gtk2/cqrlog-2.3.0/src/cqrlog.lpr(82,1) Error: (9013) Error while linking
/wrkdirs/usr/ports/comms/cqrlog/work-gtk2/cqrlog-2.3.0/src/cqrlog.lpr(82,1) Fatal: (10026) There were 1 errors compiling module, stopping
Fatal: (1018) Compilation aborted
Error: /usr/local/bin/ppc386 returned an error exitcode
Error: (lazarus) Compile Project, Target: cqrlog: stopped with exit code 256
Error: (lazbuild) failed compiling of project /wrkdirs/usr/ports/comms/cqrlog/work-gtk2/cqrlog-2.3.0/src/cqrlog.lpi

comms/cqrlog
editors/picpas
graphics/lazpaint
multimedia/winff
net-p2p/awgg
net-p2p/transmission-remote-gui
russian/emkatic
science/checkmol
science/mol2ps
x11-fm/doublecmd
cad/zcad
archivers/peazip
Comment 2 Ed Maste freebsd_committer freebsd_triage 2018-11-22 21:26:26 UTC
acm@, presumably lld ought to accept "--format elf32-i386-freebsd", but do you think it is feasible to have the build system avoid passing this argument? AFAICT it is only these ports built by lazarus that encounter this issue.
Comment 3 Jose Alonso Cardenas Marquez freebsd_committer freebsd_triage 2018-11-22 21:50:30 UTC
Could you apply the following patch file to lang/fpc and test again?

--- compiler/systems/t_bsd.pas.orig      2018-11-22 16:45:56.427850000 -0500
+++ compiler/systems/t_bsd.pas   2018-11-22 16:46:52.149911000 -0500
@@ -652,7 +652,7 @@

   if target_info.system=system_i386_freebsd then
     begin
-      targetstr:='-b elf32-i386-freebsd';
+      targetstr:='-b elf';
       emulstr:='-m elf_i386_fbsd';
     end
   else
@@ -801,12 +801,12 @@
     else
       GCSectionsStr:='-dead_strip -no_dead_strip_inits_and_terms';

-  { i386_freebsd needs -b elf32-i386-freebsd and -m elf_i386_fbsd
+  { i386_freebsd needs -b elf and -m elf_i386_fbsd
     to avoid creation of a i386:x86_64 arch binary }

   if target_info.system=system_i386_freebsd then
     begin
-      targetstr:='-b elf32-i386-freebsd';
+      targetstr:='-b elf';
       emulstr:='-m elf_i386_fbsd';
     end
   else
Comment 4 Ed Maste freebsd_committer freebsd_triage 2018-11-26 21:12:27 UTC
(In reply to Jose Alonso Cardenas Marquez from comment #3)
Thank you for the patch, I will try to test it shortly.

I did find that lld has more extensive format support in its linker script parsing, so presumably command-line -format arguments could be handled the same way.
Comment 5 Ed Maste freebsd_committer freebsd_triage 2018-11-26 21:30:58 UTC
It looks like "elf32-i386-freebsd" is also baked into the binary bootstrap compiler.

I see that this port is setting LLD_UNSAFE=yes, so shouldn't be invoking lld anyway; there's more to investigate here.  During experimentation I tried the patch above with LLD_UNSAFE removed, and that prompts a warning from GNU ld (binutils port) that -format elf is unknown.
Comment 6 commit-hook freebsd_committer freebsd_triage 2019-01-15 20:53:30 UTC
A commit references this bug:

Author: thierry
Date: Tue Jan 15 20:52:34 UTC 2019
New revision: 490402
URL: https://svnweb.freebsd.org/changeset/ports/490402

Log:
  Set LLD_UNSAFE.

  PR:		233413
  Reported by:	emaste

Changes:
  head/multimedia/winff/Makefile
Comment 7 Ed Maste freebsd_committer freebsd_triage 2019-01-30 15:03:16 UTC
dim added support for FreeBSD-specific BFD names to lld's OUTPUT_FORMAT handling (https://reviews.llvm.org/D57283), so "elf32-i386-freebsd" will now be accepted there. We need to extend that work to -b / --format.
Comment 8 Ed Maste freebsd_committer freebsd_triage 2019-07-24 19:31:34 UTC
lld has been enabled as system linker for i386 on stable/12 in advance of 12.1 (as of a few minutes ago)

I believe this PR is the main issue that needs to be addressed still before 12.1
Comment 9 Jose Alonso Cardenas Marquez freebsd_committer freebsd_triage 2019-08-15 19:19:45 UTC
I have committed new changes to lang/fpc and editors/lazarus ports. Please, see it at:

https://svnweb.freebsd.org/ports?view=revision&revision=509004
https://svnweb.freebsd.org/ports?view=revision&revision=509005
https://svnweb.freebsd.org/ports?view=revision&revision=509007

It doesn't work with lld and maybe will not work on short time. We must be use binutils from base or from ports and change LDPATH into fpc/Makefile to ld.bfd path. Also I have regenerated fpc bootstrap (i386 and amd64) . It should be work only with COMPAT_FREEBSD11 added to kernel config on 12.X+ (COMPAT from 4 to 10 should not be necessary)

I have removed LD_UNSAFE because now we can set LDPATH to a working linker (It works with ld.bfd from base or installed from binutils port)
Comment 10 Kurt Jaeger freebsd_committer freebsd_triage 2019-09-02 19:30:38 UTC
With the same patch as for lang/fpc, lazarus builds on current
Comment 11 Jose Alonso Cardenas Marquez freebsd_committer freebsd_triage 2019-09-03 05:53:05 UTC
Please, look at https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=240293. It fixes build on i386. I'll commit changes after of exp-run passed without problems
Comment 12 commit-hook freebsd_committer freebsd_triage 2019-09-03 15:53:01 UTC
A commit references this bug:

Author: acm
Date: Tue Sep  3 15:52:00 UTC 2019
New revision: 510956
URL: https://svnweb.freebsd.org/changeset/ports/510956

Log:
  - Rebuild bootstrap (ppcx64 and ppc386) with ld patches
  - Fix build on 12-STABLE and CURRENT (amd64 and i386)
  - Bump PORTREVISION for all ports that depends of lang/fpc
  - Add USE_BINUTILS to fpc and lazarus based ports
  - Add binutils dependency to Uses/fpc.mk and Uses/lazarus.mk

  PR:		240293 239934 233413 214864
  Exp-run by:	antoine

Changes:
  head/Mk/Uses/fpc.mk
  head/Mk/Uses/lazarus.mk
  head/archivers/peazip/Makefile
  head/archivers/peazip/pkg-plist
  head/cad/zcad/Makefile
  head/comms/cqrlog/Makefile
  head/databases/fpc-fpindexer/Makefile
  head/databases/fpc-gdbm/Makefile
  head/databases/fpc-ibase/Makefile
  head/databases/fpc-postgres/Makefile
  head/devel/fpc-fcl-db/Makefile
  head/devel/fpc-fcl-js/Makefile
  head/devel/fpc-fcl-json/Makefile
  head/devel/fpc-fcl-passrc/Makefile
  head/devel/fpc-fcl-pdf/Makefile
  head/devel/fpc-fcl-sdo/Makefile
  head/devel/fpc-fcl-stl/Makefile
  head/devel/fpc-fcl-web/Makefile
  head/devel/fpc-fppkg/Makefile
  head/devel/fpc-sdl/Makefile
  head/editors/cudatext/Makefile
  head/editors/lazarus/Makefile
  head/editors/picpas/Makefile
  head/games/hedgewars/Makefile
  head/graphics/fpc-imagemagick/Makefile
  head/graphics/lazpaint/Makefile
  head/lang/fpc/Makefile
  head/lang/fpc/distinfo
  head/lang/fpc/files/patch-compiler_systems_t__bsd.pas
  head/lang/fpc-base/Makefile
  head/lang/fpc-rtl-objpas/Makefile
  head/lang/fpc-source/Makefile
  head/lang/fpc-utils/Makefile
  head/lang/nbc/Makefile
  head/multimedia/fpc-libvlc/Makefile
  head/multimedia/winff/Makefile
  head/net-p2p/awgg/Makefile
  head/net-p2p/transmission-remote-gui/Makefile
  head/russian/emkatic/Makefile
  head/science/checkmol/Makefile
  head/science/mol2ps/Makefile
  head/www/fpc-googleapi/Makefile
  head/x11/fpc-x11/Makefile
  head/x11-fm/doublecmd/Makefile
Comment 13 Jose Alonso Cardenas Marquez freebsd_committer freebsd_triage 2019-09-03 15:56:46 UTC
fpc/lazarus ports will use binutils from ports. I think that lld will not supported in short time but now we can set LDPATH if it is supported later