Bug 233740 - x11/pixman: LLD relocation errors on armv7
Summary: x11/pixman: LLD relocation errors on armv7
Status: Closed FIXED
Alias: None
Product: Ports & Packages
Classification: Unclassified
Component: Individual Port(s) (show other bugs)
Version: Latest
Hardware: arm Any
: --- Affects Some People
Assignee: freebsd-x11 (Nobody)
URL:
Keywords: needs-qa, toolchain
Depends on:
Blocks: 214864
  Show dependency treegraph
 
Reported: 2018-12-03 05:00 UTC by Charlie Li
Modified: 2020-07-11 20:12 UTC (History)
2 users (show)

See Also:
bugzilla: maintainer-feedback? (x11)
koobs: merge-quarterly?


Attachments
current workaround (452 bytes, patch)
2018-12-03 05:00 UTC, Charlie Li
no flags Details | Diff
LLD_REPRODUCE output from /head@342597 snapshot (845.41 KB, application/x-xz)
2019-01-29 15:38 UTC, Jan Beich
no flags Details

Note You need to log in before you can comment on or make changes to this bug.
Description Charlie Li freebsd_committer freebsd_triage 2018-12-03 05:00:37 UTC
Created attachment 199774 [details]
current workaround

Splitting from bug 233737.

On ARM (but not aarch64) with LLD_IS_LD, the SIMD and NEON bits fail to link:

--- libpixman-1.la ---
/bin/sh ../libtool  --tag=CC    --mode=link cc   -O2 -pipe  -fno-strict-aliasing  -Wall -Wdeclaration-after-statement -Wno-unused-local-typedefs -fno-strict-aliasing -fvisibility=hidden -version-info 34:0:34  -no-undefined   -pthread       -o  libpixman-1.la -rpath /usr/local/lib pixman.lo pixman-access.lo pixman-access-accessors.lo  pixman-bits-image.lo pixman-combine32.lo  pixman-combine-float.lo pixman-conical-gradient.lo  pixman-filter.lo pixman-x86.lo pixman-mips.lo pixman-arm.lo  pixman-ppc.lo pixman-edge.lo pixman-edge-accessors.lo  pixman-fast-path.lo pixman-glyph.lo pixman-general.lo  pixman-gradient-walker.lo pixman-image.lo  pixman-implementation.lo pixman-linear-gradient.lo  pixman-matrix.lo pixman-noop.lo pixman-radial-gradient.lo  pixman-region16.lo pixman-region32.lo pixman-solid-fill.lo  pixman-timer.lo pixman-trap.lo pixman-utils.lo  -lm   -lm       libpixman-arm-simd.la libpixman-arm-neon.la     -lm
libtool: link: cc -shared  -fPIC -DPIC  .libs/pixman.o .libs/pixman-access.o .libs/pixman-access-accessors.o .libs/pixman-bits-image.o .libs/pixman-combine32.o .libs/pixman-combine-float.o .libs/pixman-conical-gradient.o .libs/pixman-filter.o .libs/pixman-x86.o .libs/pixman-mips.o .libs/pixman-arm.o .libs/pixman-ppc.o .libs/pixman-edge.o .libs/pixman-edge-accessors.o .libs/pixman-fast-path.o .libs/pixman-glyph.o .libs/pixman-general.o .libs/pixman-gradient-walker.o .libs/pixman-image.o .libs/pixman-implementation.o .libs/pixman-linear-gradient.o .libs/pixman-matrix.o .libs/pixman-noop.o .libs/pixman-radial-gradient.o .libs/pixman-region16.o .libs/pixman-region32.o .libs/pixman-solid-fill.o .libs/pixman-timer.o .libs/pixman-trap.o .libs/pixman-utils.o  -Wl,--whole-archive ./.libs/libpixman-arm-simd.a ./.libs/libpixman-arm-neon.a -Wl,--no-whole-archive  -lm  -O2 -pthread   -pthread -Wl,-soname -Wl,libpixman-1.so.0 -o .libs/libpixman-1.so.0.34.0
/nxb-bin/usr/bin/ld: error: can't create dynamic relocation R_ARM_V4BX against local symbol in readonly segment; recompile object files with -fPIC
>>> defined in ./.libs/libpixman-arm-simd.a(pixman-arm-simd-asm-scaled.o)
>>> referenced by pixman-arm-simd-asm-scaled.o:(.text+0x1B8) in archive ./.libs/libpixman-arm-simd.a

