aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGeorge Steed <george.steed@arm.com>2024-02-07 15:35:27 +0000
committerJames Zern <jzern@google.com>2024-02-13 19:48:14 +0000
commit5f16a838d3f2236d2473d95d78e882f6d89f81bc (patch)
tree47a56b24ee233b9cfe53e1d1988372660bec619c
parent80d175034c13f910002818c26f07f59f46d17336 (diff)
downloadlibaom-5f16a838d3f2236d2473d95d78e882f6d89f81bc.tar.gz
cpu.cmake: Fix AArch64 compiler flag tests
The existing check_c_compiler_flag test uses a regex internally to match against common error message strings in stderr from the compiler, however this does not match the "invalid feature modifier" error that is emitted by certain versions of GCC. This leads to the feature being incorrectly enabled only to then fail to compile the library later. To get around this, use the aom_check_source_compiles helper routine to compile a trivial program with the flag instead since this does not suffer the same problems and correctly identifies the features as being not available. Bug: aomedia:3543 Change-Id: I072281b2d3e986ee859ff8268bfad7a0fce3fd4c (cherry picked from commit faab48a3ab2a6b0061ff98b175032532e413b8b2)
-rw-r--r--build/cmake/cpu.cmake13
1 files changed, 12 insertions, 1 deletions
diff --git a/build/cmake/cpu.cmake b/build/cmake/cpu.cmake
index a9b7a6707..bd13d035d 100644
--- a/build/cmake/cpu.cmake
+++ b/build/cmake/cpu.cmake
@@ -26,8 +26,19 @@ if("${AOM_TARGET_CPU}" STREQUAL "arm64")
foreach(flavor ${ARM64_FLAVORS})
if(ENABLE_${flavor} AND NOT DEFINED AOM_${flavor}_FLAG)
set(AOM_${flavor}_FLAG "${AOM_${flavor}_DEFAULT_FLAG}")
+ string(TOLOWER "${flavor}" flavor_lower)
+
+ # Do not use check_c_compiler_flag here since the regex used to match
+ # against stderr does not recognise the "invalid feature modifier" error
+ # produced by certain versions of GCC, leading to the feature being
+ # incorrectly marked as available.
+ set(OLD_CMAKE_REQURED_FLAGS ${CMAKE_REQUIRED_FLAGS})
+ set(CMAKE_REQUIRED_FLAGS "${CMAKE_REQUIRED_FLAGS} ${AOM_${flavor}_FLAG}")
unset(FLAG_SUPPORTED)
- check_c_compiler_flag("${AOM_${flavor}_FLAG}" FLAG_SUPPORTED)
+ aom_check_source_compiles("arm_feature_flag_${flavor_lower}_available"
+ "static void function(void) {}" FLAG_SUPPORTED)
+ set(CMAKE_REQUIRED_FLAGS ${OLD_CMAKE_REQURED_FLAGS})
+
if(NOT ${FLAG_SUPPORTED})
set(ENABLE_${flavor} 0)
endif()