Skip to content

Conversation

amyspark
Copy link

Hi all,

This MR fixes an issue we observed in GStreamer when linking for Android x86:

Build log
FAILED: libopenh264.so 
/builds/tpm/cerbero/cb/android-ndk-25/toolchains/llvm/prebuilt/linux-x86_64/bin/clang++ -target i686-linux-android21 --sysroot /builds/tpm/cerbero/cb/android-ndk-25/toolchains/llvm/prebuilt/linux-x86_64/sysroot  -o libopenh264.so  -L/builds/tpm/cerbero/cb/dist/android_universal/x86/lib -L/builds/tpm/cerbero/cb/android-ndk-25/toolchains/llvm/prebuilt/linux-x86_64/sysroot/usr/lib/i686-linux-android/21 -Wl,--as-needed -Wl,--no-undefined -shared -fPIC -Wl,-soname,libopenh264.so -Wl,--whole-archive -Wl,--start-group codec/common/libcommon.a codec/processing/libprocessing.a codec/encoder/libencoder.a codec/decoder/libdecoder.a -Wl,--no-whole-archive -fPIC -no-canonical-prefixes -Wl,-no-undefined -Wl,-z,noexecstack -Wl,-z,relro -Wl,-z,now -Wl,--gc-sections -Wl,--warn-shared-textrel -Wl,-z,nocopyreloc -Wl,--sysroot=/builds/tpm/cerbero/cb/android-ndk-25/toolchains/llvm/prebuilt/linux-x86_64/sysroot -fuse-ld=lld -pthread -lm -Wl,--end-group
ld.lld: error: relocation R_386_32 cannot be used against local symbol; recompile with -fPIC
>>> defined in codec/common/libcommon.a(libcommon.a.p/dct.o)
>>> referenced by ../codec/common/x86/dct.asm
>>>               libcommon.a.p/dct.o:(.text+0x337) in archive codec/common/libcommon.a
ld.lld: error: relocation R_386_32 cannot be used against local symbol; recompile with -fPIC
>>> defined in codec/common/libcommon.a(libcommon.a.p/dct.o)
>>> referenced by ../codec/common/x86/dct.asm
>>>               libcommon.a.p/dct.o:(.text+0x34D) in archive codec/common/libcommon.a
ld.lld: error: relocation R_386_32 cannot be used against local symbol; recompile with -fPIC
>>> defined in codec/common/libcommon.a(libcommon.a.p/dct.o)
>>> referenced by ../codec/common/x86/dct.asm
>>>               libcommon.a.p/dct.o:(.text+0x355) in archive codec/common/libcommon.a
ld.lld: error: relocation R_386_32 cannot be used against local symbol; recompile with -fPIC
>>> defined in codec/common/libcommon.a(libcommon.a.p/dct.o)
>>> referenced by ../codec/common/x86/dct.asm
>>>               libcommon.a.p/dct.o:(.text+0x366) in archive codec/common/libcommon.a
ld.lld: error: relocation R_386_32 cannot be used against local symbol; recompile with -fPIC
>>> defined in codec/common/libcommon.a(libcommon.a.p/dct.o)
>>> referenced by ../codec/common/x86/dct.asm
>>>               libcommon.a.p/dct.o:(.text+0x37C) in archive codec/common/libcommon.a
ld.lld: error: relocation R_386_32 cannot be used against local symbol; recompile with -fPIC
>>> defined in codec/common/libcommon.a(libcommon.a.p/dct.o)
>>> referenced by ../codec/common/x86/dct.asm
>>>               libcommon.a.p/dct.o:(.text+0x384) in archive codec/common/libcommon.a
ld.lld: error: relocation R_386_32 cannot be used against local symbol; recompile with -fPIC
>>> defined in codec/common/libcommon.a(libcommon.a.p/dct.o)
>>> referenced by ../codec/common/x86/dct.asm
>>>               libcommon.a.p/dct.o:(.text+0x395) in archive codec/common/libcommon.a
ld.lld: error: relocation R_386_32 cannot be used against local symbol; recompile with -fPIC
>>> defined in codec/common/libcommon.a(libcommon.a.p/dct.o)
>>> referenced by ../codec/common/x86/dct.asm
>>>               libcommon.a.p/dct.o:(.text+0x3AB) in archive codec/common/libcommon.a
ld.lld: error: relocation R_386_32 cannot be used against local symbol; recompile with -fPIC
>>> defined in codec/common/libcommon.a(libcommon.a.p/dct.o)
>>> referenced by ../codec/common/x86/dct.asm
>>>               libcommon.a.p/dct.o:(.text+0x3B3) in archive codec/common/libcommon.a
ld.lld: error: relocation R_386_32 cannot be used against local symbol; recompile with -fPIC
>>> defined in codec/common/libcommon.a(libcommon.a.p/dct.o)
>>> referenced by ../codec/common/x86/dct.asm
>>>               libcommon.a.p/dct.o:(.text+0x3C4) in archive codec/common/libcommon.a
ld.lld: error: relocation R_386_32 cannot be used against local symbol; recompile with -fPIC
>>> defined in codec/common/libcommon.a(libcommon.a.p/dct.o)
>>> referenced by ../codec/common/x86/dct.asm
>>>               libcommon.a.p/dct.o:(.text+0x3DA) in archive codec/common/libcommon.a
ld.lld: error: relocation R_386_32 cannot be used against local symbol; recompile with -fPIC
>>> defined in codec/common/libcommon.a(libcommon.a.p/dct.o)
>>> referenced by ../codec/common/x86/dct.asm
>>>               libcommon.a.p/dct.o:(.text+0x3E2) in archive codec/common/libcommon.a
ld.lld: error: relocation R_386_32 cannot be used against local symbol; recompile with -fPIC
>>> defined in codec/common/libcommon.a(libcommon.a.p/dct.o)
>>> referenced by ../codec/common/x86/dct.asm
>>>               libcommon.a.p/dct.o:(.text+0x4AC) in archive codec/common/libcommon.a
ld.lld: error: relocation R_386_32 cannot be used against local symbol; recompile with -fPIC
>>> defined in codec/common/libcommon.a(libcommon.a.p/dct.o)
>>> referenced by ../codec/common/x86/dct.asm
>>>               libcommon.a.p/dct.o:(.text+0x4C2) in archive codec/common/libcommon.a
ld.lld: error: relocation R_386_32 cannot be used against local symbol; recompile with -fPIC
>>> defined in codec/common/libcommon.a(libcommon.a.p/dct.o)
>>> referenced by ../codec/common/x86/dct.asm
>>>               libcommon.a.p/dct.o:(.text+0x4CA) in archive codec/common/libcommon.a
ld.lld: error: relocation R_386_32 cannot be used against local symbol; recompile with -fPIC
>>> defined in codec/common/libcommon.a(libcommon.a.p/dct.o)
>>> referenced by ../codec/common/x86/dct.asm
>>>               libcommon.a.p/dct.o:(.text+0x4DB) in archive codec/common/libcommon.a
ld.lld: error: relocation R_386_32 cannot be used against local symbol; recompile with -fPIC
>>> defined in codec/common/libcommon.a(libcommon.a.p/dct.o)
>>> referenced by ../codec/common/x86/dct.asm
>>>               libcommon.a.p/dct.o:(.text+0x4F1) in archive codec/common/libcommon.a
ld.lld: error: relocation R_386_32 cannot be used against local symbol; recompile with -fPIC
>>> defined in codec/common/libcommon.a(libcommon.a.p/dct.o)
>>> referenced by ../codec/common/x86/dct.asm
>>>               libcommon.a.p/dct.o:(.text+0x4F9) in archive codec/common/libcommon.a
ld.lld: error: relocation R_386_32 cannot be used against local symbol; recompile with -fPIC
>>> defined in codec/common/libcommon.a(libcommon.a.p/dct.o)
>>> referenced by ../codec/common/x86/dct.asm
>>>               libcommon.a.p/dct.o:(.text+0x50A) in archive codec/common/libcommon.a
ld.lld: error: relocation R_386_32 cannot be used against local symbol; recompile with -fPIC
>>> defined in codec/common/libcommon.a(libcommon.a.p/dct.o)
>>> referenced by ../codec/common/x86/dct.asm
>>>               libcommon.a.p/dct.o:(.text+0x520) in archive codec/common/libcommon.a
ld.lld: error: too many errors emitted, stopping now (use -error-limit=0 to see all errors)
clang++: error: linker command failed with exit code 1 (use -v to see invocation)
ninja: build stopped: subcommand failed.

