[Bug 261668] bsd.port.mk: Correct usage of -fuse-ld=bfd

From: <bugzilla-noreply_at_freebsd.org>
Date: Tue, 01 Feb 2022 22:52:46 UTC
https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=261668

            Bug ID: 261668
           Summary: bsd.port.mk: Correct usage of -fuse-ld=bfd
           Product: Ports & Packages
           Version: Latest
          Hardware: Any
                OS: Any
            Status: New
          Severity: Affects Some People
          Priority: ---
         Component: Ports Framework
          Assignee: portmgr@FreeBSD.org
          Reporter: eugen@freebsd.org
                CC: ports-bugs@FreeBSD.org

Created attachment 231512
  --> https://bugs.freebsd.org/bugzilla/attachment.cgi?id=231512&action=edit
Correct usage of -fuse-ld=bfd

bsd.ports.mk has this:

if defined(LLD_UNSAFE) && ${/usr/bin/ld:L:tA} == /usr/bin/ld.lld
LDFLAGS+=      -fuse-ld=bfd
BINARY_ALIAS+= ld=${LD}
 .  if !defined(USE_BINUTILS)
...

The line with LDFLAGS should be moved just after ".if !defined(USE_BINUTILS)"
or else build fails for a software that defines USE_BINUTILS and LLD_UNSAFE for
sake of "-plugin" option of a linker not supported by ld.bfd.

Actual example is the port editors/libreoffice version 7.2.5.2 built with
non-default port option LTO enabled that is broken at the moment due to several
issues. One of them is this problem in the bsd.ports.mk that cannot be solved
within port itself.

Trivial fix is attached.

-- 
You are receiving this mail because:
You are on the CC list for the bug.