JonasVautherin
JonasVautherin

Reputation: 8033

"Relocation cannot be used against local symbol" only for one platform (x86)

Problem

I am cross-compiling gstreamer using Meson, and it works for 3 different platforms (android-arm, android-arm64, android-x86_64) but fails for android-x86 with errors like:

ld: error: relocation R_386_32 cannot be used against local symbol; recompile with -fPIC

I can't seem to understand which component was not built with -fPIC, and I don't understand why this would differ between the 4 platforms. If 3 are built with -fPIC, why would the fourth be different?

Details

More specifically, it fails with a bunch of the following errors:

FAILED: subprojects/FFmpeg/test_avcodec_utils
/usr/i686-linux-android/bin/clang  -o subprojects/FFmpeg/test_avcodec_utils subprojects/FFmpeg/test_avcodec_utils.p/libavcodec_tests_utils.c.o -Wl,--as-needed -Wl,--no-undefined -Wl,-O1 -pie -Wl,-Bsymbolic -fPIC -Wl,--start-group subprojects/FFmpeg/libavcodec-static.a subprojects/FFmpeg/libavutil.a subprojects/FFmpeg/libavutil-static.a subprojects/FFmpeg/libswresample.a subprojects/FFmpeg/libswresample-static.a -pthread -lm -lz -lz -Wl,--end-group
ld: error: relocation R_386_32 cannot be used against local symbol; recompile with -fPIC
>>> defined in subprojects/FFmpeg/libavcodec-static.a(libavcodec-static.a.p/dirac_dwt.o)
>>> referenced by x86util.asm:1315 (/work/build/android-x86/dependencies/gstreamer/gstreamer/src/gstreamer/subprojects/FFmpeg/libavutil/x86/x86util.asm:1315)
>>>               libavcodec-static.a.p/dirac_dwt.o:(.text+0x9F) in archive subprojects/FFmpeg/libavcodec-static.a

I essentially run $ meson setup --cross-file my-crossfile build . in a Dockcross container, with some options, so nothing special there as far as I can tell.

My cross-file looks like this (similar to the other 3 that work, except for cpu and cpu_family that differ):

[constants]
cross_triple = 'i686-linux-android'
cross_root = '/usr/' + cross_triple

[properties]
pkg_config_libdir = ''

[binaries]
c = cross_root + '/bin/clang'
cpp = cross_root + '/bin/clang++'
ar = cross_root + '/bin/llvm-ar'
as = cross_root + '/bin/llvm-as'
ranlib = cross_root + '/bin/llvm-ranlib'
ld = cross_root + '/bin/ld'
strip = cross_root + '/bin/llvm-strip'
pkgconfig = 'pkg-config'

[host_machine]
system = 'android'
cpu_family = 'x86'
cpu = 'i686'
endian = 'little'

Upvotes: 3

Views: 718

Answers (1)

JonasVautherin
JonasVautherin

Reputation: 8033

It turned out that -fPIC was not the problem, even though the linker said "recompile with -fPIC". It is actually an assembly issue on x86. Not sure if that is due to the architecture itself or the optimized (handwritten) assembly, but disabling the assembly optimizations (for both FFmpeg and dv) solved it.

In Meson, that means adding the following options when building gstreamer for x86:

-DFFmpeg:asm=disabled -Ddv:asm=disabled

Upvotes: 1

Related Questions