The fix is to extend #2611 to the Meson build system, and I added (as a failsafe) the two linker flags that x264 already uses to work around the same issue.

All feedback is appreciated.

@amyspark amyspark force-pushed the fix-meson-bstaticpic branch from 2a6ed6d to 8077206 Compare November 15, 2024 23:59
@brad0
Copy link
Contributor

brad0 commented Dec 29, 2024

From an OpenBSD perspective this looks pretty important.

@AndreiCherniaev
Copy link

Can you check your commit using x86 without SIMD like here? We should have openh264 which can be builded for i386...

@amyspark amyspark force-pushed the fix-meson-bstaticpic branch 3 times, most recently from 3b1cd8a to 1523262 Compare March 13, 2025 15:16
@amyspark
Copy link
Author

@AndreiCherniaev I believe that check is just not possible here, as the library forces pic: true without relying on b_staticpic.

@AndreiCherniaev
Copy link

@AndreiCherniaev I believe that check is just not possible here, as the library forces pic: true without relying on b_staticpic.

Can you help to fix meson build script to build openh264 with x86 without SIMD? Conversation

@amyspark amyspark force-pushed the fix-meson-bstaticpic branch from 1523262 to 53912b0 Compare June 17, 2025 14:26
@amyspark amyspark requested a review from nirbheek June 17, 2025 14:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants