Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[ffmpeg] build without PIC #31185

Open
talregev opened this issue Apr 29, 2023 · 9 comments
Open

[ffmpeg] build without PIC #31185

talregev opened this issue Apr 29, 2023 · 9 comments
Assignees
Labels
category:question This issue is a question

Comments

@talregev
Copy link
Contributor

talregev commented Apr 29, 2023

Operating system

wsl2 ubuntu 22.04

Compiler

gcc

Steps to reproduce the behavior

./vcpkg install ffmpeg
readelf --relocs installed/x64-linux/lib/libavcodec.a  | awk '{print $3}' | sort -u | grep R_X86_64

tested on ffmpeg 5.1.2.

Failure logs

When I run the command:

R_X86_64_32
R_X86_64_64
R_X86_64_GOTPCREL
R_X86_64_PC32
R_X86_64_PLT32
R_X86_64_REX_GOTP

It has the line R_X86_64_32 that tell it compile without PIC even with the flag --enable-pic that already set on the port.

Additional context

When I compile with shared the output of the command:

R_X86_64_64
R_X86_64_GLOB_DAT
R_X86_64_JUMP_SLO
R_X86_64_RELATIVE

Tested on ffmpeg 5.1.2.
Not sure how to fix it.
Not sure if the same happen on the ffmpeg 6.0.

@talregev talregev added the category:port-bug The issue is with a library, which is something the port should already support label Apr 29, 2023
@Cheney-W Cheney-W self-assigned this May 4, 2023
@Cheney-W
Copy link
Contributor

This issue could be reproduced with the latest vcpkg 2023-04-07-bedcba5172f5e4b91caac660ab7afe92c27a9895.

vxincwa@vxincwa-linux:~/cheney$ readelf --relocs installed/x64-linux/lib/libavcodec.a  | awk '{print $3}' | sort -u | grep R_X86_64
R_X86_64_32
R_X86_64_64
R_X86_64_GOTPCREL
R_X86_64_PC32
R_X86_64_PLT32
R_X86_64_REX_GOTP

@talregev
Copy link
Contributor Author

It still relevant.

@dg0yt
Copy link
Contributor

dg0yt commented Nov 13, 2023

Given the recent OpenSSL experience, I would suspect some (upstream) assembler code to not be relocatable. PIC compiler flags change asm generation from upstream C code, but they won't affect what is already written in assembler. You can build with PIC flags but still get binaries which are nor relocatable.

@dg0yt
Copy link
Contributor

dg0yt commented Mar 26, 2024

Hitting rtabmap, #37651.

@Vinayak-YB
Copy link

Hey people, I'm still facing the relocation issue with ffmpeg (specifically libavcodec) . Any solution ?

@dg0yt
Copy link
Contributor

dg0yt commented Mar 27, 2024

Not a port bug, although reported repeatedly.

Other than the the message suggests, the compiler is run with -fPIC.
But this doesn't affect the code which isn't compiled (to assembler) but written in assember.

The error occurs due to wrong usage:
When using the static ffmpeg binaries in shared libs, it is expected to use -Bsymbolic linker flags (or -Wl,-Bsymbolic).

Cf. #17292 (comment), #19273 (comment).

@Cheney-W Cheney-W added category:question This issue is a question and removed category:port-bug The issue is with a library, which is something the port should already support labels Mar 27, 2024
@Vinayak-YB
Copy link

Hi @dg0yt Thanks a lot. This helped resolve my error

@talregev
Copy link
Contributor Author

@dg0yt Where do you put the -Bsymbolic?
On ffmpeg or on the lib that consume it?

@dg0yt
Copy link
Contributor

dg0yt commented Mar 27, 2024

On the consumer.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
category:question This issue is a question
Projects
None yet
Development

No branches or pull requests

4 participants