diff options
author | Alexandru Croitor <alexandru.croitor@qt.io> | 2019-03-21 13:14:09 +0100 |
---|---|---|
committer | Alexandru Croitor <alexandru.croitor@qt.io> | 2019-03-21 17:47:01 +0000 |
commit | ba7c62eed53b2304c54643cbddc29db887fcd869 (patch) | |
tree | d2d91e7c3489c576569df8f7aafb97fdace0952e | |
parent | 25f67fbb073c8bedf26e165f52abacf3e20a6a94 (diff) |
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>
-rw-r--r-- | cmake/QtBaseConfigureTests.cmake | 3 | ||||
-rw-r--r-- | config.tests/x86_simd/CMakeLists.txt | 10 | ||||
-rw-r--r-- | configure.cmake | 6 | ||||
-rwxr-xr-x | util/cmake/configurejson2cmake.py | 5 |
4 files changed, 17 insertions, 7 deletions
diff --git a/cmake/QtBaseConfigureTests.cmake b/cmake/QtBaseConfigureTests.cmake index b79a1e3839..5a345cbc3c 100644 --- a/cmake/QtBaseConfigureTests.cmake +++ b/cmake/QtBaseConfigureTests.cmake @@ -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() diff --git a/config.tests/x86_simd/CMakeLists.txt b/config.tests/x86_simd/CMakeLists.txt index b213cf10fc..b624b7bc95 100644 --- a/config.tests/x86_simd/CMakeLists.txt +++ b/config.tests/x86_simd/CMakeLists.txt @@ -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}) diff --git a/configure.cmake b/configure.cmake index c12b7d3b87..a62a746916 100644 --- a/configure.cmake +++ b/configure.cmake @@ -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 diff --git a/util/cmake/configurejson2cmake.py b/util/cmake/configurejson2cmake.py index fe2bf50eaa..eb3fd606fe 100755 --- a/util/cmake/configurejson2cmake.py +++ b/util/cmake/configurejson2cmake.py @@ -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': |