diff --git a/cmake/QtFeature.cmake b/cmake/QtFeature.cmake index f7765cea94..5002a53352 100644 --- a/cmake/QtFeature.cmake +++ b/cmake/QtFeature.cmake @@ -1,4 +1,5 @@ include(QtFeatureCommon) +include(CheckCXXCompilerFlag) function(qt_feature_module_begin) qt_parse_all_arguments(arg "qt_feature_module_begin" @@ -870,6 +871,16 @@ function(qt_config_compile_test_machine_tuple label) set(TEST_machine_tuple "${output}" CACHE INTERNAL "${label}") endfunction() +function(qt_config_compiler_supports_flag_test name) + if(DEFINED "TEST_${name}") + return() + endif() + + cmake_parse_arguments(arg "" "LABEL;FLAG" "" ${ARGN}) + check_cxx_compiler_flag("${arg_FLAG}" TEST_${name}) + set(TEST_${name} "${TEST_${name}}" CACHE INTERNAL "${label}") +endfunction() + function(qt_make_features_available target) if(NOT "${target}" MATCHES "^${QT_CMAKE_EXPORT_NAMESPACE}::[a-zA-Z0-9_-]*$") message(FATAL_ERROR "${target} does not match ${QT_CMAKE_EXPORT_NAMESPACE}::[a-zA-Z0-9_-]*. INVALID NAME.") diff --git a/cmake/QtProcessConfigureArgs.cmake b/cmake/QtProcessConfigureArgs.cmake index 743e8e3eb7..9a6370cca2 100644 --- a/cmake/QtProcessConfigureArgs.cmake +++ b/cmake/QtProcessConfigureArgs.cmake @@ -96,6 +96,7 @@ defstub(qt_add_qmake_lib_dependency) defstub(qt_config_compile_test) defstub(qt_config_compile_test_machine_tuple) defstub(qt_config_compile_test_x86simd) +defstub(qt_config_compiler_supports_flag_test) defstub(qt_configure_add_report_entry) defstub(qt_configure_add_summary_build_mode) defstub(qt_configure_add_summary_build_parts) diff --git a/configure.cmake b/configure.cmake index f56047b14c..0fb01ef4fb 100644 --- a/configure.cmake +++ b/configure.cmake @@ -110,6 +110,26 @@ int main(int argc, char **argv) "# FIXME: qmake: ['CONFIG += precompile_header', 'PRECOMPILED_DIR = .pch', 'PRECOMPILED_HEADER = header.h'] ) +qt_config_compiler_supports_flag_test(use_bfd_linker + LABEL "bfd linker" + FLAG "-fuse-ld=bfd" +) + +qt_config_compiler_supports_flag_test(use_gold_linker + LABEL "gold linker" + FLAG "-fuse-ld=gold" +) + +qt_config_compiler_supports_flag_test(use_lld_linker + LABEL "lld linker" + FLAG "-fuse-ld=lld" +) + +qt_config_compiler_supports_flag_test(optimize_debug + LABEL "-Og support" + FLAG "-Og" +) + # reduce_relocations qt_config_compile_test(reduce_relocations LABEL "-Bsymbolic-functions support" @@ -364,19 +384,19 @@ qt_feature("gc_binaries" PRIVATE qt_feature("use_bfd_linker" LABEL "bfd" AUTODETECT false - CONDITION NOT WIN32 AND NOT INTEGRITY AND NOT WASM AND tests.use_bfd_linker OR FIXME + CONDITION NOT WIN32 AND NOT INTEGRITY AND NOT WASM AND TEST_use_bfd_linker ENABLE INPUT_linker STREQUAL 'bfd' DISABLE INPUT_linker STREQUAL 'gold' OR INPUT_linker STREQUAL 'lld' ) qt_feature_config("use_bfd_linker" QMAKE_PRIVATE_CONFIG) qt_feature("use_gold_linker_alias" AUTODETECT false - CONDITION NOT WIN32 AND NOT INTEGRITY AND NOT WASM AND tests.use_gold_linker OR FIXME + CONDITION NOT WIN32 AND NOT INTEGRITY AND NOT WASM AND TEST_use_gold_linker ) qt_feature("use_lld_linker" LABEL "lld" AUTODETECT false - CONDITION NOT WIN32 AND NOT INTEGRITY AND NOT WASM AND tests.use_lld_linker OR FIXME + CONDITION NOT WIN32 AND NOT INTEGRITY AND NOT WASM AND TEST_use_lld_linker ENABLE INPUT_linker STREQUAL 'lld' DISABLE INPUT_linker STREQUAL 'bfd' OR INPUT_linker STREQUAL 'gold' ) diff --git a/util/cmake/configurejson2cmake.py b/util/cmake/configurejson2cmake.py index 5e7036e614..86ebf4bae8 100755 --- a/util/cmake/configurejson2cmake.py +++ b/util/cmake/configurejson2cmake.py @@ -768,6 +768,15 @@ def write_compile_test( # "qmake": "unix:LIBS += -lpthread" # } # }, + +def write_compiler_supports_flag_test( + ctx, name, details, data, cm_fh, manual_library_list=None, is_library_test=False +): + cm_fh.write(f"qt_config_compiler_supports_flag_test({featureName(name)}\n") + cm_fh.write(lineify("LABEL", data.get("label", ""))) + cm_fh.write(lineify("FLAG", data.get("flag", ""))) + cm_fh.write(")\n\n") + def parseTest(ctx, test, data, cm_fh): skip_tests = { "c11", @@ -795,6 +804,16 @@ def parseTest(ctx, test, data, cm_fh): write_compile_test(ctx, test, details, data, cm_fh) + if data["type"] == "compilerSupportsFlag": + knownTests.add(test) + + if "test" in data: + details = data["test"] + else: + details = test + + write_compiler_supports_flag_test(ctx, test, details, data, cm_fh) + elif data["type"] == "libclang": knownTests.add(test)