[FFmpeg-trac] #9612(undetermined:new): --enable-pic flag doesn't affect the object files from assembly
FFmpeg
trac at avcodec.org
Tue Jan 25 01:58:04 EET 2022
#9612: --enable-pic flag doesn't affect the object files from assembly
-------------------------------------+-------------------------------------
Reporter: Tuğrul | Type: defect
Status: new | Priority: normal
Component: | Version:
undetermined | unspecified
Keywords: | Blocked By:
Blocking: | Reproduced by developer: 0
Analyzed by developer: 0 |
-------------------------------------+-------------------------------------
Summary of the bug:
I was trying to link a shared library to use with Node.JS.
It was failing for following error message.
{{{
/usr/bin/ld: libavcodec.a(cavsdsp.o): relocation R_X86_64_PC32 against
symbol `ff_pw_5' can not be used when making a shared object; recompile
with -fPIC
}}}
Then I tried to use '''--disable-asm''' and it built successfully.
How to reproduce:
== Build with asm and no asm versions of static libraries.
=== With asm:
{{{
% make clean && ./configure --prefix="/tmp/deploy-asm" --pkg-config-
flags="--static" --extra-cflags="-fPIC" --extra-libs="-lpthread -lm"
--enable-gpl --enable-nonfree --disable-doc --enable-pic && make && make
install
}}}
=== Without asm:
{{{
% make clean && ./configure --prefix="/tmp/deploy-no-asm" --pkg-config-
flags="--static" --extra-cflags="-fPIC" --extra-libs="-lpthread -lm"
--enable-gpl --enable-nonfree --disable-doc --enable-pic --disable-asm &&
make && make install
}}}
== Combine static libraries into a shared library
=== With asm:
{{{
% cd /tmp/deploy-asm/lib && gcc -shared -o libav-combined.so -Wl,--whole-
archive libavcodec.a libavdevice.a libavfilter.a libavformat.a libavutil.a
libpostproc.a libswresample.a libswscale.a -Wl,--no-whole-archive
}}}
Gives following error:
{{{
/usr/bin/ld: libavcodec.a(cavsdsp.o): relocation R_X86_64_PC32 against
symbol `ff_pw_5' can not be used when making a shared object; recompile
with -fPIC
/usr/bin/ld: final link failed: bad value
collect2: error: ld returned 1 exit status
}}}
=== Without asm:
{{{
% cd /tmp/deploy-no-asm/lib && gcc -shared -o libav-combined.so -Wl
,--whole-archive libavcodec.a libavdevice.a libavfilter.a libavformat.a
libavutil.a libpostproc.a libswresample.a libswscale.a -Wl,--no-whole-
archive
}}}
It is successfully linked.
I'm not expert but I'm able to imagine the problem by this Q&A
https://stackoverflow.com/questions/38192735/generating-position-
independent-code-with-gas-fpic
--
Ticket URL: <https://trac.ffmpeg.org/ticket/9612>
FFmpeg <https://ffmpeg.org>
FFmpeg issue tracker
More information about the FFmpeg-trac
mailing list