/nxb-bin/usr/bin/ld: error: can't create dynamic relocation R_ARM_V4BX against local symbol in readonly segment; recompile object files with -fPIC
>>> defined in ./.libs/libpixman-arm-simd.a(pixman-arm-simd-asm-scaled.o)
>>> referenced by pixman-arm-simd-asm-scaled.o:(.text+0x374) in archive ./.libs/libpixman-arm-simd.a

/nxb-bin/usr/bin/ld: error: can't create dynamic relocation R_ARM_V4BX against local symbol in readonly segment; recompile object files with -fPIC
>>> defined in ./.libs/libpixman-arm-neon.a(pixman-arm-neon-asm.o)
>>> referenced by pixman-arm-neon-asm.o:(.text+0x17AC) in archive ./.libs/libpixman-arm-neon.a
/nxb-bin/usr/bin/ld: error: can't create dynamic relocation R_ARM_V4BX against local symbol in readonly segment; recompile object files with -fPIC
>>> defined in ./.libs/libpixman-arm-neon.a(pixman-arm-neon-asm.o)
>>> referenced by pixman-arm-neon-asm.o:(.text+0x1814) in archive ./.libs/libpixman-arm-neon.a
/nxb-bin/usr/bin/ld: error: can't create dynamic relocation R_ARM_V4BX against local symbol in readonly segment; recompile object files with -fPIC
>>> defined in ./.libs/libpixman-arm-neon.a(pixman-arm-neon-asm.o)
>>> referenced by pixman-arm-neon-asm.o:(.text+0x1A38) in archive ./.libs/libpixman-arm-neon.a

/nxb-bin/usr/bin/ld: error: can't create dynamic relocation R_ARM_V4BX against local symbol in readonly segment; recompile object files with -fPIC
>>> defined in ./.libs/libpixman-arm-neon.a(pixman-arm-neon-asm.o)
>>> referenced by pixman-arm-neon-asm.o:(.text+0x1AFC) in archive ./.libs/libpixman-arm-neon.a

/nxb-bin/usr/bin/ld: error: can't create dynamic relocation R_ARM_V4BX against local symbol in readonly segment; recompile object files with -fPIC
>>> defined in ./.libs/libpixman-arm-neon.a(pixman-arm-neon-asm.o)
>>> referenced by pixman-arm-neon-asm.o:(.text+0x21C8) in archive ./.libs/libpixman-arm-neon.a

/nxb-bin/usr/bin/ld: error: can't create dynamic relocation R_ARM_V4BX against local symbol in readonly segment; recompile object files with -fPIC
>>> defined in ./.libs/libpixman-arm-neon.a(pixman-arm-neon-asm.o)
>>> referenced by pixman-arm-neon-asm.o:(.text+0x2294) in archive ./.libs/libpixman-arm-neon.a

/nxb-bin/usr/bin/ld: error: can't create dynamic relocation R_ARM_V4BX against local symbol in readonly segment; recompile object files with -fPIC
>>> defined in ./.libs/libpixman-arm-neon.a(pixman-arm-neon-asm.o)
>>> referenced by pixman-arm-neon-asm.o:(.text+0x84E0) in archive ./.libs/libpixman-arm-neon.a

/nxb-bin/usr/bin/ld: error: can't create dynamic relocation R_ARM_V4BX against local symbol in readonly segment; recompile object files with -fPIC
>>> defined in ./.libs/libpixman-arm-neon.a(pixman-arm-neon-asm.o)
>>> referenced by pixman-arm-neon-asm.o:(.text+0x85C4) in archive ./.libs/libpixman-arm-neon.a

