openh264 icon indicating copy to clipboard operation
openh264 copied to clipboard

build: Add missing flags for x86 asm support

Open amyspark opened this issue 1 year ago • 4 comments

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 https://github.com/cisco/openh264/pull/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 avatar Nov 13 '24 21:11 amyspark

From an OpenBSD perspective this looks pretty important.

brad0 avatar Dec 29 '24 16:12 brad0

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

AndreiCherniaev avatar Mar 13 '25 07:03 AndreiCherniaev

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

amyspark avatar Mar 13 '25 15:03 amyspark

@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

AndreiCherniaev avatar Mar 14 '25 03:03 AndreiCherniaev