[x265] [PATCH 5/6] AArch64: Comply with ENABLE_PIC option when compiling

Hari Limaye hari.limaye at arm.com
Thu Oct 24 23:29:52 UTC 2024


We currently pass `-fPIC` unconditionally when compiling for AArch64,
meaning there is no way to disable position independent code generation.

Fix this by making the addition of `-fPIC` to ARM_ARGS conditional on
the value of ENABLE_PIC, and make ENABLE_PIC=ON the default on AArch64.
---
 source/CMakeLists.txt | 12 ++++++------
 1 file changed, 6 insertions(+), 6 deletions(-)

diff --git a/source/CMakeLists.txt b/source/CMakeLists.txt
index b311c350e..fe9e6c9da 100755
--- a/source/CMakeLists.txt
+++ b/source/CMakeLists.txt
@@ -154,11 +154,11 @@ if(UNIX)
     endif()
 endif(UNIX)
 
-if(X64 AND NOT WIN32)
+if((X64 AND NOT WIN32) OR ARM64)
     option(ENABLE_PIC "Enable Position Independent Code" ON)
 else()
     option(ENABLE_PIC "Enable Position Independent Code" OFF)
-endif(X64 AND NOT WIN32)
+endif()
 
 # Compiler detection
 if(CMAKE_GENERATOR STREQUAL "Xcode")
@@ -398,7 +398,7 @@ int main() { return 0; }")
             message(STATUS "Found SVE2")
             add_definitions(-DHAVE_SVE2=1)
         endif()
-        set(ARM_ARGS -O3 -fPIC)
+        set(ARM_ARGS -O3)
         # Do not allow implicit vector type conversions in Clang builds (this
         # is already the default in GCC builds).
         check_cxx_compiler_flag(-flax-vector-conversions=none CC_HAS_FLAX_VEC_CONV_NONE)
@@ -406,9 +406,9 @@ int main() { return 0; }")
             set(ARM_ARGS ${ARM_ARGS} -flax-vector-conversions=none)
         endif()
     endif()
-	if(ENABLE_PIC)
-	list(APPEND ARM_ARGS -DPIC)
-	endif()
+    if(ENABLE_PIC)
+        list(APPEND ARM_ARGS -DPIC -fPIC)
+    endif()
     add_definitions(${ARM_ARGS})
     if(FPROFILE_GENERATE)
         if(INTEL_CXX)
-- 
2.42.1

-------------- next part --------------
A non-text attachment was scrubbed...
Name: 0005-AArch64-Comply-with-ENABLE_PIC-option-when-compiling.patch
Type: text/x-patch
Size: 2108 bytes
Desc: not available
URL: <http://mailman.videolan.org/pipermail/x265-devel/attachments/20241025/c29b09f3/attachment-0001.bin>


More information about the x265-devel mailing list