/nxb-bin/usr/bin/ld: error: can't create dynamic relocation R_ARM_V4BX against local symbol in readonly segment; recompile object files with -fPIC
>>> defined in ./.libs/libpixman-arm-neon.a(pixman-arm-neon-asm.o)
>>> referenced by pixman-arm-neon-asm.o:(.text+0x9720) in archive ./.libs/libpixman-arm-neon.a

/nxb-bin/usr/bin/ld: error: can't create dynamic relocation R_ARM_V4BX against local symbol in readonly segment; recompile object files with -fPIC
>>> defined in ./.libs/libpixman-arm-neon.a(pixman-arm-neon-asm.o)
>>> referenced by pixman-arm-neon-asm.o:(.text+0x9834) in archive ./.libs/libpixman-arm-neon.a

/nxb-bin/usr/bin/ld: error: can't create dynamic relocation R_ARM_V4BX against local symbol in readonly segment; recompile object files with -fPIC
>>> defined in ./.libs/libpixman-arm-neon.a(pixman-arm-neon-asm.o)
>>> referenced by pixman-arm-neon-asm.o:(.text+0xA7B0) in archive ./.libs/libpixman-arm-neon.a

/nxb-bin/usr/bin/ld: error: can't create dynamic relocation R_ARM_V4BX against local symbol in readonly segment; recompile object files with -fPIC
>>> defined in ./.libs/libpixman-arm-neon.a(pixman-arm-neon-asm.o)
>>> referenced by pixman-arm-neon-asm.o:(.text+0xA8CC) in archive ./.libs/libpixman-arm-neon.a

/nxb-bin/usr/bin/ld: error: can't create dynamic relocation R_ARM_V4BX against local symbol in readonly segment; recompile object files with -fPIC
>>> defined in ./.libs/libpixman-arm-neon.a(pixman-arm-neon-asm.o)
>>> referenced by pixman-arm-neon-asm.o:(.text+0x105A0) in archive ./.libs/libpixman-arm-neon.a

/nxb-bin/usr/bin/ld: error: can't create dynamic relocation R_ARM_V4BX against local symbol in readonly segment; recompile object files with -fPIC
>>> defined in ./.libs/libpixman-arm-neon.a(pixman-arm-neon-asm.o)
>>> referenced by pixman-arm-neon-asm.o:(.text+0x10DB8) in archive ./.libs/libpixman-arm-neon.a

/nxb-bin/usr/bin/ld: error: can't create dynamic relocation R_ARM_V4BX against local symbol in readonly segment; recompile object files with -fPIC
>>> defined in ./.libs/libpixman-arm-neon.a(pixman-arm-neon-asm.o)
>>> referenced by pixman-arm-neon-asm.o:(.text+0x11274) in archive ./.libs/libpixman-arm-neon.a

/nxb-bin/usr/bin/ld: error: can't create dynamic relocation R_ARM_V4BX against local symbol in readonly segment; recompile object files with -fPIC
>>> defined in ./.libs/libpixman-arm-neon.a(pixman-arm-neon-asm.o)
>>> referenced by pixman-arm-neon-asm.o:(.text+0x11808) in archive ./.libs/libpixman-arm-neon.a

/nxb-bin/usr/bin/ld: error: can't create dynamic relocation R_ARM_V4BX against local symbol in readonly segment; recompile object files with -fPIC
>>> defined in ./.libs/libpixman-arm-neon.a(pixman-arm-neon-asm-bilinear.o)
>>> referenced by pixman-arm-neon-asm-bilinear.o:(.text+0x4F0) in archive ./.libs/libpixman-arm-neon.a

/nxb-bin/usr/bin/ld: error: can't create dynamic relocation R_ARM_V4BX against local symbol in readonly segment; recompile object files with -fPIC
>>> defined in ./.libs/libpixman-arm-neon.a(pixman-arm-neon-asm-bilinear.o)
>>> referenced by pixman-arm-neon-asm-bilinear.o:(.text+0xABC) in archive ./.libs/libpixman-arm-neon.a

