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

Hari Limaye hari.limaye at arm.com
Wed Nov 6 15:37:11 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 4205db40e..5c1ae2359 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: v2-0005-AArch64-Comply-with-ENABLE_PIC-option-when-compil.patch
Type: text/x-patch
Size: 2055 bytes
Desc: not available
URL: <http://mailman.videolan.org/pipermail/x265-devel/attachments/20241106/fb0aee25/attachment.bin>


More information about the x265-devel mailing list