Bug 233412

Summary: audio/deadbeef: links non-PIC code into shared obj, fails to link with lld
Product: Ports & Packages Reporter: Ed Maste <emaste>
Component: Individual Port(s)Assignee: Ed Maste <emaste>
Status: Closed FIXED    
Severity: Affects Only Me Flags: bugzilla: maintainer-feedback? (danfe)
Priority: ---    
Version: Latest   
Hardware: Any   
OS: Any   
Bug Depends on:    
Bug Blocks: 214864    

Description Ed Maste freebsd_committer 2018-11-22 20:32:16 UTC
lld defaults to disallowing relocations in readonly segments (i.e., it expects that code that is required to be built as PIC actually is). audio/deadbeef includes some asm in the shared obj that is not built as PIC, and as a result fails to link with lld.

The easiest workaround may be to add LDFLAGS_i386=-Wl,-z,notext to let lld create the relocation, assuming the port honours LDFLAGS. It may also be possible to set LLD_UNSAFE=yes in the Makefile to fall back to GNU ld. The best approach though would be to investigate and fix the non-PIC asm upstream.

/usr/bin/ld: error: can't create dynamic relocation R_386_32 against local symbol in readonly segment; recompile object files with -fPIC
>>> defined in .libs/dsputil_yasm.o
>>> referenced by dsputil_yasm.asm
>>>               .libs/dsputil_yasm.o:(.text+0x9DF)

/usr/bin/ld: error: can't create dynamic relocation R_386_32 against local symbol in readonly segment; recompile object files with -fPIC
>>> defined in .libs/dsputil_yasm.o
>>> referenced by dsputil_yasm.asm
>>>               .libs/dsputil_yasm.o:(.text+0x9E6)

/usr/bin/ld: error: can't create dynamic relocation R_386_32 against local symbol in readonly segment; recompile object files with -fPIC
>>> defined in .libs/dsputil_yasm.o
>>> referenced by dsputil_yasm.asm
>>>               .libs/dsputil_yasm.o:(.text+0x9ED)

/usr/bin/ld: error: can't create dynamic relocation R_386_32 against local symbol in readonly segment; recompile object files with -fPIC
>>> defined in .libs/dsputil_yasm.o
>>> referenced by dsputil_yasm.asm
>>>               .libs/dsputil_yasm.o:(.text+0xA60)

/usr/bin/ld: error: can't create dynamic relocation R_386_32 against local symbol in readonly segment; recompile object files with -fPIC
>>> defined in .libs/dsputil_yasm.o
>>> referenced by dsputil_yasm.asm
>>>               .libs/dsputil_yasm.o:(.text+0xA68)

/usr/bin/ld: error: can't create dynamic relocation R_386_32 against local symbol in readonly segment; recompile object files with -fPIC
>>> defined in .libs/dsputil_yasm.o
>>> referenced by dsputil_yasm.asm
>>>               .libs/dsputil_yasm.o:(.text+0xA70)

/usr/bin/ld: error: can't create dynamic relocation R_386_32 against local symbol in readonly segment; recompile object files with -fPIC
>>> defined in .libs/dsputil_yasm.o
>>> referenced by dsputil_yasm.asm
>>>               .libs/dsputil_yasm.o:(.text+0xA78)
cc: error: linker command failed with exit code 1 (use -v to see invocation)
Comment 1 commit-hook freebsd_committer 2019-01-08 14:06:43 UTC
A commit references this bug:

Author: emaste
Date: Tue Jan  8 14:06:18 UTC 2019
New revision: 489690
URL: https://svnweb.freebsd.org/changeset/ports/489690

Log:
  audio/deadbeef: add -znotext to LDFLAGS on i386, for lld

  This port links some non-PIC code, which fails with lld as it defaults
  to disallowing relocations against read-only segments. For i386 we can
  just add -znotext unconditionally: for GNU BFD ld it just affirms BFD's
  existing default.

  PR:		233412
  Approved by:	portmgr (lld blanket)
  Sponsored by:	The FreeBSD Foundation

Changes:
  head/audio/deadbeef/Makefile