/nxb-bin/usr/bin/ld: error: too many errors emitted, stopping now (use -error-limit=0 to see all errors)
cc: error: linker command failed with exit code 1 (use -v to see invocation)
*** [libpixman-1.la] Error code 1

make[3]: stopped in /wrkdirs/usr/ports/x11/pixman/work/pixman-0.34.0/pixman
1 error

make[3]: stopped in /wrkdirs/usr/ports/x11/pixman/work/pixman-0.34.0/pixman
*** [all-recursive] Error code 1

make[2]: stopped in /wrkdirs/usr/ports/x11/pixman/work/pixman-0.34.0
1 error

make[2]: stopped in /wrkdirs/usr/ports/x11/pixman/work/pixman-0.34.0
*** [all] Error code 2

make[1]: stopped in /wrkdirs/usr/ports/x11/pixman/work/pixman-0.34.0
1 error

make[1]: stopped in /wrkdirs/usr/ports/x11/pixman/work/pixman-0.34.0

-fPIC was already passed by default, and LDFLAGS+=-Wl,z,notest results in the same error with a slightly different message of "unrecognised reloc 40".

A workaround is to disable SIMD and NEON for armv6 and armv7.
Comment 1 Jan Beich freebsd_committer freebsd_triage 2018-12-03 08:26:14 UTC
Can you share full build log, preferably from poudriere as it records environment variables, make.conf contents, etc?

I can't reproduce on
- 12.0 armv7 (clang/lld 6): https://ptpb.pw/zgax
- 13.0 armv7 (clang/lld 7): https://ptpb.pw/xFAe

and so can't pkg-fallout@:
- 12.0 armv7: http://www.ipv6proxy.net/go.php?u=http://beefy13.nyi.freebsd.org/data/latest-per-pkg/pixman/0.34.0/120armv7-quarterly.log
- 13.0 armv7: http://www.ipv6proxy.net/go.php?u=http://beefy16.nyi.freebsd.org/data/latest-per-pkg/pixman/0.34.0/head-armv7-default.log
Comment 2 Jan Beich freebsd_committer freebsd_triage 2018-12-03 08:33:12 UTC
According to src.conf(5) WITH_LLD_IS_LD is default only on armv7 (since 12.0, its first release) but not arm (v4?) or armv6.

https://svnweb.freebsd.org/changeset/base/337899
Comment 3 Charlie Li freebsd_committer freebsd_triage 2018-12-03 10:00:38 UTC
It appears that despite having devel/binutils as a build dependency, clang -no-integrated-as actually uses the base binutils as. Having WITHOUT_BINUTILS set has the build falling back to the devel/binutils as, which does not emit any assembler messages like base binutils as does (lots of register alias redefinitions ignored).

