ports head -r487783: on armv7 x11/pixman fails to build: /usr/bin/ld: error: can't create dynamic relocation R_ARM_V4BX against local symbol in readonly segment; recompile object files with -fPIC
Mark Millard
marklmi at yahoo.com
Wed Nov 14 22:36:07 UTC 2018
[Looking at package fallout logs: the official armv6 and armv7
builds are using -O2 because of MACHINE_ARCH being defined
because of qemu-user-static use. (mips too?) The logic in
share/mk/sys.mk is not causing -O . An implication
is that -O2 for armv6 and armv7 is probably far more tested
than people generally expect. The share/mk/sys.mk change
goes back to -r319861 2017-Jun-12 . Previously the logic
would have caused -O use for armv6 or armv7 in MACHINE_ARCH .]
On 2018-Nov-14, at 13:51, Mark Millard <marklmi at yahoo.com> wrote:
> [Tracking down -O2 vs. -O lead to share/mk/sys.mk instead of
> to my materials. It in turn leads back to poudriere-devel with
> qemu-user-static in use defining MACHINE_ARCH but without it
> instead not doing so. share/mk/sys.mk behaves differently
> for with vs. without the definition, leading to -O2 vs -O
> differences in the two build contexts. Details later below.]
>
> On 2018-Nov-14, at 13:05, Mark Millard <marklmi at yahoo.com> wrote:
>
>> [Added: The original cross-build via poudriere-devel and qemu-user-static
>> did not get this problem. I give details later. Sumamry: Looks like -O2
>> was used for the cross build and -O was used for armv7 native. The
>> difference is likely(?) from my materials but not supporting both ways of
>> building is likely a problem with the port(?).]
>>
>> On 2018-Nov-14, at 10:10, Mark Millard <marklmi at yahoo.com> wrote:
>>
>>> I'll first note:
>>>
>>> # /usr/bin/ld -v
>>> LLD 6.0.1 (FreeBSD 335540-1300000) (compatible with GNU linkers)
>>>
>>> and that I use:
>>>
>>> CFLAGS.clang+= -mcpu=cortex-a7
>>> CXXFLAGS.clang+= -mcpu=cortex-a7
>>> CPPFLAGS.clang+= -mcpu=cortex-a7
>>>
>>> in the src.conf like ~/src.configs/src.conf.armv7-clang-bootstrap.armv7-host
>>> file that I used.
>>>
>>> The error reports were:
>>>
>>> --- libpixman-1.la ---
>>> /bin/sh ../libtool --tag=CC --mode=link cc -O -pipe -mcpu=cortex-a7 -g -fno-strict-aliasing -Wall -Wdeclaration-after-statement -Wno-unused-local-typedefs -fno-strict-aliasing -fvisibility=hid
>>> den -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 pixm
>>> an-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-r
>>> egion32.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/pixma
>>> n-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 -O -mcpu=cortex-a7 -g -pthread -pthread -Wl,-soname -Wl,libpixman-1.so.0 -o .libs/libpixman-1.so.0.34.0
>>> /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
>>>
>>> /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
>>>
>>> /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
>>>
>>> /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
>>>
>>> /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
>>>
>>> /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
>>>
>>> /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
>>>
>>> /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
>>>
>>> /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
>>>
>>> /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
>>>
>>> /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
>>>
>>> /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
>>>
>>> /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
>>>
>>> /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
>>>
>>> /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
>>> /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
>>>
>>> /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
>>> /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
>>> /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
>>>
>>> /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
>>>
>>> /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
>>>
>>>
>>> FreeBSD context details:
>>>
>>> # uname -apKU
>>> FreeBSD OPiP2E 13.0-CURRENT FreeBSD 13.0-CURRENT #5 r340287M: Sat Nov 10 22:40:25 PST 2018 markmi at FBSDFSSD:/usr/obj/armv7_clang/arm.armv7/usr/src/arm.armv7/sys/GENERIC-NODBG arm armv7 1300003 1300003
>>
>>
>> I went back and looked at the amd64 -> armv7 cross-build
>> ( that used teh poudriere-built /nxb-bin/usr/bin/ ) and it
>> did not complain:
>>
>> --- libpixman-1.la ---
>> /bin/sh ../libtool --tag=CC --mode=link /nxb-bin/usr/bin/cc -O2 -pipe -mcpu=cortex-a7 -g -fno-strict-aliasing -Wall -Wdeclaration-after-statement -Wno-unused-local-typedefs -fno-strict-aliasing -fvisibility=hidden -version-info 34:0:34 -no-undefined -Wl,--no-threads -pthread -Wl,--no-threads -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: /nxb-bin/usr/bin/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 -mcpu=cortex-a7 -g -Wl,--no-threads -pthread -Wl,--no-threads -pthread -Wl,-soname -Wl,libpixman-1.so.0 -o .libs/libpixman-1.so.0.34.0
>> libtool: link: (cd ".libs" && rm -f "libpixman-1.so.0" && ln -s "libpixman-1.so.0.34.0" "libpixman-1.so.0")
>> libtool: link: (cd ".libs" && rm -f "libpixman-1.so" && ln -s "libpixman-1.so.0.34.0" "libpixman-1.so")
>> libtool: link: (cd .libs/libpixman-1.lax/libpixman-arm-simd.a && ar x "/wrkdirs/usr/ports/x11/pixman/work/pixman-0.34.0/pixman/./.libs/libpixman-arm-simd.a")
>> libtool: link: (cd .libs/libpixman-1.lax/libpixman-arm-neon.a && ar x "/wrkdirs/usr/ports/x11/pixman/work/pixman-0.34.0/pixman/./.libs/libpixman-arm-neon.a")
>> libtool: link: ar cru .libs/libpixman-1.a pixman.o pixman-access.o pixman-access-accessors.o pixman-bits-image.o pixman-combine32.o pixman-combine-float.o pixman-conical-gradient.o pixman-filter.o pixman-x86.o pixman-mips.o pixman-arm.o pixman-ppc.o pixman-edge.o pixman-edge-accessors.o pixman-fast-path.o pixman-glyph.o pixman-general.o pixman-gradient-walker.o pixman-image.o pixman-implementation.o pixman-linear-gradient.o pixman-matrix.o pixman-noop.o pixman-radial-gradient.o pixman-region16.o pixman-region32.o pixman-solid-fill.o pixman-timer.o pixman-trap.o pixman-utils.o .libs/libpixman-1.lax/libpixman-arm-simd.a/pixman-arm-simd-asm-scaled.o .libs/libpixman-1.lax/libpixman-arm-simd.a/pixman-arm-simd-asm.o .libs/libpixman-1.lax/libpixman-arm-simd.a/pixman-arm-simd.o .libs/libpixman-1.lax/libpixman-arm-neon.a/pixman-arm-neon-asm-bilinear.o .libs/libpixman-1.lax/libpixman-arm-neon.a/pixman-arm-neon-asm.o .libs/libpixman-1.lax/libpixman-arm-neon.a/pixman-arm-neon.o
>> libtool: link: ranlib .libs/libpixman-1.a
>> libtool: link: rm -fr .libs/libpixman-1.lax
>> libtool: link: ( cd ".libs" && rm -f "libpixman-1.la" && ln -s "../libpixman-1.la" "libpixman-1.la" )
>> ===========================================================================
>> =======================<phase: run-depends >============================
>> ===========================================================================
>> =======================<phase: stage >============================
>> . . .
>>
>>
>> So I diff'd the logs and found the following (selective extraction):
>> (- for amd64 -> armv7; + for armv7)
>>
>> -Poudriere version: 3.2.99.20180601
>> +Poudriere version: 3.2.99.20181024
>>
>> This is was expected but may mean that I need to wait
>> until the armv7 has 3.2.99.20181024 and I try via
>> it.
>>
>> -SHELL=/bin/csh
>> -UNAME_p=armv7
>> -UNAME_m=arm
>> -ABI_FILE=/usr/lib/crt1.o
>> +SHELL=/bin/sh
>>
>> The SHELL's I expected but the other 3 lines I did not.
>> But the 3 lines may only occur under qemu-user-static
>> style use.
>>
>> -QEMU_EMULATING=1
>>
>> Expected.
>>
>> In CONFIGURE_ENV:
>>
>> amd64 -> armv7: CCASFLAGS having -O2
>> armv7: CCASFLAGS having -O
>>
>> In MAKE_ENV:
>>
>> amd64 -> armv7: CFLAGS having -O2
>> armv7: CFLAGS having -O
>>
>>
>> (The -O2 vs. -O context differences may well be important
>> to the behavior.)
>>
>> (I'll not list /nxb-bin/. . . path use vs. not.)
>>
>> Later:
>>
>> -MACHINE=arm
>> -MACHINE_ARCH=armv7
>> -ARCH=${MACHINE_ARCH}
>>
>> -.if ${LDFLAGS:M-fuse-ld=*lld*} || ${/usr/bin/ld:L:tA} == /usr/bin/ld.lld
>> -LDFLAGS+= -Wl,--no-threads
>> -.endif
>>
>> (That last was part of an experiment with avoiding a
>> user-arm-static hangup.)
>>
>> -_SMP_CPUS=28
>> +_SMP_CPUS=4
>>
>> I'll stop with that. It looks to me like -O2 vs. -O
>> would be the likely distinction. While my materials
>> probably caused that difference(?), the port likely
>> should support both ways of building(?).
>
>
> /usr/src/share/mk/sys.mk has:
>
> .if !defined(%POSIX)
> #
> # MACHINE_CPUARCH defines a collection of MACHINE_ARCH. Machines with
> # the same MACHINE_ARCH can run each other's binaries, so it necessarily
> # has word size and endian swizzled in. However, the source files for
> # these machines often are shared amongst all combinations of size
> # and/or endian. This is called MACHINE_CPU in NetBSD, but that's used
> # for something different in FreeBSD.
> #
> __TO_CPUARCH=C/mips(n32|64)?(el)?(hf)?/mips/:C/arm(v[67])?(eb)?/arm/:C/powerpc(64|spe)/powerpc/:C/riscv64(sf)?/riscv/
> MACHINE_CPUARCH=${MACHINE_ARCH:${__TO_CPUARCH}}
> .endif
> . . .
> .if ${MACHINE_CPUARCH} == "arm" || ${MACHINE_CPUARCH} == "mips"
> CFLAGS ?= -O -pipe
> .else
> CFLAGS ?= -O2 -pipe
> .endif
> . . .
>
> So with qemu-user-static involved MACHINE_ARCH was defined as armv7
> and MACHINE_CPUARCH was too. (See the earlier "-MACHINE_ARCH=armv7"
> line of the log differences.)
>
> But without qemu-user-static involved MACHINE_ARCH was not defined
> and MACHINE_CPUARCH was defined as just arm . (No "+" line to
> match.)
>
> Overall result: the two contexts differ for -O2 vs. -O use in CFLAGS.
I looked at some logs associated with:
https://lists.freebsd.org/pipermail/freebsd-pkg-fallout/Week-of-Mon-20181112/thread.html
and the builds for armv6 and armv7 show MACHINE_ARCH defined and -O2
use.
The logic in share/mk/sys.mk is not causing -O for official builds
--unlike what happens on a self/native-hosted build of the arm*
ports. (mips* possibly has the same issue.)
So -O2 has been used far more than folks probably expect
and -O2 is far more tested than expected.
The share/mk/sys.mk change goes back to -r319861 2017-Jun-12 .
Previously the logic would have caused -O use for armv6 and
armv7 in MACHINE_ARCH.
===
Mark Millard
marklmi at yahoo.com
( dsl-only.net went
away in early 2018-Mar)
More information about the freebsd-x11
mailing list