From b9bdd54f69bcc704c12ec013f0f03cfcfe91d3b1 Mon Sep 17 00:00:00 2001 From: captainurist <73941350+captainurist@users.noreply.github.com> Date: Tue, 19 Sep 2023 10:01:56 +0800 Subject: [PATCH] Add -Bsymbolic --- CMakeLists.txt | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/CMakeLists.txt b/CMakeLists.txt index f29747b5b9a0..b1fe814d08ef 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -147,6 +147,15 @@ elseif(BUILD_COMPILER STREQUAL "msvc") endif() endif() +# When statically linking to ffmpeg, we're getting linker errors like this one: +# relocation R_386_32 cannot be used against local symbol; recompile with -fPIC +# And I was unable to figure out how to fix these at the ffmpeg side. The errors pop up when building for Android, and +# when linking with lld on Linux for x86. So we use this workaround: +# https://github.com/google/ExoPlayer/issues/9933#issuecomment-1029775358. +if(OE_USE_PREBUILT_DEPENDENCIES AND (BUILD_PLATFORM STREQUAL "android" OR BUILD_PLATFORM STREQUAL "linux")) + add_link_options("-Wl,-Bsymbolic") +endif() + resolve_dependencies() add_subdirectory(thirdparty)