Looks like devel/binutils as is doing something fishy.
Comment 4 Jan Beich freebsd_committer freebsd_triage 2018-12-03 10:28:34 UTC
(In reply to Charlie Li from comment #3)
> It appears that despite having devel/binutils as a build dependency, clang
> -no-integrated-as actually uses the base binutils as.

Indeed. In bug 221814 mmel@ dropped COMPILER_PATH without making sure GNU as(1) from devel/binutils is actually used.

> the devel/binutils as, which does not emit any assembler messages
> like base binutils as does (lots of register alias redefinitions ignored).

Agree. Those warnings are worth fixing.

> Looks like devel/binutils as is doing something fishy.

I'm not sure. When adding -Wl,-z,notext the error message changes

  /usr/bin/ld: error: ./.libs/libpixman-arm-simd.a(pixman-arm-simd-asm-scaled.o):(.text+0x1B8): unrecognized reloc 40

which suggests there maybe a bug in LLD.
Comment 5 commit-hook freebsd_committer freebsd_triage 2018-12-03 10:48:45 UTC
A commit references this bug:

Author: jbeich
Date: Mon Dec  3 10:47:50 UTC 2018
New revision: 486510
URL: https://svnweb.freebsd.org/changeset/ports/486510

Log:
  x11/pixman: actually use GNU as from devel/binutils

  ./pixman-arm-simd-asm.h:695: Warning: ignoring redefinition of register alias 'wk4'
  ./pixman-arm-neon-asm.h:941: Warning: ignoring redefinition of register alias 'dst_w'
  ./pixman-arm-neon-asm.h:702: Warning: ignoring redefinition of register alias 'orig_w'
  pixman-arm-neon-asm-bilinear.S:612: Warning: ignoring redefinition of register alias 'top'

  PR:		221814 233740
  Reported by:	Charlie Li
  Approved by:	portmgr blanket

Changes:
  head/x11/pixman/Makefile
Comment 6 commit-hook freebsd_committer freebsd_triage 2018-12-03 10:48:47 UTC
A commit references this bug:

Author: jbeich
Date: Mon Dec  3 10:48:06 UTC 2018
New revision: 486511
URL: https://svnweb.freebsd.org/changeset/ports/486511

Log:
  x11/pixman: mark as LLD_UNSAFE

  /usr/bin/ld: error: can't create dynamic relocation R_ARM_V4BX against local symbol in readonly segment; recompile object files with -fPIC
  >>> defined in ./.libs/libpixman-arm-simd.a(pixman-arm-simd-asm-scaled.o)
  >>> referenced by pixman-arm-simd-asm-scaled.o:(.text+0x1B8) in archive ./.libs/libpixman-arm-simd.a

  PR:		233740
  Reported by:	Charlie Li
  Approved by:	portmgr blanket

Changes:
  head/x11/pixman/Makefile
Comment 7 Ed Maste freebsd_committer freebsd_triage 2018-12-03 17:31:06 UTC
The error from LLD comes from linking non-PIC asm into a shared object. A possible workaround is to add -Wl,-znotext to LDFLAGS instead of setting LLD_UNSAFE, which allows relocations in readonly segments (which GNU ld does by default).
Comment 8 Charlie Li freebsd_committer freebsd_triage 2018-12-04 00:53:56 UTC
(In reply to Ed Maste from comment #7)
LDFLAGS+=-Wl,z,notext still does not work with port binutils as(1), as shown in comment 4.
Comment 9 Ed Maste freebsd_committer freebsd_triage 2018-12-04 16:28:43 UTC
(In reply to Charlie Li from comment #8)
Indeed, sorry I missed that.

> unrecognized reloc 40

Interesting that lld reports the offending relocation (R_ARM_V4BX) w/o -znotext, but just 'reloc 40' with.

If convenient can you set LLD_REPRODUCE=pixman.tar in the environment and try building the failing case? That will leave a reproduction tarball behind that can be used to further investigate lld's handling of this.

(In reply to Jan Beich from comment #2)
> According to src.conf(5) WITH_LLD_IS_LD is default only on armv7 (since 12.0,
> its first release) but not arm (v4?) or armv6.

Indeed - arm (v4/v5) and armv6 need some additional support in lld that arrived after the 6.0 release. Once we have Clang & lld 7.0 in the tree we should be able to test with WITH_LLD_IS_LD for arm & armv6 as well.
Comment 10 Jan Beich freebsd_committer freebsd_triage 2019-01-29 15:38:47 UTC
Created attachment 201509 [details]
LLD_REPRODUCE output from /head@342597 snapshot

(In reply to Ed Maste from comment #9)
> If convenient can you set LLD_REPRODUCE=pixman.tar ...

LLD 8.0 is not affected but if clang800-import doesn't make it into FreeBSD 11.3/12.1 ...
Comment 11 Ed Maste freebsd_committer freebsd_triage 2020-06-08 23:29:36 UTC
stable/11 and stable/12 have received Clang/LLVM updates - is this resolved now?
Comment 12 Niclas Zeising freebsd_committer freebsd_triage 2020-07-11 20:12:01 UTC
This is believed to be fixed in currently supported versions of FreeBSD.  Please re-open the PR if this is still an issue.