Fix sub-architecture (instruction sets / SIMD) handling
In qmake there are at least 2 things to know regarding
sub-architectures and instruction sets.
Which instruction sets does the compiler know to compile for,
represented by the various config.tests and features in
qtbase/configure.json.
And which instructions sets are enabled by the compiler by default,
represented by the configure.json "architecture" test and accessed
via QT_CPU_FEATURES.$$arch qmake argument.
Before this patch there was some mishandling of the above concepts
in CMake code.
The former can now be checked in CMake with via TEST_subarch_foo and
QT_FEATURE_foo (where foo is sse2, etc).
The latter can now be checked by
TEST_arch_${TEST_architecture_arch}_subarch_foo
(where foo is sse2, etc and the main arch is dynamyicall evaluated).
The configurejson2cmake script was adjusted to take care of the above
changes, and the cmake files were regenerated as well.
Change-Id: Ifbf558242e320cafae50da388eee56fa5de2a50c
Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
bb10
parent
25f67fbb07
commit
ba7c62eed5
|
|
@ -39,7 +39,8 @@ function(run_config_test_architecture)
|
|||
set(TEST_architecture_arch "${_architecture}" CACHE INTERNAL "Target machine architecture")
|
||||
set(TEST_subarch 1 CACHE INTERNAL "Ran machine subArchitecture test")
|
||||
foreach(it ${_sub_architecture})
|
||||
set(TEST_subarch_${it} 1 CACHE INTERNAL "Target sub architecture result")
|
||||
# Equivalent to qmake's QT_CPU_FEATURES.$arch.
|
||||
set(TEST_arch_${TEST_architecture_arch}_subarch_${it} 1 CACHE INTERNAL "Target sub architecture result")
|
||||
endforeach()
|
||||
set(TEST_buildAbi "${_build_abi}" CACHE INTERNAL "Target machine buildAbi")
|
||||
endfunction()
|
||||
|
|
|
|||
|
|
@ -4,12 +4,20 @@ project(x86_simd LANGUAGES CXX)
|
|||
include(../../cmake/QtPlatformSupport.cmake)
|
||||
include(../../cmake/QtCompilerOptimization.cmake)
|
||||
|
||||
# FIXME: Make the this project handle a list of SIMD entries.
|
||||
# FIXME: Make this project handle appending of the cflags (similar to the qmake project).
|
||||
# This is needed for the x86SimdAlways configure test (
|
||||
# aka we test to see if setting no SIMD (-msse2) cflags at all, will result in their implicit
|
||||
# addition by the compiler).
|
||||
string(TOUPPER "${SIMD}" upper_simd)
|
||||
|
||||
if(NOT DEFINED "QT_CFLAGS_${upper_simd}")
|
||||
message(FATAL_ERROR "This compiler does not support ${SIMD}.")
|
||||
# Don't use CMake error() because a configure error also fails the try_compile() call.
|
||||
# Instead use a compile flag that doesn't exist to force a compiler error.
|
||||
set(QT_CFLAGS_${upper_simd} "--qt-cflags-not-found")
|
||||
endif()
|
||||
|
||||
add_executable("SimdTest${SIMD}")
|
||||
target_sources("SimdTest${SIMD}" PRIVATE main.cpp)
|
||||
target_compile_options("SimdTest${SIMD}" PRIVATE ${QT_CFLAGS_${upper_simd}})
|
||||
target_compile_definitions("SimdTest${SIMD}" PRIVATE QT_COMPILER_SUPPORTS_${upper_simd})
|
||||
|
|
|
|||
|
|
@ -336,17 +336,17 @@ qt_feature("x86SimdAlways"
|
|||
qt_feature_definition("x86SimdAlways" "QT_COMPILER_SUPPORTS_SIMD_ALWAYS" VALUE "1")
|
||||
qt_feature("mips_dsp"
|
||||
LABEL "DSP"
|
||||
CONDITION ( TEST_architecture_arch STREQUAL mips ) AND TEST_subarch_dsp
|
||||
CONDITION ( TEST_architecture_arch STREQUAL mips ) AND TEST_arch_${TEST_architecture_arch}_subarch_dsp
|
||||
)
|
||||
qt_feature_definition("mips_dsp" "QT_COMPILER_SUPPORTS_MIPS_DSP" VALUE "1")
|
||||
qt_feature("mips_dspr2"
|
||||
LABEL "DSPr2"
|
||||
CONDITION ( TEST_architecture_arch STREQUAL mips ) AND TEST_subarch_dspr2
|
||||
CONDITION ( TEST_architecture_arch STREQUAL mips ) AND TEST_arch_${TEST_architecture_arch}_subarch_dspr2
|
||||
)
|
||||
qt_feature_definition("mips_dspr2" "QT_COMPILER_SUPPORTS_MIPS_DSPR2" VALUE "1")
|
||||
qt_feature("neon"
|
||||
LABEL "NEON"
|
||||
CONDITION ( ( TEST_architecture_arch STREQUAL arm ) OR ( TEST_architecture_arch STREQUAL arm64 ) ) AND TEST_subarch_neon
|
||||
CONDITION ( ( TEST_architecture_arch STREQUAL arm ) OR ( TEST_architecture_arch STREQUAL arm64 ) ) AND TEST_arch_${TEST_architecture_arch}_subarch_neon
|
||||
)
|
||||
qt_feature_definition("neon" "QT_COMPILER_SUPPORTS_NEON" VALUE "1")
|
||||
qt_feature("alloca_h" PRIVATE
|
||||
|
|
|
|||
|
|
@ -117,7 +117,7 @@ def map_tests(test: str) -> str:
|
|||
'c99': '$<COMPILE_FEATURES:c_std_99>',
|
||||
'c11': '$<COMPILE_FEATURES:c_std_11>',
|
||||
|
||||
'x86SimdAlways': 'ON', # FIXME: Is this the right thing?
|
||||
'x86SimdAlways': 'ON', # FIXME: Make this actually do a compile test.
|
||||
|
||||
'aesni': 'TEST_subarch_aes',
|
||||
'avx': 'TEST_subarch_avx',
|
||||
|
|
@ -333,7 +333,8 @@ def map_condition(condition):
|
|||
substitution = 'QT_FEATURE_{}'.format(featureName(match.group(2)))
|
||||
|
||||
elif match.group(1) == 'subarch':
|
||||
substitution = 'TEST_subarch_{}'.format(match.group(2))
|
||||
substitution = 'TEST_arch_{}_subarch_{}'.format("${TEST_architecture_arch}",
|
||||
match.group(2))
|
||||
|
||||
elif match.group(1) == 'call':
|
||||
if match.group(2) == 'crossCompile':
|
||||
|
|
|
|||
Loading…
Reference in New Issue