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
diff --git a/build/cmake/cpu.cmake b/build/cmake/cpu.cmake index a9b7a67..bd13d03 100644 --- a/build/cmake/cpu.cmake +++ b/build/cmake/cpu.cmake
@@ -26,8 +26,19 @@ 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()