diff --git a/mkspecs/features/gn_generator.prf b/mkspecs/features/gn_generator.prf index 4efbd92f2b5c5effd83867fde0900def008c467e..78b56d123460e9bd85c28a333d47cf2dc0885579 100644 --- a/mkspecs/features/gn_generator.prf +++ b/mkspecs/features/gn_generator.prf @@ -120,13 +120,18 @@ GN_CONTENTS += "config(\"$${TARGET}_config\") {" } # Stop the barrage of unused variables warnings. -gcc|clang { +gcc|clang|clang_cl { QMAKE_CXXFLAGS += "-Wno-unused-parameter" QMAKE_CXXFLAGS += "-Wno-unused-variable" } else:msvc { QMAKE_CXXFLAGS += /wd4100 /wd4101 } +# Chromium activates this, but we need it off to be able to compile QFlags +clang_cl { + QMAKE_CXXFLAGS += "-fno-complete-member-pointers" +} + !isEmpty(QMAKE_CXXFLAGS) { GN_CONTENTS += " cflags_cc = [" for(flag, QMAKE_CXXFLAGS): GN_CONTENTS += " \"$$filter_flag_values($$flag)\"," diff --git a/mkspecs/features/platform.prf b/mkspecs/features/platform.prf index 35eb6b89c0f6c8482a97835b16d54e910d921faa..67be73f74c7289b20a8309b5bc2e7f0a35bba797 100644 --- a/mkspecs/features/platform.prf +++ b/mkspecs/features/platform.prf @@ -26,7 +26,7 @@ defineTest(isPlatformSupported) { skipBuild("Qt WebEngine on Windows must be built on a 64-bit machine.") } !msvc|intel_icl { - skipBuild("Qt WebEngine on Windows requires MSVC.") + skipBuild("Qt WebEngine on Windows requires MSVC or Clang (MSVC mode).") return(false) } !isMinWinSDKVersion(10, 16299): { diff --git a/src/buildtools/gn.pro b/src/buildtools/gn.pro index 30ada935727a0a641e3ca3c34d9569a4b14f5008..b6bf9cfc4da1eda1e745b2065b410984595a0cb1 100644 --- a/src/buildtools/gn.pro +++ b/src/buildtools/gn.pro @@ -18,9 +18,13 @@ build_pass|!debug_and_release { src_3rd_party_dir = $$absolute_path("$${getChromiumSrcDir()}/../", "$$QTWEBENGINE_ROOT") gn_bootstrap = $$system_path($$absolute_path(gn/build/gen.py, $$src_3rd_party_dir)) - gn_configure = $$system_quote($$gn_bootstrap) --no-last-commit-position --out-path $$out_path \ - --cc \"$$which($$QMAKE_CC)\" --cxx \"$$which($$QMAKE_CXX)\" \ - --ld \"$$which($$QMAKE_LINK)\" + gn_gen_args = --no-last-commit-position --out-path $$out_path \ + --cc \"$$which($$QMAKE_CC)\" --cxx \"$$which($$QMAKE_CXX)\" \ + --ld \"$$which($$QMAKE_LINK)\" + + msvc:!clang_cl: gn_gen_args += --use-lto + + gn_configure = $$system_quote($$gn_bootstrap) $$gn_gen_args macos { gn_configure += --isysroot \"$$QMAKE_MAC_SDK_PATH\" } diff --git a/src/core/config/linux.pri b/src/core/config/linux.pri index 3eb4369100b5a7fea69f2dc29c691f0012faa2fd..95b7a4bdae7dd251d0b7e27612b8b1a1b4725a86 100644 --- a/src/core/config/linux.pri +++ b/src/core/config/linux.pri @@ -36,8 +36,7 @@ clang { gn_args += \ is_clang=true \ clang_use_chrome_plugins=false \ - clang_base_path=\"$${clang_prefix}\" \ - use_lld=false + clang_base_path=\"$${clang_prefix}\" linux-clang-libc++: gn_args += use_libcxx=true } else { diff --git a/src/core/config/windows.pri b/src/core/config/windows.pri index 9eb15830d7025b220de2bcc5f08f6dfa5c9d59a3..b934ea4759066d38329ad5da038e391e6d082f0d 100644 --- a/src/core/config/windows.pri +++ b/src/core/config/windows.pri @@ -1,7 +1,6 @@ include(common.pri) gn_args += \ - is_clang=false \ use_sysroot=false \ enable_session_service=false \ ninja_use_custom_environment_files=false \ @@ -9,6 +8,22 @@ gn_args += \ win_linker_timing=true \ com_init_check_hook_disabled=true +use_lld_linker: gn_args += use_lld=true +else: gn_args += use_lld=false + +clang_cl { + clang_full_path = $$system_path($$which($${QMAKE_CXX})) + # Remove the "\bin\clang-cl.exe" part: + clang_dir = $$dirname(clang_full_path) + clang_prefix = $$join(clang_dir,,,"\..") + gn_args += \ + is_clang=true \ + clang_use_chrome_plugins=false \ + clang_base_path=$$system_quote($$system_path($$clean_path($$clang_prefix))) +} else { + gn_args += is_clang=false +} + isDeveloperBuild() { gn_args += \ is_win_fastlink=true @@ -69,7 +84,6 @@ msvc { GN_TARGET_CPU = $$gnArch($$QT_ARCH) gn_args += target_cpu=\"$$GN_TARGET_CPU\" - } else { - error("Qt WebEngine for Windows can only be built with the Microsoft Visual Studio C++ compiler") + error("Qt WebEngine for Windows can only be built with a Microsoft Visual Studio C++ compatible compiler") } diff --git a/src/core/core_chromium.pri b/src/core/core_chromium.pri index 89fb40864a0a8f91b0c5705593c2a5e29887d06f..3f4266c8c746538afc40eb310e5c49c1db7ac2ce 100644 --- a/src/core/core_chromium.pri +++ b/src/core/core_chromium.pri @@ -37,6 +37,11 @@ qtConfig(egl): CONFIG += egl INCLUDEPATH += $$PWD $$PWD/api +clang_cl { + QMAKE_CFLAGS -= $$QMAKE_CFLAGS_MSVC_COMPAT + QMAKE_CXXFLAGS -= $$QMAKE_CFLAGS_MSVC_COMPAT +} + SOURCES = \ accessibility_activation_observer.cpp \ accessibility_tree_formatter_qt.cpp \ diff --git a/src/core/core_module.pro b/src/core/core_module.pro index 3b5d37f299c6e3aac242670678fe9190f9c06c9b..e2fa3494d4dfc6545ab8ff7a098c3ede9e78e8e2 100644 --- a/src/core/core_module.pro +++ b/src/core/core_module.pro @@ -55,7 +55,7 @@ LIBS_PRIVATE += -L$$api_library_path CONFIG *= no_smart_library_merge osx { LIBS_PRIVATE += -Wl,-force_load,$${api_library_path}$${QMAKE_DIR_SEP}lib$${api_library_name}.a -} else:msvc { +} else: win32 { !isDeveloperBuild() { # Remove unused functions and data in debug non-developer builds, because the binaries will # be smaller in the shipped packages. @@ -74,7 +74,7 @@ osx { LIBS_PRIVATE += -Wl,-whole-archive -l$$api_library_name -Wl,-no-whole-archive } -win32-msvc* { +win32 { POST_TARGETDEPS += $${api_library_path}$${QMAKE_DIR_SEP}$${api_library_name}.lib } else { POST_TARGETDEPS += $${api_library_path}$${QMAKE_DIR_SEP}lib$${api_library_name}.a diff --git a/src/webengine/ui_delegates_manager.cpp b/src/webengine/ui_delegates_manager.cpp index a30fa7b98900966ad544430b98323c76ef96a632..2f371efd55bc398e9e77b9d344e48a4b2e608f6d 100644 --- a/src/webengine/ui_delegates_manager.cpp +++ b/src/webengine/ui_delegates_manager.cpp @@ -64,7 +64,7 @@ namespace QtWebEngineCore { #define NO_SEPARATOR -#if defined(Q_OS_WIN) +#if defined(Q_CC_MSVC) && !defined(Q_CC_CLANG) #define FILE_NAME_CASE_STATEMENT(TYPE, COMPONENT) \ case UIDelegatesManager::TYPE:\ return QString::fromLatin1(#TYPE ##".qml");