The SVE(2) compilation tests change CMAKE_TRY_COMPILE_TARGET_TYPE to
STATIC_LIBRARY, which results in the C compiler linker options in
CMAKE_REQUIRED_LINK_OPTIONS being passed to the archiver. This causes
these tests to always fail when libnuma is enabled, as invalid linker
options are passed to the archiver. Fix this by saving, clearing, and
restoring CMAKE_REQUIRED_LINK_OPTIONS for the compilation tests.

See CMake issue:
https://gitlab.kitware.com/cmake/cmake/-/issues/23454
---
 source/CMakeLists.txt | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/source/CMakeLists.txt b/source/CMakeLists.txt
index f39bcc5c4..37dbe1a87 100755
--- a/source/CMakeLists.txt
+++ b/source/CMakeLists.txt
@@ -311,6 +311,11 @@ if(GCC)
             string(APPEND CMAKE_REQUIRED_FLAGS " ${AARCH64_SVE_FLAG}")
             set(OLD_CMAKE_TRY_COMPILE_TARGET_TYPE 
${CMAKE_TRY_COMPILE_TARGET_TYPE})
             set(CMAKE_TRY_COMPILE_TARGET_TYPE STATIC_LIBRARY)
+            # When compilation target is a STATIC_LIBRARY, the LINK_OPTIONS are
+            # passed to the archiver, so we must backup, clear and restore 
these.
+            # https://gitlab.kitware.com/cmake/cmake/-/issues/23454
+            set(OLD_CMAKE_REQUIRED_LINK_OPTIONS ${CMAKE_REQUIRED_LINK_OPTIONS})
+            set(CMAKE_REQUIRED_LINK_OPTIONS "")
 
             # Check whether the compiler can compile SVE functions that require
             # backup/restore of SVE registers according to AAPCS.
@@ -340,6 +345,7 @@ int main() { return 0; }")
 
             set(CMAKE_REQUIRED_FLAGS ${OLD_CMAKE_REQUIRED_FLAGS})
             set(CMAKE_TRY_COMPILE_TARGET_TYPE 
${OLD_CMAKE_TRY_COMPILE_TARGET_TYPE})
+            set(CMAKE_REQUIRED_LINK_OPTIONS ${OLD_CMAKE_REQUIRED_LINK_OPTIONS})
             if (SVE_COMPILATION_C_TEST_COMPILED AND 
SVE_COMPILATION_CXX_TEST_COMPILED)
                 if (SVE_HEADER_C_TEST_COMPILED AND 
SVE_HEADER_CXX_TEST_COMPILED)
                     add_definitions(-DHAVE_SVE_BRIDGE=1)
-- 
2.42.1

>From 1a6ae00352fb7659ec12b67dff2fddafa9ac4546 Mon Sep 17 00:00:00 2001
From: Hari Limaye <hari.lim...@arm.com>
Date: Mon, 6 Jan 2025 09:51:26 +0000
Subject: [PATCH] AArch64: Fix SVE(2) compilation tests when libnuma is enabled

The SVE(2) compilation tests change CMAKE_TRY_COMPILE_TARGET_TYPE to
STATIC_LIBRARY, which results in the C compiler linker options in
CMAKE_REQUIRED_LINK_OPTIONS being passed to the archiver. This causes
these tests to always fail when libnuma is enabled, as invalid linker
options are passed to the archiver. Fix this by saving, clearing, and
restoring CMAKE_REQUIRED_LINK_OPTIONS for the compilation tests.

See CMake issue:
https://gitlab.kitware.com/cmake/cmake/-/issues/23454
---
 source/CMakeLists.txt | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/source/CMakeLists.txt b/source/CMakeLists.txt
index f39bcc5c4..37dbe1a87 100755
--- a/source/CMakeLists.txt
+++ b/source/CMakeLists.txt
@@ -311,6 +311,11 @@ if(GCC)
             string(APPEND CMAKE_REQUIRED_FLAGS " ${AARCH64_SVE_FLAG}")
             set(OLD_CMAKE_TRY_COMPILE_TARGET_TYPE ${CMAKE_TRY_COMPILE_TARGET_TYPE})
             set(CMAKE_TRY_COMPILE_TARGET_TYPE STATIC_LIBRARY)
+            # When compilation target is a STATIC_LIBRARY, the LINK_OPTIONS are
+            # passed to the archiver, so we must backup, clear and restore these.
+            # https://gitlab.kitware.com/cmake/cmake/-/issues/23454
+            set(OLD_CMAKE_REQUIRED_LINK_OPTIONS ${CMAKE_REQUIRED_LINK_OPTIONS})
+            set(CMAKE_REQUIRED_LINK_OPTIONS "")
 
             # Check whether the compiler can compile SVE functions that require
             # backup/restore of SVE registers according to AAPCS.
@@ -340,6 +345,7 @@ int main() { return 0; }")
 
             set(CMAKE_REQUIRED_FLAGS ${OLD_CMAKE_REQUIRED_FLAGS})
             set(CMAKE_TRY_COMPILE_TARGET_TYPE ${OLD_CMAKE_TRY_COMPILE_TARGET_TYPE})
+            set(CMAKE_REQUIRED_LINK_OPTIONS ${OLD_CMAKE_REQUIRED_LINK_OPTIONS})
             if (SVE_COMPILATION_C_TEST_COMPILED AND SVE_COMPILATION_CXX_TEST_COMPILED)
                 if (SVE_HEADER_C_TEST_COMPILED AND SVE_HEADER_CXX_TEST_COMPILED)
                     add_definitions(-DHAVE_SVE_BRIDGE=1)
-- 
2.42.1

_______________________________________________
x265-devel mailing list
x265-devel@videolan.org
https://mailman.videolan.org/listinfo/x265-devel

Reply via email to