Re: Internal linker error from pkg-fallout on 14.0-CURRENT on i386

From: Dimitry Andric <dim_at_FreeBSD.org>
Date: Tue, 21 Feb 2023 09:54:07 UTC
On 20 Feb 2023, at 20:33, Kevin Zheng <kevinz5000@gmail.com> wrote:
> 
> At least two of my ports recently started to fail to build on 14.0-CURRENT on i386 as reported by pkg-fallout with messages like:
> 
> internal linker error: wrote incorrect addend value 0x5000406A instead of 0x0 for dynamic relocation R_386_32 at offset 0x410DD3 against symbol __gxx_personality_v0
> 
> ld: error: clientgame.o:(function _GLOBAL__sub_I_clientgame.cpp: .text+0x7543): internal linker error: wrote incorrect addend value 0xCC48300 instead of 0x0 for dynamic relocation R_386_32 at offset 0x4FDED3 against symbol __gxx_personality_v0
> 
> I searched Bugzilla for "internal linker error" but was unable to find any existing reports. Is this a known issue and I'm just bad at searching, or is this something I should report (and where?)

Bugzilla search is just very bad, so it's not you. :-)

This typically turns up for ports on i386 that use -z notext in their
linker flags, to work around text relocation issues. See also
<https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=268495> and
<https://cgit.freebsd.org/ports/commit/?id=145ca5487348>.

As of lld 15 the linker checks dynamic relocations more strictly, and
unfortunately the maintainers turned these "incorrect addend" messages
into internal errors instead of warnings (at least when lld is compiled
with assertions enabled).

Meanwhile, I have been informed that these diagnostics are actually
quite harmless, and can be ignored. To suppress them, the linker flags
should include --no-check-dynamic-relocations.

Similar to audio/openal-soft, this should look something like:

  .include <bsd.port.pre.mk>

  .if ${COMPILER_TYPE} == "clang" && ${COMPILER_VERSION} >= 150
  LDFLAGS_i386+=  -Wl,--no-check-dynamic-relocations
  .endif

  # ... other stuff ...

  .include <bsd.port.post.mk>

-Dimitry