From b1e6a41c9d555c2455c6414c7b9da1f13e2f8811 Mon Sep 17 00:00:00 2001 From: Raed Rizqie Date: Fri, 25 Jul 2025 12:18:46 +0800 Subject: [PATCH] angleproject: update to 2.1.r25748.890b5d8f (#24941) - rebase most patches - enable d3d11 compositor - enable swiftshader on mingw64 and ucrt64 --- .../001-add-mingw-toolchain.patch | 1496 +++++++++-------- .../002-buildflags-fixes.patch | 208 ++- .../003-angle-src-fixes.patch | 110 +- .../004-swiftshader-updates.patch | 210 ++- .../005-vulkan-memory-allocator-updates.patch | 40 +- .../006-spirv-updates.patch | 10 +- .../007-vulkan-loader-updates.patch | 51 +- mingw-w64-angleproject/PKGBUILD | 163 +- 8 files changed, 1300 insertions(+), 988 deletions(-) diff --git a/mingw-w64-angleproject/001-add-mingw-toolchain.patch b/mingw-w64-angleproject/001-add-mingw-toolchain.patch index 47269d0019..0f6d5f2b72 100644 --- a/mingw-w64-angleproject/001-add-mingw-toolchain.patch +++ b/mingw-w64-angleproject/001-add-mingw-toolchain.patch @@ -1,24 +1,8 @@ diff --git a/config/BUILD.gn b/config/BUILD.gn -index 35c9a6275..7cf9f574d 100644 +index 56ca3ca73..4b0b33318 100644 --- a/config/BUILD.gn +++ b/config/BUILD.gn -@@ -115,13 +115,13 @@ config("debug") { - defines += [ "DYNAMIC_ANNOTATIONS_PREFIX=NACL_" ] - } - -- if (is_win) { -+ if (is_msvs) { - if (!enable_iterator_debugging && !use_custom_libcxx) { - # Iterator debugging is enabled by default by the compiler on debug - # builds, and we have to tell it to turn it off. - defines += [ "_HAS_ITERATOR_DEBUGGING=0" ] - } -- } else if ((is_linux || is_chromeos) && current_cpu == "x64" && -+ } else if ((is_linux || is_chromeos || is_mingw) && current_cpu == "x64" && - enable_iterator_debugging) { - # Enable libstdc++ debugging facilities to help catch problems early, see - # http://crbug.com/65151 . -@@ -161,25 +161,25 @@ config("default_libs") { +@@ -157,25 +157,25 @@ config("default_libs") { # instead the targets that use the less common ones (e.g. wininet or # winspool) should include those explicitly. libs = [ @@ -63,7 +47,7 @@ index 35c9a6275..7cf9f574d 100644 # Please don't add more stuff here. We should actually be making this # list smaller, since all common things should be covered. If you need -@@ -195,9 +195,9 @@ config("default_libs") { +@@ -191,9 +191,9 @@ config("default_libs") { } else { # These libraries are not compatible with Windows UWP (i.e. store apps.) libs += [ @@ -76,31 +60,25 @@ index 35c9a6275..7cf9f574d 100644 ] } } else if (is_android) { -@@ -291,9 +291,13 @@ group("shared_library_deps") { - # Windows linker setup for EXEs and DLLs. - if (is_win) { - _windows_linker_configs = [ -- "//build/config/win:sdk_link", - "//build/config/win:common_linker_setup", - ] -+ if (is_msvs) { -+ _windows_linker_configs += [ -+ "//build/config/win:sdk_link", -+ ] -+ } - } +@@ -253,7 +253,7 @@ group("common_deps_without_libcxx") { + } + } - # This config defines the configs applied to all executables. -@@ -367,7 +371,7 @@ config("shared_library_config") { +- if (is_win) { ++ if (is_msvc) { + if (build_with_chromium && is_component_build) { + # To enable allocator_shim for the windows component built chrome, + # need to make all shared libraries and also executable(i.e.chrome.exe) +@@ -405,7 +405,7 @@ config("shared_library_config") { # Recommend precompiled headers for targets with more than 50 .cc files. config("precompiled_headers") { if (enable_precompiled_headers) { - if (is_win) { -+ if (is_msvs) { ++ if (is_msvc) { # This is a string rather than a file GN knows about. It has to match # exactly what's in the /FI flag below, and what might appear in the # source code in quotes for an #include directive. -@@ -380,7 +384,7 @@ config("precompiled_headers") { +@@ -418,7 +418,7 @@ config("precompiled_headers") { # Force include the header. cflags = [ "/FI$precompiled_header" ] @@ -110,7 +88,7 @@ index 35c9a6275..7cf9f574d 100644 } } diff --git a/config/BUILDCONFIG.gn b/config/BUILDCONFIG.gn -index 1fa42b1b1..bab13adae 100644 +index 147226d72..07b31bfc5 100644 --- a/config/BUILDCONFIG.gn +++ b/config/BUILDCONFIG.gn @@ -135,6 +135,9 @@ declare_args() { @@ -123,194 +101,227 @@ index 1fa42b1b1..bab13adae 100644 # Set to true when compiling with the Clang compiler. is_clang = current_os != "linux" || (current_cpu != "s390x" && current_cpu != "s390" && -@@ -211,15 +214,23 @@ if (host_toolchain == "") { +@@ -227,16 +230,20 @@ if (host_toolchain == "") { + # On Windows always use the target CPU for host builds for x86/x64. On the # configurations we support this will always work and it saves build steps. # Windows ARM64 targets require an x64 host for cross build. - if (target_cpu == "x86" || target_cpu == "x64") { +- if (target_cpu == "x86" || target_cpu == "x64") { - if (is_clang) { -+ if (is_clang && !is_mingw) { - host_toolchain = "//build/toolchain/win:win_clang_$target_cpu" - } else { -- host_toolchain = "//build/toolchain/win:$target_cpu" -+ if (is_mingw) { -+ host_toolchain = "//build/toolchain/win:mingw_$target_cpu" +- host_toolchain = "//build/toolchain/win:win_clang_$target_cpu" ++ if (is_mingw) { ++ host_toolchain = "//build/toolchain/win:mingw_$target_cpu" ++ } else { ++ if (target_cpu == "x86" || target_cpu == "x64") { ++ if (is_clang) { ++ host_toolchain = "//build/toolchain/win:win_clang_$target_cpu" + } else { + host_toolchain = "//build/toolchain/win:$target_cpu" + } ++ } else if (is_clang) { ++ host_toolchain = "//build/toolchain/win:win_clang_$host_cpu" + } else { +- host_toolchain = "//build/toolchain/win:$target_cpu" ++ host_toolchain = "//build/toolchain/win:$host_cpu" } - } else if (is_clang) { -+ } else if (is_clang && !is_mingw) { - host_toolchain = "//build/toolchain/win:win_clang_$host_cpu" - } else { +- host_toolchain = "//build/toolchain/win:win_clang_$host_cpu" +- } else { - host_toolchain = "//build/toolchain/win:$host_cpu" -+ if (is_mingw) { -+ host_toolchain = "//build/toolchain/win:mingw_$host_cpu" -+ } else { -+ host_toolchain = "//build/toolchain/win:$host_cpu" -+ } } } else if (host_os == "aix") { host_toolchain = "//build/toolchain/aix:$host_cpu" -@@ -253,8 +264,10 @@ if (target_os == "android") { +@@ -271,10 +278,14 @@ if (target_os == "android") { } else if (target_os == "win") { # On Windows, we use the same toolchain for host and target by default. # Beware, win cross builds have some caveats, see docs/win_cross.md - if (is_clang) { -+ if (is_clang && !is_mingw) { - _default_toolchain = "//build/toolchain/win:win_clang_$target_cpu" -+ } else if (is_mingw) { +- _default_toolchain = "//build/toolchain/win:win_clang_$target_cpu" ++ if (is_mingw) { + _default_toolchain = "//build/toolchain/win:mingw_$target_cpu" } else { - _default_toolchain = "//build/toolchain/win:$target_cpu" +- _default_toolchain = "//build/toolchain/win:$target_cpu" ++ if (is_clang) { ++ _default_toolchain = "//build/toolchain/win:win_clang_$target_cpu" ++ } else { ++ _default_toolchain = "//build/toolchain/win:$target_cpu" ++ } } -@@ -309,6 +322,7 @@ is_win = current_os == "win" || current_os == "winuwp" + } else if (target_os == "winuwp") { + # Only target WinUWP on for a Windows store application and only +@@ -339,6 +350,7 @@ is_win = current_os == "win" || current_os == "winuwp" - is_apple = is_ios || is_mac + is_apple = is_ios || is_mac || is_watchos is_posix = !is_win && !is_fuchsia -+is_msvs = is_win && !is_mingw ++is_msvc = is_win && !is_mingw # ============================================================================= # TARGET DEFAULTS -@@ -413,7 +427,7 @@ set_defaults("rust_library") { +@@ -418,7 +430,7 @@ if (is_android) { + [ "//build/config/android:default_orderfile_instrumentation" ] + } + +-if (is_clang && !is_nacl) { ++if (is_clang && !is_nacl && !is_mingw) { + default_compiler_configs += [ + "//build/config/clang:extra_warnings", + "//build/config/clang:find_bad_constructs", +@@ -446,7 +458,7 @@ set_defaults("rust_library") { # Compute the set of configs common to all linked targets (shared libraries, # loadable modules, executables) to avoid duplication below. -if (is_win) { -+if (is_msvs) { ++if (is_msvc) { # Many targets remove these configs, so they are not contained within # //build/config:executable_config for easy removal. _linker_configs = [ -@@ -435,7 +449,7 @@ default_executable_configs = default_compiler_configs + [ +@@ -473,7 +485,7 @@ default_executable_configs = default_compiler_configs + [ "//build/config:executable_config", ] + _linker_configs -if (is_win) { -+if (is_msvs) { ++if (is_msvc) { # Turn on linker CFI for executables, and position it so it can be removed # if needed. default_executable_configs += [ "//build/config/win:cfi_linker" ] -@@ -451,7 +465,7 @@ default_shared_library_configs = default_compiler_configs + [ +@@ -497,7 +509,7 @@ default_shared_library_configs = default_compiler_configs + [ "//build/config:default_libs", "//build/config:shared_library_config", ] + _linker_configs -if (is_win) { -+if (is_msvs) { ++if (is_msvc) { # Turn on linker CFI for DLLs, and position it so it can be removed if needed. default_shared_library_configs += [ "//build/config/win:cfi_linker" ] } -diff --git a/config/clang/BUILD.gn b/config/clang/BUILD.gn -index 8fd6760f3..0dae22f48 100644 ---- a/config/clang/BUILD.gn -+++ b/config/clang/BUILD.gn -@@ -4,6 +4,10 @@ - - import("clang.gni") - -+if (is_mingw) { -+ clang_use_chrome_plugins = false -+} -+ - config("find_bad_constructs") { - if (clang_use_chrome_plugins) { - cflags = [] diff --git a/config/compiler/BUILD.gn b/config/compiler/BUILD.gn -index 4e6708bdd..ac5a3c120 100644 +index 29c284ee0..0125019ad 100644 --- a/config/compiler/BUILD.gn +++ b/config/compiler/BUILD.gn -@@ -317,13 +317,13 @@ config("compiler") { +@@ -322,14 +322,20 @@ config("compiler") { - # In general, Windows is totally different, but all the other builds share - # some common compiler and linker configuration. -- if (!is_win) { -+ if (!is_msvs) { - # Common POSIX compiler flags setup. - # -------------------------------- - cflags += [ "-fno-strict-aliasing" ] # See http://crbug.com/32204 + configs += [ + # See the definitions below. +- ":clang_revision", +- ":rustc_revision", + ":compiler_cpu_abi", + ":compiler_codegen", + ":compiler_deterministic", + ":clang_warning_suppression", + ] - # Stack protection. -- if (is_apple) { -+ if (is_apple || is_mingw) { - # The strong variant of the stack protector significantly increases - # binary size, so only enable it in debug mode. - if (is_debug) { -@@ -377,7 +377,7 @@ config("compiler") { ++ if (clang_use_chrome_plugins) { ++ configs += [ ":clang_revision" ] ++ } ++ ++ if (enable_rust) { ++ configs += [ ":rustc_revision" ] ++ } ++ + # TODO(https://crbug.com/404297941): Disable clang_warning_suppression + # configuration because the ICECC build doesn't distribute the + # warning_suppression.txt file to other ICECC nodes. As a result, the nodes +@@ -355,8 +361,8 @@ config("compiler") { + # Make signed overflow and pointer overflowdefined to wrap. + # This avoids risking miscompilations and security bugs on overflow. + # When UBSan is enabled, we want to continue flagging overflows as a bug. +- if (!is_ubsan && (!is_win || is_clang)) { +- if (is_win) { ++ if (!is_ubsan && (!is_msvc || is_clang)) { ++ if (is_msvc) { + cflags += [ "/clang:-fno-strict-overflow" ] + } else { + cflags += [ "-fno-strict-overflow" ] +@@ -366,7 +372,7 @@ config("compiler") { + # Don't emit the GCC version ident directives, they just end up in the + # .comment section or debug info taking up binary size, and makes comparing + # .o files built with different compiler versions harder. +- if (!is_win || is_clang) { ++ if (!is_msvc || is_clang) { + cflags += [ "-fno-ident" ] + } + +@@ -426,6 +432,18 @@ config("compiler") { + if (fatal_linker_warnings && is_apple) { + ldflags += [ "-Wl,-fatal_warnings" ] + } ++ } else if (is_mingw) { ++ cflags += [ "-fno-strict-aliasing" ] ++ ++ if (is_debug) { ++ cflags += [ "-fstack-protector-strong" ] ++ } else { ++ cflags += [ "-fstack-protector" ] ++ } ++ ++ if (use_lld) { ++ ldflags += [ "-fuse-ld=lld" ] ++ } + } # Non-Apple Posix and Fuchsia compiler flags setup. - # ----------------------------------- -- if ((is_posix && !is_apple) || is_fuchsia) { -+ if ((is_posix && !is_apple) || is_fuchsia || is_mingw) { - if (enable_profiling) { - if (!is_debug) { - cflags += [ "-g" ] -@@ -527,11 +527,11 @@ config("compiler") { +@@ -574,7 +592,7 @@ config("compiler") { + cflags += [ "-fmerge-all-constants" ] + + if (!use_sized_deallocation) { +- if (is_win) { ++ if (is_msvc) { + cflags += [ "/Zc:sizedDealloc-" ] + } else { + cflags += [ "-fno-sized-deallocation" ] +@@ -586,7 +604,7 @@ config("compiler") { + } + } + +- if (use_lld) { ++ if (use_lld && !is_mingw) { # TODO(thakis): Make the driver pass --color-diagnostics to the linker # if -fcolor-diagnostics is passed to it, and pass -fcolor-diagnostics # in ldflags instead. -- if (is_win) { -+ if (is_msvs) { - # On Windows, we call the linker directly, instead of calling it through - # the driver. - ldflags += [ "--color-diagnostics" ] -- } else { -+ } else if (!is_clang) { - ldflags += [ "-Wl,--color-diagnostics" ] - } +@@ -605,7 +623,7 @@ config("compiler") { + ldflags += [ "-Wl,-z,keep-text-section-prefix" ] } -@@ -558,7 +558,7 @@ config("compiler") { - "-instcombine-lower-dbg-declare=0", - ] - if (!is_debug && use_thin_lto && is_a_target_toolchain) { -- if (is_win) { -+ if (is_msvs) { - ldflags += [ "-mllvm:-instcombine-lower-dbg-declare=0" ] - } else { - ldflags += [ "-Wl,-mllvm,-instcombine-lower-dbg-declare=0" ] -@@ -566,7 +566,7 @@ config("compiler") { - } - # TODO(crbug.com/1235145): Investigate why/if this should be needed. -- if (is_win) { -+ if (is_msvs) { - cflags += [ "/clang:-ffp-contract=off" ] - } else { - cflags += [ "-ffp-contract=off" ] -@@ -580,7 +580,7 @@ config("compiler") { +- if (is_clang) { ++ if (is_clang && !is_mingw) { + cflags += [ "-fcrash-diagnostics-dir=" + clang_diagnostic_dir ] + if (save_reproducers_on_lld_crash && use_lld) { + ldflags += [ +@@ -664,7 +682,7 @@ config("compiler") { # C11/C++11 compiler flags setup. # --------------------------- -- if (is_linux || is_chromeos || is_android || (is_nacl && is_clang) || -+ if (is_linux || is_mingw || is_chromeos || is_android || (is_nacl && is_clang) || - current_os == "aix") { +- if (is_linux || is_chromeos || is_android || current_os == "aix") { ++ if (is_linux || is_chromeos || is_android || is_mingw || current_os == "aix") { if (is_clang) { standard_prefix = "c" -@@ -624,7 +624,7 @@ config("compiler") { + +@@ -682,7 +700,7 @@ config("compiler") { + } + + cflags_c += [ "-std=${standard_prefix}11" ] +- if (is_clang) { ++ if (is_clang || is_mingw) { + if (defined(use_cxx17) && use_cxx17) { + assert(!use_cxx23) + cflags_cc += [ "-std=${standard_prefix}++17" ] +@@ -696,7 +714,7 @@ config("compiler") { # support "c++20"/"gnu++20". cflags_cc += [ "-std=${standard_prefix}++2a" ] } - } else if (is_win) { -+ } else if (is_msvs) { ++ } else if (is_msvc) { cflags_c += [ "/std:c11" ] - if (use_cxx17 || (!is_clang && defined(msvc_use_cxx17) && msvc_use_cxx17)) { - cflags_cc += [ "/std:c++17" ] -@@ -683,7 +683,7 @@ config("compiler") { - # should be able to better manage binary size increases on its own. - import_instr_limit = 30 - -- if (is_win) { -+ if (is_msvs) { - ldflags += [ - "/opt:lldltojobs=all", - "-mllvm:-import-instr-limit=$import_instr_limit", -@@ -758,7 +758,7 @@ config("compiler") { - if (compiler_timing) { - if (is_clang && !is_nacl) { - cflags += [ "-ftime-trace" ] + if (defined(use_cxx17) && use_cxx17) { + assert(!use_cxx23) +@@ -911,7 +929,7 @@ config("compiler") { + if (use_lld && is_mac) { + ldflags += [ "-Wl,--time-trace" ] + } - } else if (is_win) { -+ } else if (is_msvs) { ++ } else if (is_msvc) { cflags += [ # "Documented" here: # http://aras-p.info/blog/2017/10/23/Best-unknown-MSVC-flag-d2cgsummary/ -@@ -787,7 +787,7 @@ config("compiler") { +@@ -940,7 +958,7 @@ config("compiler") { # present. On Android this increases binary size due to more thinks for long # jumps. Turn it off by default and enable selectively for targets where it's # beneficial. @@ -318,36 +329,27 @@ index 4e6708bdd..ac5a3c120 100644 + if (use_lld && !enable_call_graph_profile_sort && !is_mingw) { if (is_win) { ldflags += [ "/call-graph-profile-sort:no" ] - } else { -@@ -796,7 +796,7 @@ config("compiler") { + } else if (!is_wasm) { +@@ -950,7 +968,7 @@ config("compiler") { } - if (is_clang && !is_nacl && show_includes) { + if (is_clang && show_includes) { - if (is_win) { -+ if (is_msvs) { - # TODO(crbug.com/1223741): Goma mixes the -H and /showIncludes output. - assert(!use_goma, "show_includes on Windows is not reliable with goma") ++ if (is_msvc) { cflags += [ -@@ -932,7 +932,7 @@ config("thinlto_optimize_default") { - if (!is_debug && use_thin_lto && is_a_target_toolchain) { - lto_opt_level = 0 + "/clang:-H", + "/clang:-fshow-skipped-includes", +@@ -966,7 +984,7 @@ config("compiler") { + # This flag enforces that member pointer base types are complete. It helps + # prevent us from running into problems in the Microsoft C++ ABI (see + # https://crbug.com/847724). +- if (is_clang && target_os != "chromeos" && (is_win || use_custom_libcxx)) { ++ if (is_clang && target_os != "chromeos" && (is_msvc || use_custom_libcxx)) { + cflags += [ "-fcomplete-member-pointers" ] + } -- if (is_win) { -+ if (is_msvs) { - ldflags = [ "/opt:lldlto=" + lto_opt_level ] - } else { - ldflags = [ "-Wl,--lto-O" + lto_opt_level ] -@@ -958,7 +958,7 @@ config("thinlto_optimize_max") { - lto_opt_level = 0 - } - -- if (is_win) { -+ if (is_msvs) { - ldflags = [ "/opt:lldlto=" + lto_opt_level ] - } else { - ldflags = [ "-Wl,--lto-O" + lto_opt_level ] -@@ -989,7 +989,7 @@ config("compiler_cpu_abi") { - ldflags += [ "-fno-global-isel" ] +@@ -1240,22 +1258,26 @@ config("compiler_cpu_abi") { + configs += [ "//build/config/chromeos:compiler_cpu_abi" ] } - if ((is_posix && !is_apple) || is_fuchsia) { @@ -355,52 +357,91 @@ index 4e6708bdd..ac5a3c120 100644 # CPU architecture. We may or may not be doing a cross compile now, so for # simplicity we always explicitly set the architecture. if (current_cpu == "x64") { -@@ -1024,7 +1024,7 @@ config("compiler_cpu_abi") { +- if (is_clang && !is_android && !is_fuchsia && !is_chromeos_device) { ++ if (is_clang && !is_android && !is_fuchsia && !is_mingw && !is_chromeos_device) { + cflags += [ "--target=x86_64-unknown-linux-gnu" ] + ldflags += [ "--target=x86_64-unknown-linux-gnu" ] ++ } else if (is_mingw) { ++ ldflags += [ "-m64" ] + } else { + cflags += [ "-m64" ] + ldflags += [ "-m64" ] + } + cflags += [ "-msse3" ] + } else if (current_cpu == "x86") { +- if (is_clang && !is_android && !is_chromeos_device) { ++ if (is_clang && !is_android && !is_mingw && !is_chromeos_device) { + cflags += [ "--target=i386-unknown-linux-gnu" ] + ldflags += [ "--target=i386-unknown-linux-gnu" ] ++ } else if (is_mingw) { ++ ldflags += [ "-m32" ] + } else { + cflags += [ "-m32" ] + ldflags += [ "-m32" ] +@@ -1277,7 +1299,7 @@ config("compiler_cpu_abi") { + cflags += [ "-mtune=$arm_tune" ] } } else if (current_cpu == "arm64") { - if (is_clang && !is_android && !is_nacl && !is_fuchsia && -- !(is_chromeos_lacros && is_chromeos_device)) { -+ !(is_chromeos_lacros && is_chromeos_device) && !is_win) { +- if (is_clang && !is_android && !is_fuchsia && !is_chromeos_device) { ++ if (is_clang && !is_android && !is_fuchsia && !is_mingw && !is_chromeos_device) { cflags += [ "--target=aarch64-linux-gnu" ] ldflags += [ "--target=aarch64-linux-gnu" ] } -@@ -1334,7 +1334,7 @@ config("compiler_deterministic") { +@@ -1595,7 +1617,7 @@ config("compiler_deterministic") { # Eliminate build metadata (__DATE__, __TIME__ and __TIMESTAMP__) for # deterministic build. See https://crbug.com/314403 if (!is_official_build) { - if (is_win && !is_clang) { -+ if (is_msvs && !is_clang) { ++ if (is_msvc && !is_clang) { cflags += [ "/wd4117", # Trying to define or undefine a predefined macro. "/D__DATE__=", -@@ -1377,7 +1377,7 @@ config("compiler_deterministic") { +@@ -1635,7 +1657,7 @@ config("compiler_deterministic") { asmflags = [ "-Wa,-fdebug-compilation-dir,." ] } - if (is_win && use_lld) { -+ if (is_msvs && use_lld) { ++ if (is_msvc && use_lld) { if (symbol_level == 2 || (is_clang && using_sanitizer)) { # Absolutize source file paths for PDB. Pass the real build directory # if the pdb contains source-level debug information and if linker -@@ -1410,7 +1410,7 @@ config("compiler_deterministic") { - } +@@ -1677,7 +1699,7 @@ config("compiler_deterministic") { config("clang_revision") { -- if (is_clang && clang_base_path == default_clang_base_path) { -+ if (is_msvs && is_clang && clang_base_path == default_clang_base_path) { - update_args = [ - "--print-revision", - "--verify-version=$clang_version", -@@ -1528,7 +1528,7 @@ config("default_warnings") { - cflags_cc = [] + if (is_clang && clang_base_path == default_clang_base_path && +- current_os != "zos") { ++ !is_mingw && current_os != "zos") { + _perform_consistency_checks = current_toolchain == default_toolchain + if (llvm_force_head_revision) { + _head_revision_stamp_path = "//third_party/llvm-build/force_head_revision" +@@ -1886,7 +1908,7 @@ config("runtime_library") { + # the C++ symbols. This config ensures the C++ symbols exist and are strong in + # order to cause that replacement to occur by explicitly linking in clang's + # compiler-rt library. +- if (is_clang && !is_cronet_build) { ++ if (is_clang && !is_cronet_build && !is_mingw) { + configs += [ "//build/config/clang:compiler_builtins" ] + } + +@@ -1932,7 +1954,7 @@ config("runtime_library") { + # is broken out separately so nocompile tests can force-enable this setting + # independently of the default warning flags. + config("treat_warnings_as_errors") { +- if (is_win) { ++ if (is_msvc) { + cflags = [ "/WX" ] + } else { + cflags = [ "-Werror" ] +@@ -1983,7 +2005,7 @@ config("default_warnings") { ldflags = [] + configs = [] - if (is_win) { -+ if (is_msvs) { - if (treat_warnings_as_errors) { - cflags += [ "/WX" ] - } -@@ -1603,10 +1603,33 @@ config("default_warnings") { ++ if (is_msvc) { + if (fatal_linker_warnings) { + arflags = [ "/WX" ] + ldflags = [ "/WX" ] +@@ -2059,10 +2081,33 @@ config("default_warnings") { # files. cflags += [ "-Wno-packed-not-aligned" ] } @@ -409,21 +450,21 @@ index 4e6708bdd..ac5a3c120 100644 + cflags += [ + "-Wno-attributes", # "__decspec(dllimport) inline" + "-Wno-format", # PRIu64 llu support on MinGW -+ "-Wno-parentheses", ++ "-Wno-uninitialized", + "-Wno-unknown-pragmas", + ] + if (!is_clang) { ++ cflags_cc += [ ++ "-Wno-ignored-attributes", ++ "-Wno-invalid-constexpr", ++ "-Wno-pessimizing-move", ++ "-Wno-shift-count-overflow", ++ "-Wno-subobject-linkage", # Tests having code in header files ++ ] + cflags += [ + "-Wno-array-bounds", -+ "-Wno-dangling-pointer", -+ "-Wno-shift-count-overflow", -+ "-Wno-sign-compare", -+ "-Wno-stringop-overflow", # False positive overflow error on gcc 10 -+ "-Wno-stringop-truncation", + "-Wno-unused-but-set-variable", -+ ] -+ cflags_cc += [ -+ "-Wno-conversion-null", ++ "-Wno-stringop-overflow", # False positive overflow error on gcc 10 + ] + } + } @@ -431,373 +472,372 @@ index 4e6708bdd..ac5a3c120 100644 # Common Clang and GCC warning setup. - if (!is_win || is_clang) { -+ if (!is_msvs || is_clang) { ++ if (!is_msvc || is_clang) { cflags += [ # Disables. "-Wno-missing-field-initializers", # "struct foo f = {0};" -@@ -1711,7 +1734,7 @@ config("prevent_unsafe_narrowing") { +@@ -2246,7 +2291,7 @@ config("prevent_unsafe_narrowing") { # part of Chromium. config("chromium_code") { - if (is_win) { -+ if (is_msvs) { ++ if (is_msvc) { if (is_clang) { cflags = [ "/W4" ] # Warning level 4. -@@ -1798,7 +1821,7 @@ config("no_chromium_code") { +@@ -2301,7 +2346,7 @@ config("chromium_code") { + } + } + +- if (is_clang) { ++ if (is_clang && !is_mingw) { + cflags += [ + # Warn on missing break statements at the end of switch cases. + # For intentional fallthrough, use [[fallthrough]]. +@@ -2354,7 +2399,7 @@ config("no_chromium_code") { cflags_cc = [] defines = [] - if (is_win) { -+ if (is_msvs) { ++ if (is_msvc) { if (is_clang) { cflags += [ "/W3" ] # Warning level 3. } -@@ -1865,7 +1888,7 @@ config("noshadowing") { +@@ -2405,7 +2450,7 @@ config("noshadowing") { # Allows turning Run-Time Type Identification on or off. config("rtti") { - if (is_win) { -+ if (is_msvs) { ++ if (is_msvc) { cflags_cc = [ "/GR" ] } else { cflags_cc = [ "-frtti" ] -@@ -1875,7 +1898,7 @@ config("rtti") { +@@ -2415,7 +2460,7 @@ config("rtti") { config("no_rtti") { # Some sanitizer configs may require RTTI to be left enabled globally if (!use_rtti) { - if (is_win) { -+ if (is_msvs) { ++ if (is_msvc) { cflags_cc = [ "/GR-" ] } else { cflags_cc = [ "-fno-rtti" ] -@@ -1919,7 +1942,7 @@ config("thin_archive") { - # confuses lldb. - if ((is_posix && !is_nacl && !is_apple) || is_fuchsia) { - arflags = [ "-T" ] +@@ -2467,7 +2512,7 @@ config("thin_archive") { + "-T", + "-S", + ] - } else if (is_win && use_lld) { -+ } else if (is_msvs && use_lld) { ++ } else if (is_msvc && use_lld) { arflags = [ "/llvmlibthin" ] } } -@@ -1930,7 +1953,7 @@ config("thin_archive") { +@@ -2478,7 +2523,7 @@ config("thin_archive") { # Note: exceptions are disallowed in Google code. config("exceptions") { - if (is_win) { -+ if (is_msvs) { ++ if (is_msvc) { # Enables exceptions in the STL. if (!use_custom_libcxx) { defines = [ "_HAS_EXCEPTIONS=1" ] -@@ -1943,7 +1966,7 @@ config("exceptions") { +@@ -2491,7 +2536,7 @@ config("exceptions") { } config("no_exceptions") { - if (is_win) { -+ if (is_msvs) { ++ if (is_msvc) { # Disables exceptions in the STL. # libc++ uses the __has_feature macro to control whether to use exceptions, # so defining this macro is unnecessary. Defining _HAS_EXCEPTIONS to 0 also -@@ -2009,7 +2032,7 @@ config("no_incompatible_pointer_warnings") { +@@ -2501,7 +2546,9 @@ config("no_exceptions") { + if (!use_custom_libcxx) { + defines = [ "_HAS_EXCEPTIONS=0" ] + } +- } else { ++ } else if (!is_mingw) { ++ # Do not explicitly set no-exceptions on MinGW, else we have to ++ # unset it in many other places. + cflags_cc = [ "-fno-exceptions" ] + cflags_objcc = cflags_cc + } +@@ -2576,7 +2623,7 @@ config("no_incompatible_pointer_warnings") { # Shared settings for both "optimize" and "optimize_max" configs. # IMPORTANT: On Windows "/O1" and "/O2" must go before the common flags. -if (is_win) { -+if (is_msvs) { ++if (is_msvc) { common_optimize_on_cflags = [ - "/Ob2", # Both explicit and auto inlining. "/Oy-", # Disable omitting frame pointers, must be after /O2. -@@ -2088,7 +2111,7 @@ if (is_win) { - } + "/Zc:inline", # Remove unreferenced COMDAT (faster links). +@@ -2631,7 +2678,7 @@ if (is_win) { + "-Wl,-no_function_starts", + ] + } +- } else if (current_os != "aix" && current_os != "zos") { ++ } else if (current_os != "aix" && current_os != "zos" && !is_mingw) { + # Non-Mac Posix flags. + # Aix does not support these. - config("default_stack_frames") { -- if (!is_win) { -+ if (!is_msvs) { - if (enable_frame_pointers) { - cflags = [ "-fno-omit-frame-pointer" ] - -@@ -2115,7 +2138,7 @@ config("default_stack_frames") { - - # Default "optimization on" config. +@@ -2714,7 +2761,7 @@ config("default_stack_frames") { + # [1]: https://pinpoint-dot-chromeperf.appspot.com/job/132bc772be0000 + # [2]: https://crrev.com/c/5447532 config("optimize") { - if (is_win) { -+ if (is_msvs) { - if (chrome_pgo_phase != 2) { - # Favor size over speed, /O1 must be before the common flags. - # /O1 implies /Os and /GF. -@@ -2174,7 +2197,7 @@ config("optimize") { ++ if (is_msvc) { + # clang-cl's /O2 corresponds to clang's -O3, and really want -O2 for + # consistency with the other platforms. + cflags = [ +@@ -2738,7 +2785,7 @@ config("optimize") { + } + + if (is_clang && use_ml_inliner && is_a_target_toolchain && !is_chromeos && +- !is_high_end_android) { ++ !is_mingw && !is_high_end_android) { + cflags += [ + "-mllvm", + "-enable-ml-inliner=release", +@@ -2763,7 +2810,7 @@ config("optimize") { # Turn off optimizations. config("no_optimize") { - if (is_win) { -+ if (is_msvs) { ++ if (is_msvc) { cflags = [ "/Od", # Disable optimization. "/Ob0", # Disable all inlining (on by default). -@@ -2226,7 +2249,7 @@ config("optimize_max") { - configs = [ "//build/config/nacl:irt_optimize" ] - } else { - ldflags = common_optimize_on_ldflags -- if (is_win) { -+ if (is_msvs) { - # Favor speed over size, /O2 must be before the common flags. - # /O2 implies /Ot, /Oi, and /GF. - cflags = [ "/O2" ] + common_optimize_on_cflags -@@ -2259,7 +2282,7 @@ config("optimize_speed") { - configs = [ "//build/config/nacl:irt_optimize" ] - } else { - ldflags = common_optimize_on_ldflags -- if (is_win) { -+ if (is_msvs) { - # Favor speed over size, /O2 must be before the common flags. - # /O2 implies /Ot, /Oi, and /GF. - cflags = [ "/O2" ] + common_optimize_on_cflags -@@ -2396,7 +2419,7 @@ config("win_pdbaltpath") { - - # Full symbols. - config("symbols") { +@@ -2799,7 +2846,7 @@ config("no_optimize") { + # elsewhere. + config("optimize_max") { + ldflags = common_optimize_on_ldflags - if (is_win) { -+ if (is_msvs) { ++ if (is_msvc) { + # Favor speed over size, /O2 must be before the common flags. + # /O2 implies /Ot, /Oi, and /GF. + cflags = [ "/O2" ] + common_optimize_on_cflags +@@ -2820,7 +2867,7 @@ config("optimize_max") { + # so that we don't need this disclaimer. + config("optimize_speed") { + ldflags = common_optimize_on_ldflags +- if (is_win) { ++ if (is_msvc) { + # Favor speed over size, /O2 must be before the common flags. + # /O2 implies /Ot, /Oi, and /GF. + cflags = [ "/O2" ] + common_optimize_on_cflags +@@ -2862,7 +2909,7 @@ config("default_optimization") { + } + + _clang_sample_profile = "" +-if (is_clang && is_a_target_toolchain) { ++if (is_clang && is_a_target_toolchain && !is_mingw) { + if (clang_sample_profile_path != "") { + _clang_sample_profile = clang_sample_profile_path + } else if (clang_use_default_sample_profile) { +@@ -2965,7 +3012,7 @@ config("win_pdbaltpath") { + config("symbols") { + rustflags = [] + configs = [] +- if (is_win) { ++ if (is_msvc) { if (is_clang) { cflags = [ # Debug information in the .obj files. -@@ -2485,7 +2508,7 @@ config("symbols") { - # DWARF info may be corrupt; offsets in a range list entry are in different - # sections" there. Maybe just a bug in nacl_switch_32.S. - _enable_gdb_index = -- symbol_level == 2 && !is_apple && !is_nacl && current_cpu != "x86" && -+ symbol_level == 2 && !is_apple && !is_mingw && !is_nacl && current_cpu != "x86" && - current_os != "zos" && (use_gold || use_lld) && - # Disable on non-fission 32-bit Android because it pushes - # libcomponents_unittests over the 4gb size limit. -@@ -2536,7 +2559,7 @@ config("symbols") { - # This config guarantees to hold symbol for stack trace which are shown to user +@@ -3013,7 +3060,7 @@ config("symbols") { + + # On aix -gdwarf causes linker failures due to thread_local variables. + # On zos -gdwarf causes INSUFFICIENT ABOVE THE LINE STORAGE WAS AVAILABLE. +- if (current_os != "aix" && current_os != "zos") { ++ if (current_os != "aix" && current_os != "zos" && current_os != "win") { + if (use_dwarf5) { + cflags += [ "-gdwarf-5" ] + rustflags += [ "-Zdwarf-version=5" ] +@@ -3062,7 +3109,7 @@ config("symbols") { + ldflags += [ "-gsplit-dwarf" ] + } + +- _enable_gdb_index = symbol_level == 2 && !is_apple && use_lld && !is_wasm ++ _enable_gdb_index = symbol_level == 2 && !is_apple && use_lld && !is_wasm && !is_mingw + if (_enable_gdb_index) { + if (is_clang) { + # This flag enables the GNU-format pubnames and pubtypes sections, +@@ -3082,7 +3129,7 @@ config("symbols") { + configs += [ "//build/config:compress_debug_sections" ] + } + +- if (is_clang && is_win && !is_component_build) { ++ if (is_clang && is_msvc && !is_component_build) { + # Remove unreferenced methods to reduce type info in symbols. + # See: https://github.com/llvm/llvm-project/pull/87018. + # The downside with this flag is precisely that: Unreferenced methods get +@@ -3095,7 +3142,7 @@ config("symbols") { + cflags += [ "-gomit-unreferenced-methods" ] + } + +- if (is_clang) { ++ if (is_clang && !is_mingw) { + if (is_apple) { + # TODO(crbug.com/40117949): Investigate missing debug info on mac. + # Make sure we don't use constructor homing on mac. +@@ -3120,7 +3167,7 @@ config("symbols") { # when crash happens in unittests running on buildbot. config("minimal_symbols") { + rustflags = [] - if (is_win) { -+ if (is_msvs) { ++ if (is_msvc) { # Functions, files, and line tables only. cflags = [] -@@ -2610,7 +2633,7 @@ config("minimal_symbols") { +@@ -3155,7 +3202,7 @@ config("minimal_symbols") { + # TODO(thakis): Remove this once mac_deployment_target is 10.11. + cflags += [ "-gdwarf-4" ] + rustflags += [ "-Zdwarf-version=4" ] +- } else if (!use_dwarf5 && current_os != "aix") { ++ } else if (!use_dwarf5 && current_os != "aix" && current_os != "win") { + # On aix -gdwarf causes linker failures due to thread_local variables. + # Recent clang versions default to DWARF5 on Linux, and Android is about + # to switch. TODO: Adopt that in controlled way. +@@ -3195,7 +3242,7 @@ config("minimal_symbols") { # told to not generate debug information and the linker then just puts function # names in the final debug information. config("no_symbols") { - if (is_win) { -+ if (is_msvs) { ++ if (is_msvc) { ldflags = [ "/DEBUG" ] # All configs using /DEBUG should include this: -@@ -2710,6 +2733,11 @@ buildflag_header("compiler_buildflags") { - config("cet_shadow_stack") { - if (enable_cet_shadow_stack && is_win) { - assert(target_cpu == "x64") -- ldflags = [ "/CETCOMPAT" ] -+ if (is_mingw) { -+ ldflags = [ "-fcf-protection=full" ] -+ cflags = [ "-fcf-protection=full" ] -+ } else { -+ ldflags = [ "/CETCOMPAT" ] -+ } - } +@@ -3313,7 +3360,7 @@ buildflag_header("compiler_buildflags") { } + + config("cet_shadow_stack") { +- if (enable_cet_shadow_stack && is_win) { ++ if (enable_cet_shadow_stack && is_msvc) { + assert(target_cpu == "x64") + ldflags = [ "/CETCOMPAT" ] + } +diff --git a/config/compiler/compiler.gni b/config/compiler/compiler.gni +index 61c3779e9..90a617ad0 100644 +--- a/config/compiler/compiler.gni ++++ b/config/compiler/compiler.gni +@@ -315,7 +315,7 @@ if (symbol_level == -1) { + # info or variable info, so we can leave that out to speed up the build. + # Sanitizers also require symbols for filename suppressions to work. + symbol_level = 1 +- } else if ((!is_linux && !is_chromeos && !is_fuchsia && ++ } else if ((!is_linux && !is_chromeos && !is_fuchsia && !is_mingw && + current_os != "aix") || is_debug || is_castos || + is_cast_android) { + # Linux builds slower by having symbols as part of the target binary, diff --git a/config/linux/pkg-config.py b/config/linux/pkg-config.py -index 2e38c7ffb..0802bf760 100755 +index f4d31de67..158208895 100755 --- a/config/linux/pkg-config.py +++ b/config/linux/pkg-config.py -@@ -40,6 +40,11 @@ from optparse import OptionParser - # Additionally, you can specify the option --atleast-version. This will skip - # the normal outputting of a dictionary and instead print true or false, - # depending on the return value of pkg-config for the given package. -+# -+# --pkg_config_libdir= allows direct override -+# of the PKG_CONFIG_LIBDIR environment library. -+# -+# --full-path-libs causes lib names to include their full path. - - - def SetConfigPath(options): -@@ -103,12 +108,29 @@ def RewritePath(path, strip_prefix, sysroot): - else: - return path - -+flag_regex = re.compile("(-.)(.+)") -+ -+def FlagReplace(matchobj): -+ if matchobj.group(1) == '-I': -+ return matchobj.group(1) + subprocess.check_output([u'cygpath',u'-w',matchobj.group(2)]).strip().decode("utf-8") -+ if matchobj.group(1) == '-L': -+ return matchobj.group(1) + subprocess.check_output([u'cygpath',u'-w',matchobj.group(2)]).strip().decode("utf-8") -+ if matchobj.group(1) == '-l': -+ return matchobj.group(1) + matchobj.group(2) + '.lib' -+ return matchobj.group(0) -+ -+def ConvertGCCToMSVC(flags): -+ """Rewrites GCC flags into MSVC flags.""" -+ # need a better way to determine mingw vs msvc build -+ if 'win32' not in sys.platform or "GCC" in sys.version: -+ return flags -+ return [ flag_regex.sub(FlagReplace,flag) for flag in flags] - - def main(): +@@ -108,7 +108,7 @@ def main(): # If this is run on non-Linux platforms, just return nothing and indicate # success. This allows us to "kind of emulate" a Linux build from other # platforms. - if "linux" not in sys.platform: -+ if "linux" not in sys.platform and "win32" not in sys.platform: ++ if sys.platform not in ["linux", "win32"]: print("[[],[],[],[],[]]") return 0 -@@ -121,12 +143,15 @@ def main(): - parser.add_option('-a', action='store', dest='arch', type='string') - parser.add_option('--system_libdir', action='store', dest='system_libdir', - type='string', default='lib') -+ parser.add_option('--pkg_config_libdir', action='store', dest='pkg_config_libdir', -+ type='string') - parser.add_option('--atleast-version', action='store', - dest='atleast_version', type='string') - parser.add_option('--libdir', action='store_true', dest='libdir') - parser.add_option('--dridriverdir', action='store_true', dest='dridriverdir') - parser.add_option('--version-as-components', action='store_true', - dest='version_as_components') -+ parser.add_option('--full-path-libs', action='store_true', dest='full_path_libs') - (options, args) = parser.parse_args() - - # Make a list of regular expressions to strip out. -@@ -143,6 +168,10 @@ def main(): - else: - prefix = '' - -+ # Override PKG_CONFIG_LIBDIR -+ if options.pkg_config_libdir: -+ os.environ['PKG_CONFIG_LIBDIR'] = options.pkg_config_libdir -+ - if options.atleast_version: - # When asking for the return value, just run pkg-config and print the return - # value, no need to do other work. -@@ -202,7 +231,7 @@ def main(): - # For now just split on spaces to get the args out. This will break if - # pkgconfig returns quoted things with spaces in them, but that doesn't seem - # to happen in practice. -- all_flags = flag_string.strip().split(' ') -+ all_flags = ConvertGCCToMSVC(flag_string.strip().split(' ')) - - - sysroot = options.sysroot -@@ -219,7 +248,10 @@ def main(): - continue; - - if flag[:2] == '-l': -- libs.append(RewritePath(flag[2:], prefix, sysroot)) -+ library = RewritePath(flag[2:], prefix, sysroot) -+ # Skip math library on MSVC -+ if library != 'm.lib': -+ libs.append(library) - elif flag[:2] == '-L': - lib_dirs.append(RewritePath(flag[2:], prefix, sysroot)) - elif flag[:2] == '-I': -@@ -236,6 +268,14 @@ def main(): - else: - cflags.append(flag) - -+ if options.full_path_libs: -+ full_path_libs = [] -+ for lib_dir in lib_dirs: -+ for lib in libs: -+ if os.path.isfile(lib_dir+"/"+lib): -+ full_path_libs.append(lib_dir+"/"+lib) -+ libs = full_path_libs -+ - # Output a GN array, the first one is the cflags, the second are the libs. The - # JSON formatter prints GN compatible lists when everything is a list of - # strings. -diff --git a/config/linux/pkg_config.gni b/config/linux/pkg_config.gni -index cb9b46003..e2428abbe 100644 ---- a/config/linux/pkg_config.gni -+++ b/config/linux/pkg_config.gni -@@ -45,6 +45,9 @@ declare_args() { - # in similar fashion by setting the `system_libdir` variable in the build's - # args.gn file to 'lib' or 'lib64' as appropriate for the target architecture. - system_libdir = "lib" -+ -+ # Allow directly overriding the PKG_CONFIG_LIBDIR enviroment variable -+ pkg_config_libdir = "" - } - - pkg_config_script = "//build/config/linux/pkg-config.py" -@@ -88,6 +91,17 @@ if (host_pkg_config != "") { - host_pkg_config_args = pkg_config_args - } - -+if (pkg_config_libdir != "") { -+ pkg_config_args += [ -+ "--pkg_config_libdir", -+ pkg_config_libdir, -+ ] -+ host_pkg_config_args += [ -+ "--pkg_config_libdir", -+ pkg_config_libdir, -+ ] -+} -+ - template("pkg_config") { - assert(defined(invoker.packages), - "Variable |packages| must be defined to be a list in pkg_config.") diff --git a/config/sanitizers/BUILD.gn b/config/sanitizers/BUILD.gn -index 35b7ba7aa..710b8c2df 100644 +index e2f39f029..53e4576e7 100644 --- a/config/sanitizers/BUILD.gn +++ b/config/sanitizers/BUILD.gn -@@ -216,7 +216,7 @@ config("default_sanitizer_ldflags") { +@@ -67,7 +67,7 @@ group("deps") { + data += [ "//tools/memory/sanitizer/escalate_sanitizer_warnings.py" ] + } + if (is_asan || is_ubsan_any) { +- if (is_win || is_apple) { ++ if (is_msvc || is_apple) { + data_deps = [ ":copy_sanitizer_runtime" ] + } + if (is_apple) { +@@ -85,7 +85,7 @@ group("deps") { + assert(!(is_win && is_asan && current_cpu == "x86"), + "ASan is only supported in 64-bit builds on Windows.") + +-if ((is_apple || is_win) && (is_asan || is_ubsan_any)) { ++if ((is_apple || is_msvc) && (is_asan || is_ubsan_any)) { + _clang_rt_dso_full_path = + "$clang_base_path/lib/clang/$clang_version/lib/$clang_rt_dso_path" + +@@ -252,7 +252,7 @@ config("default_sanitizer_ldflags") { } } } - } else if (is_win) { -+ } else if (is_msvs) { ++ } else if (is_msvc) { # Windows directly calls link.exe instead of the compiler driver when # linking. Hence, pass the runtime libraries instead of -fsanitize=address # or -fsanitize=fuzzer. -@@ -317,7 +317,7 @@ config("cfi_flags") { +@@ -325,7 +325,7 @@ config("asan_flags") { + # already on for Fuchsia). Pass the flag to turn it back off. + cflags += [ "-fno-sanitize-address-globals-dead-stripping" ] + } +- if (is_win) { ++ if (is_msvc) { + if (!defined(asan_win_blocklist_path)) { + asan_win_blocklist_path = + rebase_path("//tools/memory/asan/blocklist_win.txt", root_build_dir) +@@ -379,7 +379,7 @@ config("cfi_flags") { if (use_cfi_diag) { cflags += [ "-fno-sanitize-trap=cfi" ] - if (is_win) { -+ if (is_msvs) { ++ if (is_msvc) { cflags += [ "/Oy-", "/Ob0", +diff --git a/config/sanitizers/sanitizers.gni b/config/sanitizers/sanitizers.gni +index e371f0288..07a6bcf64 100644 +--- a/config/sanitizers/sanitizers.gni ++++ b/config/sanitizers/sanitizers.gni +@@ -418,7 +418,7 @@ fuzzing_engine_add_configs = + + # Expose clang_rt dynamic lib name to the dependents that need it as an input + # when running an exeutable. +-if ((is_apple || is_win) && (is_asan || is_ubsan_any)) { ++if ((is_apple || is_msvc) && (is_asan || is_ubsan_any)) { + if (is_mac || (is_ios && target_environment == "catalyst")) { + if (is_asan) { + clang_rt_dso_path = "darwin/libclang_rt.asan_osx_dynamic.dylib" diff --git a/config/win/BUILD.gn b/config/win/BUILD.gn -index 692e7adf5..c16c471df 100644 +index aaeadc313..4803bd492 100644 --- a/config/win/BUILD.gn +++ b/config/win/BUILD.gn -@@ -50,6 +50,7 @@ declare_args() { +@@ -48,6 +48,7 @@ declare_args() { # is applied to all targets. It is here to separate out the logic that is # Windows-only. config("compiler") { -+ if (is_msvs) { ++ if (is_msvc) { if (current_cpu == "x86") { asmflags = [ # When /safeseh is specified, the linker will only produce an image if it -@@ -215,6 +216,19 @@ config("compiler") { +@@ -213,6 +214,15 @@ config("compiler") { # the source file is a no-op. "/ignore:4221", ] -+ } else { -+ if (current_cpu == "x86" || current_cpu == "x64") { -+ cflags = [ "-msse3" ] ++ } else { # is_mingw ++ cflags = [] ++ if (current_cpu != "arm64"){ ++ cflags += [ "-Wa,-mbig-obj" ] + } -+ if (current_cpu == "x86") { -+ ldflags = [ "-m32" ] -+ if (!is_clang) { -+ ldflags += [ "-Wl,--enable-stdcall-fixup" ] -+ } -+ } else if (current_cpu == "x64") { -+ ldflags = [ "-m64" ] ++ if (!is_clang) { ++ cflags += [ "-fno-keep-inline-dllexport" ] + } + } } # This is included by reference in the //build/config/compiler:runtime_library -@@ -315,19 +329,27 @@ config("sdk_link") { +@@ -301,7 +311,7 @@ config("winver") { + + # Linker flags for Windows SDK setup, this is applied only to EXEs and DLLs. + config("sdk_link") { +- if (current_cpu == "x86") { ++ if (is_msvc && current_cpu == "x86") { + ldflags = [ + "/SAFESEH", # Not compatible with x64 so use only for x86. + "/largeaddressaware", +@@ -313,19 +323,27 @@ config("sdk_link") { # targets who want different library configurations can remove this and specify # their own. config("common_linker_setup") { @@ -818,7 +858,7 @@ index 692e7adf5..c16c471df 100644 + ldflags = [ + "-Wl,-dynamicbase", + "-Wl,-nxcompat", -+ ] ++ ] + } else { + ldflags = [ + "/FIXED:NO", @@ -837,124 +877,173 @@ index 692e7adf5..c16c471df 100644 } } -@@ -336,7 +358,7 @@ config("default_cfg_compiler") { - # This is needed to allow functions to be called by code that is built +@@ -335,12 +353,14 @@ config("default_cfg_compiler") { # with CFG enabled, such as system libraries. # The CFG guards are only emitted if |win_enable_cfg_guards| is enabled. -- if (is_clang) { -+ if (is_msvs && is_clang) { - if (win_enable_cfg_guards) { + if (win_enable_cfg_guards) { +- if (is_clang) { ++ if (is_msvc && is_clang) { cflags = [ "/guard:cf" ] - } else { -@@ -351,7 +373,7 @@ config("disable_guards_cfg_compiler") { ++ } else { ++ cflags = [ "-fcf-protection" ] + } + rustflags = [ "-Ccontrol-flow-guard" ] + } else { +- if (is_clang) { ++ if (is_msvc && is_clang) { + cflags = [ "/guard:cf,nochecks" ] + } + rustflags = [ "-Ccontrol-flow-guard=nochecks" ] +@@ -353,8 +373,10 @@ config("disable_guards_cfg_compiler") { # Emit table of address-taken functions for Control-Flow Guard (CFG). # This is needed to allow functions to be called by code that is built # with CFG enabled, such as system libraries. - if (is_clang) { -+ if (is_msvs && is_clang) { ++ if (is_msvc && is_clang) { cflags = [ "/guard:cf,nochecks" ] - } - } -@@ -478,6 +500,7 @@ config("default_crt") { - # when the debug CRT is part of the bottleneck. This also avoids *implicitly* - # defining _DEBUG. - config("release_crt") { -+if (is_msvs) { - if (is_component_build) { - cflags = [ "/MD" ] - -@@ -493,8 +516,10 @@ config("release_crt") { - } - } - } -+} - - config("dynamic_crt") { -+if (is_msvs) { - if (is_debug) { - # This pulls in the DLL debug CRT and defines _DEBUG - cflags = [ "/MDd" ] -@@ -508,8 +533,10 @@ config("dynamic_crt") { - } - } - } -+} - - config("static_crt") { -+if (is_msvs) { - if (is_debug) { - # This pulls in the static debug CRT and defines _DEBUG - cflags = [ "/MTd" ] -@@ -523,27 +550,34 @@ config("static_crt") { - } - } - } -+} - - # Subsystem -------------------------------------------------------------------- - - # This is appended to the subsystem to specify a minimum version. --if (current_cpu == "x64") { -- # The number after the comma is the minimum required OS version. -- # 5.02 = Windows Server 2003. -- subsystem_version_suffix = ",5.02" --} else if (current_cpu == "arm64") { -- # Windows ARM64 requires Windows 10. -- subsystem_version_suffix = ",10.0" --} else { -- # 5.01 = Windows XP. -- subsystem_version_suffix = ",5.01" -+if (is_msvs) { -+ if (current_cpu == "x64") { -+ # The number after the comma is the minimum required OS version. -+ # 5.02 = Windows Server 2003. -+ subsystem_version_suffix = ",5.02" -+ } else if (current_cpu == "arm64") { -+ # Windows ARM64 requires Windows 10. -+ subsystem_version_suffix = ",10.0" + } else { -+ # 5.01 = Windows XP. -+ subsystem_version_suffix = ",5.01" ++ cflags = [ "-fcf-protection=none" ] + } + rustflags = [ "-Ccontrol-flow-guard=nochecks" ] + } +@@ -367,7 +389,7 @@ config("cfi_linker") { + # ASan and CFG leads to slow process startup. Chromium's test runner uses + # lots of child processes, so this means things are really slow. Disable CFG + # for now. https://crbug.com/846966 +- if (!is_debug && !is_asan) { ++ if (is_msvc && !is_debug && !is_asan) { + # Turn on CFG bitmap generation and CFG load config. + ldflags = [ "/guard:cf" ] + } +@@ -403,6 +425,7 @@ config("cfi_linker") { + # This config should also be used for any test binary whose goal is to run + # tests with the full browser. + config("delayloads") { ++ if (is_msvc) { + ldflags = [ + "/DELAYLOAD:api-ms-win-core-synch-l1-2-0.dll", + "/DELAYLOAD:api-ms-win-core-winrt-error-l1-1-0.dll", +@@ -453,11 +476,13 @@ config("delayloads") { + "/DELAYLOAD:wsock32.dll", + "/DELAYLOAD:wtsapi32.dll", + ] + } } + # This config (along with `:delayloads`) applies to chrome.exe & chrome_elf.dll. + # Entries should not appear in both configs. + config("delayloads_not_for_child_dll") { ++ if (is_msvc) { + ldflags = [ + "/DELAYLOAD:crypt32.dll", + "/DELAYLOAD:dbghelp.dll", +@@ -473,6 +498,7 @@ config("delayloads_not_for_child_dll") { + "/DELAYLOAD:wintrust.dll", + "/DELAYLOAD:ws2_32.dll", + ] ++ } + } + + # ACLs are placed on the filesystem in order to allow chrome to launch +@@ -527,7 +553,7 @@ config("default_crt") { + # when the debug CRT is part of the bottleneck. This also avoids *implicitly* + # defining _DEBUG. + config("release_crt") { +- if (is_component_build) { ++ if (is_msvc && is_component_build) { + cflags = [ "/MD" ] + + # /MD specifies msvcrt.lib as the CRT library, which is the dynamic+release +@@ -539,7 +565,7 @@ config("release_crt") { + # standard library, which libc++ needs for exception_ptr internals. + ldflags = [ "/DEFAULTLIB:msvcprt.lib" ] + } +- } else { ++ } else if (!is_mingw) { + cflags = [ "/MT" ] + + # /MT specifies libcmt.lib as the CRT library, which is the static+release +@@ -554,7 +580,7 @@ config("release_crt") { + } + + config("dynamic_crt") { +- if (is_debug) { ++ if (is_msvc && is_debug) { + # This pulls in the DLL debug CRT and defines _DEBUG + cflags = [ "/MDd" ] + +@@ -570,7 +596,7 @@ config("dynamic_crt") { + if (use_custom_libcxx) { + ldflags = [ "/DEFAULTLIB:msvcprtd.lib" ] + } +- } else { ++ } else if (!is_mingw) { + cflags = [ "/MD" ] + + # /MD specifies msvcrt.lib as the CRT library, which is the dynamic+release +@@ -584,7 +610,7 @@ config("dynamic_crt") { + } + + config("static_crt") { +- if (is_debug) { ++ if (is_msvc && is_debug) { + # This pulls in the static debug CRT and defines _DEBUG + cflags = [ "/MTd" ] + +@@ -601,7 +627,7 @@ config("static_crt") { + if (use_custom_libcxx) { + ldflags = [ "/DEFAULTLIB:libcpmtd.lib" ] + } +- } else { ++ } else if (!is_mingw) { + cflags = [ "/MT" ] + + # /MT specifies libcmt.lib as the CRT library, which is the static+release +@@ -620,13 +646,21 @@ config("static_crt") { + # This is appended to the subsystem to specify a minimum version. + # The number after the comma is the minimum required OS version. + # Set to 10.0 since we only support >= Win10 since M110. +-subsystem_version_suffix = ",10.0" ++subsystem_version_suffix = "10.0" + config("console") { - ldflags = [ "/SUBSYSTEM:CONSOLE$subsystem_version_suffix" ] -+ if (is_msvs) { -+ ldflags = [ "/SUBSYSTEM:CONSOLE$subsystem_version_suffix" ] ++ if (is_mingw) { ++ ldflags = [ "-Wl,-subsystem,console:$subsystem_version_suffix" ] ++ } else { ++ ldflags = [ "/SUBSYSTEM:CONSOLE,$subsystem_version_suffix" ] + } } config("windowed") { - ldflags = [ "/SUBSYSTEM:WINDOWS$subsystem_version_suffix" ] -+ if (is_msvs) { -+ ldflags = [ "/SUBSYSTEM:WINDOWS$subsystem_version_suffix" ] ++ if (is_mingw) { ++ ldflags = [ "-Wl,-subsystem,windows:$subsystem_version_suffix" ] ++ } else { ++ ldflags = [ "/SUBSYSTEM:WINDOWS,$subsystem_version_suffix" ] + } } # Incremental linking ---------------------------------------------------------- -@@ -609,3 +643,20 @@ config("pdb_larger_than_4gb") { +@@ -636,7 +670,7 @@ config("default_incremental_linking") { + # Enable incremental linking for debug builds and all component builds - any + # builds where performance is not job one. + # TODO(thakis): Always turn this on with lld, no reason not to. +- if (is_debug || is_component_build) { ++ if (is_msvc && (is_debug || is_component_build)) { + ldflags = [ "/INCREMENTAL" ] + if (use_lld) { + # lld doesn't use ilk files and doesn't really have an incremental link +@@ -651,7 +685,7 @@ config("default_incremental_linking") { + # in lld-link. + ldflags += [ "/OPT:NOICF" ] + } +- } else { ++ } else if (!is_mingw) { + ldflags = [ "/INCREMENTAL:NO" ] } - ldflags += [ "/pdbpagesize:8192" ] } -+ -+# Let unit tests see all "for_testing" dll symbols. -+config("export_all_symbols") { -+ if (is_mingw) { -+ ldflags = [ "-Wl,--export-all-symbols" ] -+ } -+} -+ -+# Workaround a Mingw ld bug where large debug symbol data -+# causes the produced executable to be corrupted -+# https://stackoverflow.com/questions/22261539/ld-exe-crashing-in-mingw -+# this affects mksnapshot and v8 component. -+config("strip_all_symbols_at_link_time") { -+ if (is_mingw) { -+ ldflags = [ "-Wl,--strip-all" ] -+ } -+} diff --git a/config/win/manifest.gni b/config/win/manifest.gni -index e1859eacd..bc52040b6 100644 +index 2feb96cf2..e4c3acc97 100644 --- a/config/win/manifest.gni +++ b/config/win/manifest.gni @@ -72,7 +72,7 @@ segment_heap_manifest = "//build/win/segment_heap.manifest" @@ -962,35 +1051,24 @@ index e1859eacd..bc52040b6 100644 # } -if (is_win) { -+if (is_msvs) { ++if (is_msvc) { template("windows_manifest") { config_name = "${target_name}__config" - source_set_name = target_name + diff --git a/config/win/visual_studio_version.gni b/config/win/visual_studio_version.gni -index 1da479dd5..6a22dcccd 100644 +index bd4116693..65cd9a7ed 100644 --- a/config/win/visual_studio_version.gni +++ b/config/win/visual_studio_version.gni -@@ -18,13 +18,17 @@ declare_args() { - # Full path to the Windows SDK, not including a backslash at the end. - # This value is the default location, override if you have a different - # installation location. -- windows_sdk_path = "C:\Program Files (x86)\Windows Kits\10" -+ if (is_msvs) { -+ windows_sdk_path = "C:\Program Files (x86)\Windows Kits\10" -+ } else { -+ windows_sdk_path = "" -+ } - - # Version of the Windows SDK pointed to by the windows_sdk_path. +@@ -24,7 +24,7 @@ declare_args() { windows_sdk_version = "" } -if (visual_studio_path == "") { -+if (is_msvs && visual_studio_path == "") { ++if (is_msvc && visual_studio_path == "") { toolchain_data = exec_script("../../vs_toolchain.py", [ "get_toolchain_dir" ], "scope") visual_studio_path = toolchain_data.vs_path -@@ -33,7 +37,7 @@ if (visual_studio_path == "") { +@@ -33,7 +33,7 @@ if (visual_studio_path == "") { visual_studio_version = toolchain_data.vs_version wdk_path = toolchain_data.wdk_dir visual_studio_runtime_dirs = toolchain_data.runtime_dirs @@ -1000,26 +1078,26 @@ index 1da479dd5..6a22dcccd 100644 "You must set the visual_studio_version if you set the path") assert(windows_sdk_version != "", diff --git a/toolchain/gcc_solink_wrapper.py b/toolchain/gcc_solink_wrapper.py -index 03ef04261..00dd73be8 100755 +index 0dae7ab55..df6dd9cef 100755 --- a/toolchain/gcc_solink_wrapper.py +++ b/toolchain/gcc_solink_wrapper.py -@@ -24,6 +24,8 @@ def CollectSONAME(args): - # TODO(crbug.com/1259067): Come up with a way to get this info without having +@@ -24,6 +24,9 @@ def CollectSONAME(args): + # TODO(crbug.com/40797404): Come up with a way to get this info without having # to bundle readelf in the toolchain package. toc = '' -+ if 'GCC' in sys.version and sys.platform=='win32': # Mingw's readelf doesn't work on PE files ++ # MinGW's readelf doesn't work on PE files ++ if sys.platform == 'win32' and 'GCC' in sys.version: + return 0, toc readelf = subprocess.Popen(wrapper_utils.CommandToRun( [args.readelf, '-d', args.sofile]), stdout=subprocess.PIPE, -@@ -38,6 +40,10 @@ def CollectSONAME(args): +@@ -38,6 +41,9 @@ def CollectSONAME(args): def CollectDynSym(args): """Replaces: nm --format=posix -g -D -p $sofile | cut -f1-2 -d' '""" toc = '' -+ -+ if 'GCC' in sys.version and sys.platform=='win32': # Mingw's nm doesn't work on PE/COFF files ++ # MinGW's nm doesn't work on PE/COFF files ++ if sys.platform == 'win32' and 'GCC' in sys.version: + return 0, toc -+ nm = subprocess.Popen(wrapper_utils.CommandToRun( [args.nm, '--format=posix', '-g', '-D', '-p', args.sofile]), stdout=subprocess.PIPE, @@ -1054,10 +1132,10 @@ index 03ef04261..00dd73be8 100755 if dwp_proc: dwp_result = dwp_proc.wait() diff --git a/toolchain/gcc_toolchain.gni b/toolchain/gcc_toolchain.gni -index 713c1b9fd..150d50342 100644 +index c22ec9046..b102e414e 100644 --- a/toolchain/gcc_toolchain.gni +++ b/toolchain/gcc_toolchain.gni -@@ -61,6 +61,7 @@ if (enable_resource_allowlist_generation) { +@@ -57,6 +57,7 @@ if (enable_resource_allowlist_generation) { # - cc # - cxx # - ld @@ -1065,33 +1143,25 @@ index 713c1b9fd..150d50342 100644 # # Optional parameters that control the tools: # -@@ -117,6 +118,9 @@ template("single_gcc_toolchain") { - assert(defined(invoker.cc), "gcc_toolchain() must specify a \"cc\" value") - assert(defined(invoker.cxx), "gcc_toolchain() must specify a \"cxx\" value") - assert(defined(invoker.ld), "gcc_toolchain() must specify a \"ld\" value") -+ if (is_mingw) { -+ assert(defined(invoker.rc), "gcc_toolchain() must specify a \"rc\" value") -+ } - - # This define changes when the toolchain changes, forcing a rebuild. - # Nothing should ever use this define. -@@ -309,6 +313,9 @@ template("single_gcc_toolchain") { +@@ -264,6 +265,11 @@ template("single_gcc_toolchain") { } else { nm = "nm" } -+ if (is_mingw) { ++ if (defined(invoker.rc)) { + rc = invoker.rc ++ } else { ++ rc = "windres" + } if (defined(invoker.dwp)) { dwp_switch = " --dwp=\"${invoker.dwp}\"" } else { -@@ -398,6 +405,14 @@ template("single_gcc_toolchain") { - outputs = [ "$object_subdir/{{source_name_part}}.o" ] +@@ -364,6 +370,14 @@ template("single_gcc_toolchain") { + outputs = [ "$object_subdir/{{source_name_part}}.pcm" ] } + tool("rc") { + depfile = "{{output}}.d" -+ command = "$rc -i {{source}} {{include_dirs}} -o {{output}} -O coff" ++ command = "$rc -i {{source}} -o {{output}} {{include_dirs}} -O coff" + depsformat = "gcc" + description = "RC {{output}}" + outputs = [ "$object_subdir/{{source_name_part}}.rc.o" ] @@ -1100,21 +1170,27 @@ index 713c1b9fd..150d50342 100644 tool("asm") { # For GCC we can just use the C compiler to compile assembly. depfile = "{{output}}.d" -@@ -420,10 +435,12 @@ template("single_gcc_toolchain") { +@@ -381,15 +395,17 @@ template("single_gcc_toolchain") { + } else { + rspfile = "{{output}}.rsp" + rspfile_content = "{{inputs}}" +- command = "\"$ar\" {{arflags}} -r -c -D {{output}} @\"$rspfile\"" ++ command = "\"$ar\" {{arflags}} -r -c -s {{output}} @\"$rspfile\"" + } # Remove the output file first so that ar doesn't try to modify the # existing file. - if (host_os == "win") { -+ if (is_msvs) { ++ if (host_os == "win" && !is_mingw) { tool_wrapper_path = rebase_path("//build/toolchain/win/tool_wrapper.py", root_build_dir) - command = "cmd /c $python_path $tool_wrapper_path delete-file {{output}} && $command" + command = "cmd /s /c \"\"$python_path\" $tool_wrapper_path delete-file {{output}} && $command\"" + } else if (is_mingw) { + command = "$command" } else { command = "rm -f {{output}} && $command" } -@@ -460,9 +477,12 @@ template("single_gcc_toolchain") { +@@ -426,9 +442,12 @@ template("single_gcc_toolchain") { tocfile = sofile + ".TOC" soname_flag = "" @@ -1124,24 +1200,60 @@ index 713c1b9fd..150d50342 100644 soname_flag = "-Wl,-soname=\"$soname\"" + } else if (is_mingw) { + # Have MinGW linker generate an import library -+ soname_flag = "-Wl,--out-implib=\"$sofile\".a " ++ soname_flag = "-Wl,--out-implib=\"$soname.a\"" } link_command = "$ld -shared $soname_flag {{ldflags}}${extra_ldflags} -o \"$unstripped_sofile\" @\"$rspfile\" {{rlibs}}" -@@ -470,7 +490,7 @@ template("single_gcc_toolchain") { +@@ -464,6 +483,8 @@ template("single_gcc_toolchain") { + + if (target_cpu == "mipsel" && is_component_build && is_android) { + rspfile_content = "-Wl,--start-group -Wl,--whole-archive {{inputs}} {{solibs}} -Wl,--no-whole-archive {{libs}} -Wl,--end-group" ++ } else if (current_os == "win") { ++ rspfile_content = "-Wl,--whole-archive {{inputs}} -Wl,--no-whole-archive -Wl,--start-group {{solibs}} {{libs}} -Wl,--end-group" + } else if (current_os == "aix") { + # --whole-archive, --no-whole-archive flags are not available on the aix + # ld. +@@ -606,7 +627,7 @@ template("single_gcc_toolchain") { + # We need to specify link groups, at least, for single pass linkers. I.e. + # Rust libraries are alpha-sorted instead of by dependencies so they fail + # to link if not properly ordered or grouped. +- link_command = "$ld {{ldflags}}${extra_ldflags} -o \"$unstripped_outfile\" $start_group_flag @\"$rspfile\" $end_group_flag {{solibs}} {{libs}} $start_group_flag {{rlibs}} $end_group_flag" ++ link_command = "$ld {{ldflags}}${extra_ldflags} -o \"$unstripped_outfile\" @\"$rspfile\" $start_group_flag {{solibs}} {{libs}} $end_group_flag {{rlibs}}" + + # Generate a map file to be used for binary size analysis. # Map file adds ~10% to the link time on a z620. - # With target_os="android", libchrome.so.map.gz is ~20MB. - map_switch = "" -- if (enable_linker_map) { -+ if (enable_linker_map && !is_mingw) { - map_file = "$unstripped_sofile.map.gz" - map_switch = " --map-file \"$map_file\"" - } +@@ -628,7 +649,7 @@ template("single_gcc_toolchain") { + + description = "LINK $outfile" + +- rspfile_content = "{{inputs}}" ++ rspfile_content = "-Wl,--whole-archive {{inputs}} -Wl,--no-whole-archive" + outputs = [ outfile ] + if (outfile != unstripped_outfile) { + outputs += [ unstripped_outfile ] +diff --git a/toolchain/siso.gni b/toolchain/siso.gni +index 63dea48db..f2b4456b2 100644 +--- a/toolchain/siso.gni ++++ b/toolchain/siso.gni +@@ -6,13 +6,6 @@ import("//build/config/gclient_args.gni") + # need to match with autoninja's logic. + use_siso_default = false + +-_is_ninja_used = path_exists(rebase_path(".ninja_deps", root_build_dir)) +- +-if (path_exists("//build/config/siso/.sisoenv") && +- defined(build_with_chromium) && build_with_chromium && !_is_ninja_used) { +- use_siso_default = true +-} +- + declare_args() { + # Placeholder to allow having use_siso in args.gn file. + # Explicit `use_siso` in args.gn can override default. diff --git a/toolchain/toolchain.gni b/toolchain/toolchain.gni -index 7ddeb1268..0559c8f10 100644 +index 44dbc84d0..edf5b0c35 100644 --- a/toolchain/toolchain.gni +++ b/toolchain/toolchain.gni -@@ -57,7 +57,7 @@ if (is_apple) { +@@ -67,7 +67,7 @@ if (host_os == "mac") { } # Prefix for shared library files. @@ -1150,72 +1262,91 @@ index 7ddeb1268..0559c8f10 100644 shlib_prefix = "lib" } else { shlib_prefix = "" +@@ -88,12 +88,15 @@ if (is_fuchsia) { + # four variables reduce the duplication in that boilerplate. + stamp_description = "STAMP {{output}}" + copy_description = "COPY {{source}} {{output}}" +-if (host_os == "win") { ++if (is_msvc) { + _tool_wrapper_path = + rebase_path("//build/toolchain/win/tool_wrapper.py", root_build_dir) + + stamp_command = "cmd /c type nul > \"{{output}}\"" + copy_command = "\"$python_path\" $_tool_wrapper_path recursive-mirror {{source}} {{output}}" ++} else if (is_mingw) { ++ stamp_command = "touch {{output}}" ++ copy_command = "cp -f {{source}} {{output}}" + } else { + stamp_command = "touch {{output}}" + copy_command = "ln -f {{source}} {{output}} 2>/dev/null || (rm -rf {{output}} && cp -af {{source}} {{output}})" diff --git a/toolchain/win/BUILD.gn b/toolchain/win/BUILD.gn -index 612938527..cee8c01d6 100644 +index 87d1e4aa1..60f618abf 100644 --- a/toolchain/win/BUILD.gn +++ b/toolchain/win/BUILD.gn -@@ -4,6 +4,7 @@ +@@ -15,7 +15,7 @@ assert(is_win, "Should only be running on Windows") - import("//build/config/win/visual_studio_version.gni") - import("//build/toolchain/win/toolchain.gni") -+import("//build/toolchain/gcc_toolchain.gni") - - assert(is_win, "Should only be running on Windows") - -@@ -21,16 +22,18 @@ if (current_toolchain == default_toolchain) { + # Copy the VS runtime DLL for the default toolchain to the root build directory + # so things will run. +-if (current_toolchain == default_toolchain) { ++if (is_msvc && current_toolchain == default_toolchain) { + if (is_debug) { + configuration_name = "Debug" } else { - configuration_name = "Release" - } -- exec_script("../../vs_toolchain.py", -- [ -- "copy_dlls", -- rebase_path(root_build_dir), -- configuration_name, -- target_cpu, -- ]) -+ if (is_msvs) { -+ exec_script("../../vs_toolchain.py", -+ [ -+ "copy_dlls", -+ rebase_path(root_build_dir), -+ configuration_name, -+ target_cpu, -+ ]) -+ } +@@ -30,7 +30,7 @@ if (current_toolchain == default_toolchain) { + ]) } -if (target_cpu == "x86" || target_cpu == "x64") { -+if (is_msvs && (target_cpu == "x86" || target_cpu == "x64")) { ++if (is_msvc && (target_cpu == "x86" || target_cpu == "x64")) { win_toolchains("x86") { toolchain_arch = "x86" } -@@ -39,7 +42,7 @@ if (target_cpu == "x86" || target_cpu == "x64") { +@@ -39,7 +39,7 @@ if (target_cpu == "x86" || target_cpu == "x64") { } } -if (target_cpu == "arm64") { -+if (is_msvs && target_cpu == "arm64") { ++if (is_msvc && target_cpu == "arm64") { win_toolchains("arm64") { toolchain_arch = "arm64" } -@@ -53,10 +56,12 @@ if (target_cpu == "arm64") { - # The only reason it's a separate toolchain is so that it can force - # is_component_build to false in the toolchain_args() block, because - # building nacl64.exe in component style does not work. --win_toolchains("nacl_win64") { -- toolchain_arch = "x64" -- toolchain_args = { -- is_component_build = false -+if (!is_mingw) { -+ win_toolchains("nacl_win64") { -+ toolchain_arch = "x64" -+ toolchain_args = { -+ is_component_build = false -+ } +@@ -80,3 +80,17 @@ if (target_os == "winuwp") { + } } } ++ ++if (is_mingw) { ++ mingw_toolchain("x86") { ++ toolchain_arch = "x86" ++ } ++ ++ mingw_toolchain("x64") { ++ toolchain_arch = "x64" ++ } ++ ++ mingw_toolchain("arm64") { ++ toolchain_arch = "arm64" ++ } ++} +diff --git a/toolchain/win/toolchain.gni b/toolchain/win/toolchain.gni +index 7dbd8a17e..1bf27f81d 100644 +--- a/toolchain/win/toolchain.gni ++++ b/toolchain/win/toolchain.gni +@@ -10,7 +10,12 @@ import("//build/config/win/visual_studio_version.gni") + import("//build/toolchain/cc_wrapper.gni") + import("//build/toolchain/rbe.gni") + import("//build/toolchain/toolchain.gni") +-import("//build/toolchain/win/win_toolchain_data.gni") ++ ++if (is_mingw) { ++ import("//build/toolchain/gcc_toolchain.gni") ++} else { ++ import("//build/toolchain/win/win_toolchain_data.gni") ++} -@@ -87,3 +92,29 @@ if (target_os == "winuwp") { + assert(is_win, "Should only be running on Windows") + +@@ -867,3 +872,27 @@ template("win_toolchains") { } } } @@ -1223,74 +1354,75 @@ index 612938527..cee8c01d6 100644 +template("mingw_toolchain") { + gcc_toolchain("mingw_" + target_name) { + forward_variables_from(invoker, "*") -+ cc = getenv("CC") -+ cxx = getenv("CXX") -+ ar = getenv("AR") ++ if (is_clang) { ++ cc = "clang" ++ cxx = "clang++" ++ } else { ++ cc = "gcc" ++ cxx = "g++" ++ } + ld = cxx ++ nm = "nm" ++ ar = "ar" + rc = "windres" + strip = "strip" + executable_extension = ".exe" ++ enable_linker_map = false + toolchain_args = { -+ current_cpu = target_name + current_os = "win" ++ current_cpu = toolchain_arch + } + } +} -+ -+mingw_toolchain("arm64") { -+} -+ -+mingw_toolchain("x64") { -+} -+ -+mingw_toolchain("x86") { -+} diff --git a/util/lastchange.py b/util/lastchange.py -index 98a6360b4..8a055310c 100755 +index 3321a3e86..d08562291 100755 --- a/util/lastchange.py +++ b/util/lastchange.py -@@ -191,7 +191,10 @@ def GetGitTopDirectory(source_dir): +@@ -21,8 +21,6 @@ _ROOT_DIR = os.path.abspath( + + sys.path.insert(0, _ROOT_DIR) + +-import gclient_utils +- + VersionInfo = collections.namedtuple( + "VersionInfo", ("revision_id", "revision", "commit_position", "timestamp")) + _EMPTY_VERSION_INFO = VersionInfo('0' * 40, '0' * 40, '', 0) +@@ -236,7 +234,10 @@ def GetGitTopDirectory(source_dir): Returns: The output of "git rev-parse --show-toplevel" as a string """ - return _RunGitCommand(source_dir, ['rev-parse', '--show-toplevel']) + directory = _RunGitCommand(source_dir, ['rev-parse', '--show-toplevel']) -+ if "GCC" in sys.version and sys.platform=='win32': ++ if sys.platform == 'win32' and 'GCC' in sys.version: + return subprocess.check_output(["cygpath", "-w", directory]).strip(b"\n").decode() + return directory def WriteIfChanged(file_name, contents): +@@ -264,9 +265,6 @@ def GetVersion(source_dir, commit_filter, merge_base_ref): + if 'BASE_COMMIT_SUBMISSION_MS' in os.environ: + return GetVersionInfoFromEnv() + +- if gclient_utils.IsEnvCog(): +- return _EMPTY_VERSION_INFO +- + git_top_dir = None + try: + git_top_dir = GetGitTopDirectory(source_dir) diff --git a/win/BUILD.gn b/win/BUILD.gn -index 864581851..99d81e90f 100644 +index 0c47c2c8c..e244ea4e9 100644 --- a/win/BUILD.gn +++ b/win/BUILD.gn -@@ -9,14 +9,18 @@ import("//build/config/win/manifest.gni") - # Depending on this target will cause the manifests for Chrome's default - # Windows and common control compatibility and elevation for executables. - windows_manifest("default_exe_manifest") { -- sources = [ -- as_invoker_manifest, -- common_controls_manifest, -- default_compatibility_manifest, -- ] -+ if (is_mingw) { -+ sources = [] -+ } else { -+ sources = [ -+ as_invoker_manifest, -+ common_controls_manifest, -+ default_compatibility_manifest, -+ ] -+ } +@@ -16,7 +16,7 @@ windows_manifest("default_exe_manifest") { + ] } -if (is_win) { -+if (is_msvs) { ++if (is_msvc) { assert(host_os != "mac" || target_cpu != "x86", "Windows cross-builds from Mac must be 64-bit.") -@@ -78,4 +82,8 @@ if (is_win) { +@@ -78,4 +78,8 @@ if (is_win) { } } } diff --git a/mingw-w64-angleproject/002-buildflags-fixes.patch b/mingw-w64-angleproject/002-buildflags-fixes.patch index 7c574211e6..501e464e70 100644 --- a/mingw-w64-angleproject/002-buildflags-fixes.patch +++ b/mingw-w64-angleproject/002-buildflags-fixes.patch @@ -1,8 +1,28 @@ +diff --git a/.gn b/.gn +index dc3df25a1b..7fc44a7337 100644 +--- a/.gn ++++ b/.gn +@@ -26,15 +26,6 @@ script_executable = "python3" + # These are the list of GN files that run exec_script. This allowlist exists + # to force additional review for new uses of exec_script, which is strongly + # discouraged except for gypi_to_gn calls. +-exec_script_allowlist = angle_dotfile_settings.exec_script_allowlist + +- build_dotfile_settings.exec_script_allowlist + +- [ +- "//build/config/sysroot.gni", +- "//build/config/win/BUILD.gn", +- "//build/config/win/visual_studio_version.gni", +- "//build/gn_helpers.py", +- "//build_overrides/build.gni", +- ] + + default_args = { + clang_use_chrome_plugins = false diff --git a/BUILD.gn b/BUILD.gn -index 964d511238..1a99c6095d 100644 +index 957af7e194..1935b75749 100644 --- a/BUILD.gn +++ b/BUILD.gn -@@ -14,7 +14,10 @@ if (angle_has_build) { +@@ -18,7 +18,10 @@ if (angle_has_build) { import("//build/config/linux/pkg_config.gni") import("//build/config/sanitizers/sanitizers.gni") import("//build/config/ui.gni") @@ -14,51 +34,66 @@ index 964d511238..1a99c6095d 100644 if (is_android) { # android/rules.gni can only be imported for Android targets -@@ -91,10 +94,14 @@ if (angle_build_all) { +@@ -108,10 +111,11 @@ if (angle_build_all) { ":angle", ":angle_shader_translator", ":translator_fuzzer", - ":xxhash_fuzzer", "$angle_root/samples:angle_samples", - "$angle_root/src/tests:angle_tests", -+ #"$angle_root/src/tests:angle_tests", ] + if (use_fuzzing_engine) { -+ deps += [ -+ ":xxhash_fuzzer", -+ ] ++ deps += [ ":xxhash_fuzzer" ] + } if (angle_enable_cl) { deps += [ "$angle_root/src/libOpenCL:angle_cl" ] } -@@ -271,7 +278,7 @@ config("constructor_and_destructor_warnings") { - config("extra_warnings") { - cflags = [] - -- is_gcc = !is_clang && !is_win -+ is_gcc = !is_clang && !is_msvs - - # Avoid failing builds for warnings enabled by Skia build. - if (defined(is_skia_standalone)) { -@@ -279,7 +286,7 @@ config("extra_warnings") { +@@ -339,7 +343,7 @@ config("extra_warnings") { } # Enable more default warnings on Windows. - if (is_win) { -+ if (is_msvs) { ++ if (is_msvc) { cflags += [ "/we4244", # Conversion: possible loss of data. "/we4312", # Conversion: greater size. -@@ -342,7 +349,7 @@ config("build_id_config") { +@@ -381,6 +385,17 @@ config("extra_warnings") { + ] + } + ++ if (is_mingw && !is_clang) { ++ cflags_cc = [ ++ "-Wno-conversion-null", ++ "-Wno-dangling-pointer", ++ "-Wno-deprecated-copy", ++ "-Wno-sign-compare", ++ "-Wno-stringop-truncation", ++ "-Wno-unused-function", ++ ] ++ } ++ + if (is_gcc) { + cflags_cc = [ "-Wdeprecated-copy" ] + } +@@ -402,7 +417,7 @@ config("build_id_config") { ldflags = [ "-Wl,--build-id" ] } -_use_copy_compiler_dll = angle_has_build && is_win -+_use_copy_compiler_dll = angle_has_build && is_msvs ++_use_copy_compiler_dll = angle_has_build && is_msvc if (_use_copy_compiler_dll) { copy("copy_compiler_dll") { -@@ -451,7 +458,7 @@ angle_source_set("xxhash") { +@@ -487,7 +502,7 @@ config("angle_common_config") { + + if (is_win && !angle_is_winuwp && !build_with_chromium) { + # Needed for futex support +- libs += [ "synchronization.lib" ] ++ libs += [ "synchronization" ] + } + + defines = [] +@@ -517,7 +532,7 @@ angle_source_set("xxhash") { } } @@ -67,7 +102,7 @@ index 964d511238..1a99c6095d 100644 fuzzer_test("xxhash_fuzzer") { sources = [ "src/common/third_party/xxhash/xxhash_fuzzer.cpp" ] deps = [ ":xxhash" ] -@@ -616,9 +623,9 @@ angle_static_library("angle_gpu_info_util") { +@@ -682,9 +697,9 @@ angle_static_library("angle_gpu_info_util") { if (is_win) { sources += libangle_gpu_info_util_win_sources if (!angle_is_winuwp) { @@ -79,25 +114,25 @@ index 964d511238..1a99c6095d 100644 } if (is_linux || is_chromeos) { -@@ -762,7 +769,7 @@ template("translator_lib") { - ":angle_version_info", - ] +@@ -827,7 +842,7 @@ angle_static_library("translator") { + ":angle_version_info", + ] -- if (is_win) { -+ if (is_msvs) { - # Necessary to suppress some system header xtree warnings in Release. - # For some reason this warning doesn't get triggered in Chromium - cflags = [ "/wd4718" ] -@@ -949,7 +956,7 @@ config("libANGLE_config") { +- if (is_win) { ++ if (is_msvc) { + # Necessary to suppress some system header xtree warnings in Release. + # For some reason this warning doesn't get triggered in Chromium + cflags = [ "/wd4718" ] +@@ -986,7 +1001,7 @@ config("libANGLE_config") { ldflags = [] defines += [ "LIBANGLE_IMPLEMENTATION" ] - if (is_win) { -+ if (is_msvs) { ++ if (is_msvc) { cflags += [ "/wd4530" ] # C++ exception handler used, but unwind semantics # are not enabled. } -@@ -1053,8 +1060,8 @@ angle_source_set("libANGLE_no_vulkan") { +@@ -1087,8 +1102,8 @@ angle_source_set("libANGLE_no_vulkan") { if (is_win && !angle_is_winuwp) { libs += [ @@ -108,7 +143,7 @@ index 964d511238..1a99c6095d 100644 ] } -@@ -1079,7 +1086,7 @@ angle_source_set("libANGLE_no_vulkan") { +@@ -1117,7 +1132,7 @@ angle_source_set("libANGLE_no_vulkan") { } if (angle_enable_d3d11) { @@ -117,16 +152,31 @@ index 964d511238..1a99c6095d 100644 } if (angle_enable_metal) { -@@ -1469,6 +1476,8 @@ if (angle_enable_gl_desktop_frontend) { +@@ -1129,7 +1144,7 @@ angle_source_set("libANGLE_no_vulkan") { + } + + # Enable extra Chromium style warnings for libANGLE. +- if (is_clang && angle_has_build && !is_nacl) { ++ if (is_clang && angle_has_build && !is_nacl && !is_mingw) { + suppressed_configs -= [ "//build/config/clang:find_bad_constructs" ] + } + +@@ -1467,11 +1482,14 @@ angle_static_library("libGLESv2_thin_static") { + + public_configs += [ ":angle_static_config" ] + deps = [ ":includes" ] ++ output_name = "libGLESv2_thin" + public_deps = [ ":libANGLE" ] + } angle_static_library("libGLESv2_static") { sources = libglesv2_sources + complete_static_lib = true + output_name = "libGLESv2" - if (angle_enable_gl_desktop_frontend) { - sources += libglesv2_gl_sources - defines = [ "ANGLE_ENABLE_GL_DESKTOP_FRONTEND" ] -@@ -1614,6 +1623,7 @@ if (angle_enable_vulkan) { + public_deps = [ ":libGLESv2_thin_static" ] + } + +@@ -1588,6 +1606,7 @@ if (angle_enable_vulkan) { } libEGL_template("libEGL_static") { @@ -134,24 +184,11 @@ index 964d511238..1a99c6095d 100644 target_type = "angle_static_library" public_configs = [ ":angle_static_config" ] deps = [ ":libGLESv2_static" ] -diff --git a/build_overrides/build.gni b/build_overrides/build.gni -index f9d54f2b3..40c1f8e63 100644 ---- a/build_overrides/build.gni -+++ b/build_overrides/build.gni -@@ -42,7 +42,7 @@ limit_android_deps = true - # of hardening checks. To ensure performance remains competitive, drop the - # libc++ hardening checks, since ANGLE already makes no security guarantees in - # these situations. --if (is_win) { -+if (is_msvs) { - # TODO(https://crbug.com/1418717): ANGLE uses Chromium's abseil-cpp directory. - # Since Abseil does not mark symbols as exported, Chromium uses an alternate - # approach to scrape the symbols that need to be exported and generates .def diff --git a/gni/angle.gni b/gni/angle.gni -index e946c6b6f..8862dc2f7 100644 +index bdefa2e04c..2d87b3927b 100644 --- a/gni/angle.gni +++ b/gni/angle.gni -@@ -48,7 +48,6 @@ if (angle_has_build) { +@@ -53,7 +53,6 @@ if (angle_has_build) { import("//build/config/ozone.gni") # import the ozone_platform_x11 variable import("//build/config/sanitizers/sanitizers.gni") import("//build_overrides/build.gni") @@ -159,20 +196,23 @@ index e946c6b6f..8862dc2f7 100644 if (is_android) { import("//build/config/android/config.gni") } -@@ -61,6 +60,12 @@ if (angle_has_build) { - angle_vulkan_display_mode = "headless" - } +@@ -153,7 +152,7 @@ declare_args() { + # Windows App SDK is almost UWP but for Win32, so we want all the same things + angle_is_winuwp = (is_win && target_os == "winuwp") || angle_is_winappsdk -+ if (is_mingw) { -+ declare_args() { -+ use_fuzzing_engine = false -+ } -+ } -+ - declare_args() { - angle_use_gbm = ozone_platform_gbm - angle_use_x11 = ozone_platform_x11 && !is_ggp && (is_linux || is_chromeos) -@@ -197,7 +202,7 @@ declare_args() { +- angle_is_msvc = is_win && !is_clang ++ angle_is_msvc = is_win && !is_clang && !is_mingw + + # Default to using "_angle" suffix on Android + if (is_android) { +@@ -212,13 +211,13 @@ declare_args() { + # anglebug.com/42266968 + angle_enable_wgpu = + !is_official_build && !(is_android || is_fuchsia || angle_is_winuwp) && +- (!is_win || is_clang) && (!is_linux || angle_use_x11) && ++ (!is_win || is_clang) && (!is_linux || angle_use_x11) && !is_mingw && + defined(angle_dawn_dir) + } declare_args() { # ASTC emulation is only built on standalone non-android builds @@ -181,17 +221,17 @@ index e946c6b6f..8862dc2f7 100644 } declare_args() { -@@ -274,7 +279,7 @@ declare_args() { - angle_vulkan_validation_layers_dir = - "$angle_root/third_party/vulkan-deps/vulkan-validation-layers/src" +@@ -350,7 +349,7 @@ angle_remove_configs = [] + if (angle_has_build) { + angle_remove_configs += [ "//build/config/compiler:default_include_dirs" ] -- angle_build_vulkan_system_info = angle_has_build && !angle_is_winuwp -+ angle_build_vulkan_system_info = angle_has_build && angle_enable_vulkan && !angle_is_winuwp +- if (is_clang && !is_nacl) { ++ if (is_clang && !is_nacl && !is_mingw) { + angle_remove_configs += [ "//build/config/clang:find_bad_constructs" ] + } - # Enable overlay by default when debug layers are enabled. This is currently only implemented on - # Vulkan. diff --git a/src/libANGLE/renderer/d3d/BUILD.gn b/src/libANGLE/renderer/d3d/BUILD.gn -index b5cbea8b7..054395801 100644 +index 55227c34b3..a1a027773c 100644 --- a/src/libANGLE/renderer/d3d/BUILD.gn +++ b/src/libANGLE/renderer/d3d/BUILD.gn @@ -27,14 +27,16 @@ angle_source_set("angle_d3d_shared") { @@ -199,7 +239,7 @@ index b5cbea8b7..054395801 100644 config("angle_d3d9_backend_config") { defines = [ "ANGLE_ENABLE_D3D9" ] - ldflags = [ "/DELAYLOAD:d3d9.dll" ] -+ if (is_msvs) { ++ if (is_msvc) { + ldflags = [ "/DELAYLOAD:d3d9.dll" ] + } } @@ -224,36 +264,36 @@ index b5cbea8b7..054395801 100644 public_deps = [ ":angle_d3d_shared" ] public_configs = [ ":angle_d3d11_backend_config" ] diff --git a/src/tests/BUILD.gn b/src/tests/BUILD.gn -index 440d2e0dd..f686474b5 100644 +index c0dc92ae34..d10eceb320 100644 --- a/src/tests/BUILD.gn +++ b/src/tests/BUILD.gn -@@ -3,7 +3,6 @@ +@@ -2,7 +2,6 @@ + # Use of this source code is governed by a BSD-style license that can be # found in the LICENSE file. - import("//build/config/chromecast_build.gni") -import("//testing/test.gni") import("../../gni/angle.gni") import("angle_unittests.gni") diff --git a/util/BUILD.gn b/util/BUILD.gn -index 89bfb5362..9a1fd3a07 100644 +index 6cff850678..ff8e74551d 100644 --- a/util/BUILD.gn +++ b/util/BUILD.gn -@@ -379,7 +379,7 @@ foreach(is_shared_library, +@@ -396,7 +396,7 @@ foreach(is_shared_library, } } -if (is_win && !angle_is_winuwp) { -+if (is_msvs && !angle_is_winuwp) { ++if (is_msvc && !angle_is_winuwp) { angle_source_set("angle_stack_walker") { sources = [ "windows/third_party/StackWalker/src/StackWalker.cpp", -@@ -435,7 +435,7 @@ angle_source_set("angle_test_utils") { +@@ -452,7 +452,7 @@ angle_source_set("angle_test_utils") { sources += [ "windows/test_utils_win.cpp" ] if (angle_is_winuwp) { sources += [ "windows/test_utils_winuwp.cpp" ] - } else { -+ } else if (is_msvs) { ++ } else if (is_msvc) { deps += [ ":angle_stack_walker" ] sources += [ "windows/win32/test_utils_win32.cpp" ] } diff --git a/mingw-w64-angleproject/003-angle-src-fixes.patch b/mingw-w64-angleproject/003-angle-src-fixes.patch index 644bcd79d9..e642eb1225 100644 --- a/mingw-w64-angleproject/003-angle-src-fixes.patch +++ b/mingw-w64-angleproject/003-angle-src-fixes.patch @@ -1,38 +1,5 @@ -diff --git a/src/common/mathutil.h b/src/common/mathutil.h -index d142b35de..46b9eac13 100644 ---- a/src/common/mathutil.h -+++ b/src/common/mathutil.h -@@ -1032,8 +1032,8 @@ inline uint32_t BitfieldReverse(uint32_t value) - } - - // Count the 1 bits. --#if defined(_MSC_VER) && !defined(__clang__) --# if defined(_M_IX86) || defined(_M_X64) -+#if defined(ANGLE_PLATFORM_WINDOWS) && !defined(__clang__) -+# if defined(_M_IX86) || defined(_M_X64) || defined(__i386__) || defined(__x86_64__) - namespace priv - { - // Check POPCNT instruction support and cache the result. -@@ -1076,7 +1076,7 @@ inline int BitCount(uint64_t bits) - { - if (priv::kHasPopcnt) - { --# if defined(_M_X64) -+# if defined(_M_X64) || defined(__x86_64__) - return static_cast(__popcnt64(bits)); - # else // x86 - return static_cast(__popcnt(static_cast(bits >> 32)) + -@@ -1109,7 +1109,7 @@ inline int BitCount(uint64_t bits) - return static_cast(vget_lane_u64(vpaddl_u32(vpaddl_u16(vpaddl_u8(vsum))), 0)); - } - # endif // defined(_M_IX86) || defined(_M_X64) --#endif // defined(_MSC_VER) && !defined(__clang__) -+#endif // defined(ANGLE_PLATFORM_WINDOWS) && !defined(__clang__) - - #if defined(ANGLE_PLATFORM_POSIX) || defined(__clang__) - inline int BitCount(uint32_t bits) diff --git a/src/common/serializer/JsonSerializer.cpp b/src/common/serializer/JsonSerializer.cpp -index 0028331d9..e675c406b 100644 +index 0028331d9b..e675c406b8 100644 --- a/src/common/serializer/JsonSerializer.cpp +++ b/src/common/serializer/JsonSerializer.cpp @@ -173,7 +173,7 @@ void JsonSerializer::addValue(const std::string &name, rapidjson::Value &&value) @@ -44,24 +11,69 @@ index 0028331d9..e675c406b 100644 mDoc.AddMember(nameValue, std::move(value), mAllocator); } } -diff --git a/src/compiler/translator/Compiler.cpp b/src/compiler/translator/Compiler.cpp -index 485b4bd38..cbe275733 100644 ---- a/src/compiler/translator/Compiler.cpp -+++ b/src/compiler/translator/Compiler.cpp -@@ -1213,7 +1213,7 @@ bool TCompiler::checkAndSimplifyAST(TIntermBlock *root, +diff --git a/src/libANGLE/renderer/gl/renderergl_utils.cpp b/src/libANGLE/renderer/gl/renderergl_utils.cpp +index c62bb468dd..1fb6e91716 100644 +--- a/src/libANGLE/renderer/gl/renderergl_utils.cpp ++++ b/src/libANGLE/renderer/gl/renderergl_utils.cpp +@@ -2288,9 +2288,9 @@ void InitializeFeatures(const FunctionsGL *functions, angle::FeaturesGL *feature + // Mesa always exposes ASTC extension but only Intel Gen9, Gen11, and Gen12 have hardware + // support for it. Newer Intel GPUs (Gen12.5+) do not support ASTC. + ANGLE_FEATURE_CONDITION(features, allowAstcFormats, +- !isMesa || isIntel && (Is9thGenIntel(device) || IsGeminiLake(device) || ++ !isMesa || (isIntel && (Is9thGenIntel(device) || IsGeminiLake(device) || + IsCoffeeLake(device) || Is11thGenIntel(device) || +- Is12thGenIntel(device))); ++ Is12thGenIntel(device)))); - bool TCompiler::resizeClipAndCullDistanceBuiltins(TIntermBlock *root) - { -- auto resizeVariable = [=](const ImmutableString &name, uint32_t size, uint32_t maxSize) { -+ auto resizeVariable = [=, this](const ImmutableString &name, uint32_t size, uint32_t maxSize) { - // Skip if the variable is not used or implicitly has the maximum size - if (size == 0 || size == maxSize) - return true; + // Ported from gpu_driver_bug_list.json (#183) + ANGLE_FEATURE_CONDITION(features, emulateAbsIntFunction, IsApple() && isIntel); +diff --git a/src/libANGLE/renderer/vulkan/CommandQueue.h b/src/libANGLE/renderer/vulkan/CommandQueue.h +index bd2bb019a8..6f46f8c9da 100644 +--- a/src/libANGLE/renderer/vulkan/CommandQueue.h ++++ b/src/libANGLE/renderer/vulkan/CommandQueue.h +@@ -591,8 +591,8 @@ class [[nodiscard]] ScopedPrimaryCommandBuffer final + + DeviceScoped unlockAndRelease() + { +- ASSERT(mCommandBuffer.get().valid() && mPoolLock.owns_lock() || +- !mCommandBuffer.get().valid() && mPoolLock.mutex() == nullptr); ++ ASSERT((mCommandBuffer.get().valid() && mPoolLock.owns_lock()) || ++ (!mCommandBuffer.get().valid() && mPoolLock.mutex() == nullptr)); + mPoolLock = {}; + return std::move(mCommandBuffer); + } +diff --git a/src/libANGLE/renderer/vulkan/ProgramExecutableVk.cpp b/src/libANGLE/renderer/vulkan/ProgramExecutableVk.cpp +index 124155117c..ee33f139cf 100644 +--- a/src/libANGLE/renderer/vulkan/ProgramExecutableVk.cpp ++++ b/src/libANGLE/renderer/vulkan/ProgramExecutableVk.cpp +@@ -2037,11 +2037,6 @@ angle::Result ProgramExecutableVk::updateTexturesDescriptorSet( + if (newSharedCacheKey) + { + ASSERT(newSharedCacheKey->valid()); +- ANGLE_TRY(UpdateFullTexturesDescriptorSet( +- context, mVariableInfoMap, mTextureWriteDescriptorDescs, updateBuilder, +- *mExecutable, textures, samplers, +- mDescriptorSets[DescriptorSetIndex::Texture]->getDescriptorSet())); +- + const gl::ActiveTextureMask &activeTextureMask = mExecutable->getActiveSamplersMask(); + for (size_t textureUnit : activeTextureMask) + { +@@ -2056,10 +2051,6 @@ angle::Result ProgramExecutableVk::updateTexturesDescriptorSet( + context, *mDescriptorSetLayouts[DescriptorSetIndex::Texture], + &mDescriptorSets[DescriptorSetIndex::Texture])); + ASSERT(mDescriptorSets[DescriptorSetIndex::Texture]); +- +- ANGLE_TRY(UpdateFullTexturesDescriptorSet( +- context, mVariableInfoMap, mTextureWriteDescriptorDescs, updateBuilder, *mExecutable, +- textures, samplers, mDescriptorSets[DescriptorSetIndex::Texture]->getDescriptorSet())); + } + + mValidDescriptorSetIndices.set(DescriptorSetIndex::Texture); diff --git a/util/capture/frame_capture_test_utils.cpp b/util/capture/frame_capture_test_utils.cpp -index 427844c5d..8c549d1b3 100644 +index 13dc463dc6..9941adb4c4 100644 --- a/util/capture/frame_capture_test_utils.cpp +++ b/util/capture/frame_capture_test_utils.cpp -@@ -84,7 +84,7 @@ bool LoadTraceInfoFromJSON(const std::string &traceName, +@@ -170,7 +170,7 @@ bool LoadTraceInfoFromJSON(const std::string &traceName, return false; } @@ -69,4 +81,4 @@ index 427844c5d..8c549d1b3 100644 + const rapidjson::Document::Object &meta = doc["TraceMetadata"].GetObject(); strncpy(traceInfoOut->name, traceName.c_str(), kTraceInfoMaxNameLen); - traceInfoOut->contextClientMajorVersion = meta["ContextClientMajorVersion"].GetInt(); + traceInfoOut->frameEnd = meta["FrameEnd"].GetInt(); diff --git a/mingw-w64-angleproject/004-swiftshader-updates.patch b/mingw-w64-angleproject/004-swiftshader-updates.patch index 5774dbe9ff..6cf463ce8f 100644 --- a/mingw-w64-angleproject/004-swiftshader-updates.patch +++ b/mingw-w64-angleproject/004-swiftshader-updates.patch @@ -1,5 +1,18 @@ +diff --git a/BUILD.gn b/BUILD.gn +index b405f5122..4c9ad3d45 100644 +--- a/BUILD.gn ++++ b/BUILD.gn +@@ -34,7 +34,7 @@ config("swiftshader_config") { + defines += [ "_ENABLE_EXTENDED_ALIGNED_STORAGE" ] + + # Diable some MSVC warnings. +- if (!is_clang) { ++ if (!is_clang && !is_mingw) { + cflags += [ + "/wd4065", # switch statement contains 'default' but no 'case' labels + "/wd4309", # Truncation of constant value. See PixelRoutine.cpp casts diff --git a/src/Reactor/BUILD.gn b/src/Reactor/BUILD.gn -index 67dfeb0ec..5df50ba8a 100644 +index 67dfeb0ec..379bb6468 100644 --- a/src/Reactor/BUILD.gn +++ b/src/Reactor/BUILD.gn @@ -16,7 +16,7 @@ import("reactor.gni") @@ -7,19 +20,29 @@ index 67dfeb0ec..5df50ba8a 100644 config("swiftshader_llvm_reactor_private_config") { - if (is_win) { -+ if (is_msvs) { ++ if (is_msvc) { cflags = [ "/wd4141", # 'inline' used more than once. (LLVM 7.0) "/wd4146", # unary minus operator applied to unsigned type. (LLVM 7.0) -@@ -104,12 +104,19 @@ if (supports_subzero) { +@@ -25,6 +25,8 @@ config("swiftshader_llvm_reactor_private_config") { + "/wd4245", # conversion from int to unsigned int (llvm) + "/wd4624", # destructor was implicitly defined as deleted (LLVM 7.0) + ] ++ } else if (is_mingw) { ++ cflags = [ "-Wno-missing-template-keyword" ] + } else { + cflags = [ "-Wno-unused-local-typedef" ] + } +@@ -104,12 +106,20 @@ if (supports_subzero) { } else if (is_mac) { include_dirs += [ "../../third_party/llvm-subzero/build/MacOS/include/" ] } + -+ if (is_clang) { ++ if (is_mingw) { + defines += [ + "__STDC_CONSTANT_MACROS", -+ "__STDC_LIMIT_MACROS" ++ "__STDC_FORMAT_MACROS", ++ "__STDC_LIMIT_MACROS", + ] + } } @@ -28,21 +51,21 @@ index 67dfeb0ec..5df50ba8a 100644 cflags = [] - if (is_win) { -+ if (is_msvs) { ++ if (is_msvc) { cflags += [ "/wd4005", "/wd4018", -@@ -155,7 +162,7 @@ if (supports_subzero) { +@@ -155,7 +165,7 @@ if (supports_subzero) { config("swiftshader_reactor_with_subzero_private_config") { cflags = [] - if (is_win) { -+ if (is_msvs) { ++ if (is_msvc) { cflags += [ "/wd4141", "/wd4146", diff --git a/src/Reactor/SubzeroReactor.cpp b/src/Reactor/SubzeroReactor.cpp -index 0a4e9d2ce..0d282b0d3 100644 +index c0c6b1d6e..c33dd10c5 100644 --- a/src/Reactor/SubzeroReactor.cpp +++ b/src/Reactor/SubzeroReactor.cpp @@ -286,7 +286,7 @@ private: @@ -55,12 +78,21 @@ index 0a4e9d2ce..0d282b0d3 100644 # else __asm volatile("cpuid" diff --git a/src/Vulkan/BUILD.gn b/src/Vulkan/BUILD.gn -index 5556abdf0..4bc957ba8 100644 +index 852068cad..c70307160 100644 --- a/src/Vulkan/BUILD.gn +++ b/src/Vulkan/BUILD.gn -@@ -183,8 +183,10 @@ swiftshader_shared_library("swiftshader_libvulkan") { - "vk_swiftshader.def", - ] +@@ -50,7 +50,7 @@ config("swiftshader_libvulkan_private_config") { + defines = [ "VK_EXPORT=" ] + } + +- if (is_clang) { ++ if (is_clang || is_mingw) { + cflags = [ + "-Wno-unused-private-field", + "-Wno-switch", +@@ -172,8 +172,10 @@ swiftshader_source_set("_swiftshader_libvulkan") { + + if (is_win) { libs += [ - "gdi32.lib", - "user32.lib", @@ -71,17 +103,51 @@ index 5556abdf0..4bc957ba8 100644 ] } -@@ -237,7 +239,7 @@ action("icd_file") { +@@ -200,7 +202,7 @@ swiftshader_source_set("_swiftshader_libvulkan") { + + swiftshader_shared_library("swiftshader_libvulkan") { + # TODO(capn): Use the same ICD name on both Windows and non-Windows. +- if (is_win) { ++ if (is_msvc) { + output_name = "vk_swiftshader" + } else { + output_name = "libvk_swiftshader" +@@ -242,8 +244,10 @@ action("icd_file") { + output_icd_file = "${root_out_dir}/${swiftshader_icd_file_name}" input_file = swiftshader_icd_file_name - if (is_win) { -- library_path = ".\\vk_swiftshader.dll" +- if (is_win) { ++ if (is_msvc) { + library_path = ".\\vk_swiftshader.dll" ++ } else if (is_mingw) { + library_path = "./libvk_swiftshader.dll" } else if (is_mac) { library_path = "./libvk_swiftshader.dylib" } else if (is_fuchsia) { +diff --git a/third_party/SPIRV-Tools/BUILD.gn b/third_party/SPIRV-Tools/BUILD.gn +index 4848fddd0..7da529600 100644 +--- a/third_party/SPIRV-Tools/BUILD.gn ++++ b/third_party/SPIRV-Tools/BUILD.gn +@@ -374,7 +374,7 @@ config("spvtools_internal_config") { + "-Wno-unreachable-code-break", + "-Wno-unreachable-code-return", + ] +- } else if (!is_win) { ++ } else if (!is_msvc) { + # Work around a false-positive on a Skia GCC 10 builder. + cflags += [ "-Wno-format-truncation" ] + } else { +@@ -382,7 +382,7 @@ config("spvtools_internal_config") { + cflags += [ "/Zc:__cplusplus" ] + } + +- if (!is_win) { ++ if (!is_msvc) { + cflags += [ "-std=c++17" ] + } else { + cflags += [ "/std:c++17" ] diff --git a/third_party/llvm-10.0/BUILD.gn b/third_party/llvm-10.0/BUILD.gn -index 59e52303c..09ca85108 100644 +index f99abba37..46754bbc0 100644 --- a/third_party/llvm-10.0/BUILD.gn +++ b/third_party/llvm-10.0/BUILD.gn @@ -18,7 +18,7 @@ import("../../src/swiftshader.gni") @@ -89,10 +155,50 @@ index 59e52303c..09ca85108 100644 cflags = [] - if (is_win) { -+ if (is_msvs) { ++ if (is_msvc) { cflags += [ "/wd4005", "/wd4018", +@@ -53,6 +53,18 @@ config("swiftshader_llvm_private_config") { + "-Wno-macro-redefined", + ] + } ++ } else if (is_mingw) { ++ cflags += [ ++ "-Wno-format", ++ "-Wno-sign-compare", ++ ] ++ if (!is_clang) { ++ cflags_cc = [ ++ "-Wno-cast-user-defined", ++ "-Wno-init-list-lifetime", ++ "-Wno-missing-template-keyword", ++ ] ++ } + } + + if (is_fuchsia) { +@@ -80,6 +92,7 @@ config("swiftshader_llvm_private_config") { + + defines = [ + "__STDC_CONSTANT_MACROS", ++ "__STDC_FORMAT_MACROS", + "__STDC_LIMIT_MACROS", + ] + } +diff --git a/third_party/llvm-10.0/llvm/include/llvm/Support/Threading.h b/third_party/llvm-10.0/llvm/include/llvm/Support/Threading.h +index bacab8fa2..16ddf6d20 100644 +--- a/third_party/llvm-10.0/llvm/include/llvm/Support/Threading.h ++++ b/third_party/llvm-10.0/llvm/include/llvm/Support/Threading.h +@@ -18,7 +18,7 @@ + #include "llvm/ADT/SmallVector.h" + #include "llvm/Config/llvm-config.h" // for LLVM_ON_UNIX + #include "llvm/Support/Compiler.h" +-#include // So we can check the C++ standard lib macros. ++#include // So we can check the C++ standard lib macros. + #include + + #if defined(_MSC_VER) diff --git a/third_party/llvm-10.0/llvm/include/llvm/Support/Windows/WindowsSupport.h b/third_party/llvm-10.0/llvm/include/llvm/Support/Windows/WindowsSupport.h index bb7e79b86..640c00eed 100644 --- a/third_party/llvm-10.0/llvm/include/llvm/Support/Windows/WindowsSupport.h @@ -120,6 +226,35 @@ index a9463024c..2df917cc7 100644 # include # include #endif +diff --git a/third_party/llvm-subzero/include/llvm/Support/Atomic.h b/third_party/llvm-subzero/include/llvm/Support/Atomic.h +index d03714b00..552313f0c 100644 +--- a/third_party/llvm-subzero/include/llvm/Support/Atomic.h ++++ b/third_party/llvm-subzero/include/llvm/Support/Atomic.h +@@ -20,6 +20,11 @@ + + #include "llvm/Support/DataTypes.h" + ++// Windows will at times define MemoryFence. ++#ifdef MemoryFence ++#undef MemoryFence ++#endif ++ + namespace llvm { + namespace sys { + void MemoryFence(); +diff --git a/third_party/llvm-subzero/include/llvm/Support/Threading.h b/third_party/llvm-subzero/include/llvm/Support/Threading.h +index 4bef7ec8d..be8da3621 100644 +--- a/third_party/llvm-subzero/include/llvm/Support/Threading.h ++++ b/third_party/llvm-subzero/include/llvm/Support/Threading.h +@@ -17,7 +17,7 @@ + + #include "llvm/Config/llvm-config.h" // for LLVM_ON_UNIX + #include "llvm/Support/Compiler.h" +-#include // So we can check the C++ standard lib macros. ++#include // So we can check the C++ standard lib macros. + #include + + // std::call_once from libc++ is used on all Unix platforms. Other diff --git a/third_party/llvm-subzero/lib/Support/ErrorHandling.cpp b/third_party/llvm-subzero/lib/Support/ErrorHandling.cpp index a7d3a1800..191264b4b 100644 --- a/third_party/llvm-subzero/lib/Support/ErrorHandling.cpp @@ -134,17 +269,16 @@ index a7d3a1800..191264b4b 100644 # include #endif diff --git a/third_party/llvm-subzero/lib/Support/Timer.cpp b/third_party/llvm-subzero/lib/Support/Timer.cpp -index fbd73d0b6..c9d17a53b 100644 +index 7e95b4514..420b6d1ac 100644 --- a/third_party/llvm-subzero/lib/Support/Timer.cpp +++ b/third_party/llvm-subzero/lib/Support/Timer.cpp -@@ -174,7 +174,7 @@ void TimeRecord::print(const TimeRecord &Total, raw_ostream &OS) const { - OS << " "; - - if (Total.getMemUsed()) -- OS << format("%9" PRId64 " ", (int64_t)getMemUsed()); -+ OS << format("%9lld ", (int64_t)getMemUsed()); - } - +@@ -22,6 +22,7 @@ + #include "llvm/Support/Process.h" + #include "llvm/Support/YAMLTraits.h" + #include "llvm/Support/raw_ostream.h" ++#include + #include + using namespace llvm; diff --git a/third_party/llvm-subzero/lib/Support/Windows/Process.inc b/third_party/llvm-subzero/lib/Support/Windows/Process.inc index 8d646b321..2d56e4c0d 100644 @@ -195,22 +329,19 @@ index c358b99ab..d67b21ec8 100644 #define NOMINMAX #endif diff --git a/third_party/marl/BUILD.gn b/third_party/marl/BUILD.gn -index 4c0264892..ccd1c482a 100644 +index 4c0264892..ad8ee6239 100644 --- a/third_party/marl/BUILD.gn +++ b/third_party/marl/BUILD.gn -@@ -14,7 +14,9 @@ +@@ -14,7 +14,6 @@ import("../../src/swiftshader.gni") -import("//testing/test.gni") -+if (build_with_chromium) { -+ import("//testing/test.gni") -+} config("marl_config") { include_dirs = [ "include" ] diff --git a/third_party/marl/src/scheduler.cpp b/third_party/marl/src/scheduler.cpp -index f5e9df0ec..c762e5dde 100644 +index 51bb27b44..fd2cf6c0c 100644 --- a/third_party/marl/src/scheduler.cpp +++ b/third_party/marl/src/scheduler.cpp @@ -20,7 +20,7 @@ @@ -231,19 +362,6 @@ index f5e9df0ec..c762e5dde 100644 __nop(); #else __asm__ __volatile__("nop"); -diff --git a/third_party/subzero/CMakeLists.txt b/third_party/subzero/CMakeLists.txt -index aec878b79..7c9fc9f2e 100644 ---- a/third_party/subzero/CMakeLists.txt -+++ b/third_party/subzero/CMakeLists.txt -@@ -78,7 +78,7 @@ else() - message(WARNING "Architecture '${ARCH}' not supported by Subzero") - endif() - --if(WIN32) -+if(MSVC) - list(APPEND SUBZERO_COMPILE_OPTIONS - "/wd4146" # unary minus operator applied to unsigned type, result still unsigned - "/wd4334" # ''operator' : result of 32-bit shift implicitly converted to 64 bits (was 64-bit shift intended?) diff --git a/third_party/subzero/src/IceTargetLowering.cpp b/third_party/subzero/src/IceTargetLowering.cpp index ab09b48cb..64cca4cda 100644 --- a/third_party/subzero/src/IceTargetLowering.cpp diff --git a/mingw-w64-angleproject/005-vulkan-memory-allocator-updates.patch b/mingw-w64-angleproject/005-vulkan-memory-allocator-updates.patch index 80b884b323..1c5b665171 100644 --- a/mingw-w64-angleproject/005-vulkan-memory-allocator-updates.patch +++ b/mingw-w64-angleproject/005-vulkan-memory-allocator-updates.patch @@ -1,38 +1,48 @@ diff --git a/BUILD.gn b/BUILD.gn -index 97aab3a..4b1ddd6 100644 +index 97aab3a..036c36a 100644 --- a/BUILD.gn +++ b/BUILD.gn -@@ -22,7 +22,7 @@ config("vulkan_memory_allocator_config") { +@@ -22,10 +22,12 @@ config("vulkan_memory_allocator_config") { "-Wno-unused-variable", ] } - if (is_win && !is_clang) { -+ if (is_msvs && !is_clang) { ++ if (is_msvc && !is_clang) { cflags_cc = [ "/wd4189", # local variable is initialized but not referenced ] ++ } else if (is_mingw && !is_clang) { ++ cflags_cc = [ "-Wno-unused-variable" ] + } + defines = [ + "VMA_DYNAMIC_VULKAN_FUNCTIONS=0", diff --git a/include/vk_mem_alloc.h b/include/vk_mem_alloc.h -index 8091bae..cb49117 100644 +index 0bbfeed..7871149 100644 --- a/include/vk_mem_alloc.h +++ b/include/vk_mem_alloc.h -@@ -2485,6 +2485,7 @@ remove them if not needed. - #include // for assert - #include // for min, max - #include -+#include // for snprintf - - #ifndef VMA_NULL - // Value used as null pointer. Define it to e.g.: nullptr, NULL, 0, (void*)0. +@@ -2704,6 +2704,7 @@ remove them if not needed. + #include // for assert + #include // for min, max + #include ++ #include // for snprintf + #else + #include VMA_CONFIGURATION_USER_INCLUDES_H + #endif diff --git a/vulkan_memory_allocator.gni b/vulkan_memory_allocator.gni -index 4aa2d79..0cf24b2 100644 +index 4aa2d79..368b847 100644 --- a/vulkan_memory_allocator.gni +++ b/vulkan_memory_allocator.gni -@@ -26,7 +26,7 @@ template("vulkan_memory_allocator") { +@@ -26,10 +26,12 @@ template("vulkan_memory_allocator") { "-Wno-unused-variable", ] } - if (is_win && !is_clang) { -+ if (is_msvs && !is_clang) { ++ if (is_msvc && !is_clang) { cflags_cc = [ "/wd4189", # local variable is initialized but not referenced ] ++ } else if (is_mingw && !is_clang) { ++ cflags_cc = [ "-Wno-unused-variable" ] + } + } + diff --git a/mingw-w64-angleproject/006-spirv-updates.patch b/mingw-w64-angleproject/006-spirv-updates.patch index b0657ff8db..2da91bd66d 100644 --- a/mingw-w64-angleproject/006-spirv-updates.patch +++ b/mingw-w64-angleproject/006-spirv-updates.patch @@ -1,22 +1,22 @@ diff --git a/BUILD.gn b/BUILD.gn -index 44954b2d..0e62c356 100644 +index 7cf33942..e12f62e1 100644 --- a/BUILD.gn +++ b/BUILD.gn -@@ -367,7 +367,7 @@ config("spvtools_internal_config") { +@@ -188,7 +188,7 @@ config("spvtools_internal_config") { "-Wno-unreachable-code-break", "-Wno-unreachable-code-return", ] - } else if (!is_win) { -+ } else if (!is_msvs) { ++ } else if (!is_msvc) { # Work around a false-positive on a Skia GCC 10 builder. cflags += [ "-Wno-format-truncation" ] } else { -@@ -375,7 +375,7 @@ config("spvtools_internal_config") { +@@ -196,7 +196,7 @@ config("spvtools_internal_config") { cflags += [ "/Zc:__cplusplus" ] } - if (!is_win) { -+ if (!is_msvs) { ++ if (!is_msvc) { cflags += [ "-std=c++17" ] } else { cflags += [ "/std:c++17" ] diff --git a/mingw-w64-angleproject/007-vulkan-loader-updates.patch b/mingw-w64-angleproject/007-vulkan-loader-updates.patch index 62758130f7..ecd5a5397c 100644 --- a/mingw-w64-angleproject/007-vulkan-loader-updates.patch +++ b/mingw-w64-angleproject/007-vulkan-loader-updates.patch @@ -1,54 +1,63 @@ diff --git a/BUILD.gn b/BUILD.gn -index 7bbd39316..45f0d588c 100644 +index 5a73707d4..847d5710b 100644 --- a/BUILD.gn +++ b/BUILD.gn -@@ -80,7 +80,7 @@ config("vulkan_loader_config") { - "LOADER_USE_UNSAFE_FILE_SEARCH=1", +@@ -37,8 +37,8 @@ if (is_win) { + + config("vulkan_internal_config") { + defines = [ "VK_ENABLE_BETA_EXTENSIONS" ] +- if (is_clang || !is_win) { +- cflags = [ ++ if (is_clang || !is_msvc) { ++ cflags_cc = [ + "-Wno-conversion", + "-Wno-extra-semi", + "-Wno-sign-compare", +@@ -78,7 +78,7 @@ config("vulkan_loader_config") { ] + cflags = [] - if (is_win) { -+ if (is_msvs) { - cflags = [ "/wd4201" ] ++ if (is_msvc) { + cflags += [ "/wd4201" ] } if (is_linux || is_chromeos) { -@@ -146,7 +146,7 @@ if (!is_android) { +@@ -222,7 +222,7 @@ if (!is_android) { if (custom_vulkan_loader_library_name != "") { output_name = custom_vulkan_loader_library_name } else { - if (is_win) { -+ if (is_msvs) { ++ if (is_msvc) { output_name = "vulkan-1" } else { output_name = "vulkan" -@@ -164,10 +164,14 @@ if (!is_android) { - "loader/dirent_on_windows.h", - "loader/loader_windows.c", - "loader/loader_windows.h", -- "loader/loader.rc", -- "loader/vulkan-1.def", +@@ -244,7 +244,14 @@ if (!is_android) { + "$target_gen_dir/loader.rc", + "loader/vulkan-1.def", ] - if (!is_clang) { -+ if (vulkan_loader_shared) { -+ sources += [ -+ "loader/loader.rc", ++ if (is_mingw) { ++ sources -= [ ++ "$target_gen_dir/loader.rc", + "loader/vulkan-1.def", + ] ++ defines = [ "BUILD_STATIC_LOADER" ] + } -+ if (is_msvs && !is_clang) { ++ if (is_msvc && !is_clang) { cflags = [ "/wd4054", # Type cast from function pointer "/wd4055", # Type cast from data pointer -@@ -186,7 +190,7 @@ if (!is_android) { +@@ -263,7 +270,7 @@ if (!is_android) { if (is_clang) { cflags = [ "-Wno-incompatible-pointer-types" ] } - libs = [ "Cfgmgr32.lib" ] + libs = [ "cfgmgr32" ] + deps += [ ":gen_loader_rc" ] } if (is_linux || is_chromeos) { - sources += [ diff --git a/loader/loader_windows.c b/loader/loader_windows.c -index f9f2ddae8..1a0d999d7 100644 +index f73659c09..b8f701f15 100644 --- a/loader/loader_windows.c +++ b/loader/loader_windows.c @@ -95,6 +95,7 @@ void windows_initialization(void) { @@ -59,7 +68,7 @@ index f9f2ddae8..1a0d999d7 100644 BOOL WINAPI DllMain(HINSTANCE hinst, DWORD reason, LPVOID reserved) { (void)hinst; switch (reason) { -@@ -112,6 +113,7 @@ BOOL WINAPI DllMain(HINSTANCE hinst, DWORD reason, LPVOID reserved) { +@@ -116,6 +117,7 @@ BOOL WINAPI DllMain(HINSTANCE hinst, DWORD reason, LPVOID reserved) { } return TRUE; } diff --git a/mingw-w64-angleproject/PKGBUILD b/mingw-w64-angleproject/PKGBUILD index 767f106f5e..4654ea2b6a 100644 --- a/mingw-w64-angleproject/PKGBUILD +++ b/mingw-w64-angleproject/PKGBUILD @@ -5,12 +5,14 @@ _realname=angleproject pkgbase=mingw-w64-${_realname} pkgname="${MINGW_PACKAGE_PREFIX}-${_realname}" -pkgver=2.1.r21358.2e285bb5 -pkgrel=9 +pkgver=2.1.r25748.890b5d8f +pkgrel=1 pkgdesc='A conformant OpenGL ES implementation for Windows, Mac, Linux, iOS and Android (mingw-w64)' arch=('any') mingw_arch=('mingw64' 'ucrt64' 'clang64' 'clangarm64') -url='https://chromium.googlesource.com/angle/angle' +url='http://angleproject.org/' +msys2_repository_url='https://chromium.googlesource.com/angle/angle' +msys2_documentation_url='https://chromium.googlesource.com/angle/angle/+/main/README.md' license=('spdx:BSD-3-Clause') depends=("${MINGW_PACKAGE_PREFIX}-egl-headers" "${MINGW_PACKAGE_PREFIX}-gles-headers" @@ -26,20 +28,19 @@ makedepends=("${MINGW_PACKAGE_PREFIX}-cc" "${MINGW_PACKAGE_PREFIX}-python" "git" "unzip") -_commit=("2e285bb591f78af3b5b1f83617e06f9ef9067924") +_commit=("890b5d8fa2988e3719e0d80421bf3e927db9cd5c") source=("${_realname}::git+https://chromium.googlesource.com/angle/angle.git#commit=${_commit}" - "bare-clones/build::git+https://chromium.googlesource.com/chromium/src/build.git#commit=ccb49e801879c107ed6e96a84eb227f65ce4823b" - "bare-clones/zlib::git+https://chromium.googlesource.com/chromium/src/third_party/zlib.git#commit=90e67ba3f8998a3532fc8e3db9539aada8060d43" - "bare-clones/clang::git+https://chromium.googlesource.com/chromium/src/tools/clang.git#commit=64e9f9321c450d938fec79ef8e4431fd1a08f5ce" - "swiftshader.zip::https://github.com/google/swiftshader/archive/0ba0b45490cd209448c5f976f41b34a746c9de5d.zip" - "bare-clones/vulkan_memory_allocator::git+https://chromium.googlesource.com/external/github.com/GPUOpen-LibrariesAndSDKs/VulkanMemoryAllocator.git#commit=ebe84bec02c041d28f902da0214bf442743fc907" - "bare-clones/vulkan-deps::git+https://chromium.googlesource.com/vulkan-deps.git#commit=23a32754e71562453af68898e6918e06172d4c46" - "bare-clones/spirv-headers::git+https://chromium.googlesource.com/external/github.com/KhronosGroup/SPIRV-Headers.git#commit=3469b164e25cee24435029a569933cb42578db5d" - "bare-clones/spirv-tools::git+https://chromium.googlesource.com/external/github.com/KhronosGroup/SPIRV-Tools.git#commit=310a67020a7d67be4fdf1b4bfa9bb85f985c6fd7" - "bare-clones/vulkan-headers::git+https://chromium.googlesource.com/external/github.com/KhronosGroup/Vulkan-Headers.git#commit=b6a29e5ca865f48368f6b2f170adb89975bb0be1" - "bare-clones/vulkan-loader::git+https://chromium.googlesource.com/external/github.com/KhronosGroup/Vulkan-Loader.git#commit=a1d9d485ce1a66adc9a584ea79bc3829203863b6" - "bare-clones/vulkan-tools::git+https://chromium.googlesource.com/external/github.com/KhronosGroup/Vulkan-Tools.git#commit=247c806c93c720488daa0bc86acd5b6f3a0e14f9" - "bare-clones/vulkan-validation-layers::git+https://chromium.googlesource.com/external/github.com/KhronosGroup/Vulkan-ValidationLayers.git#commit=9086fcc46a679c334f9ede021a65215981df776a" + "swiftshader.zip::https://github.com/google/swiftshader/archive/c1f7fbbec4e17769c0182daae185466cb806d0d5.zip" + "bare-clones/build::git+https://chromium.googlesource.com/chromium/src/build.git#commit=70c150bc0ae989d00c15ab1ed67464198e4890d0" + "bare-clones/zlib::git+https://chromium.googlesource.com/chromium/src/third_party/zlib.git#commit=bf1e8de6cc305fdab82db1b65bed76b70bd96c8b" + "bare-clones/clang::git+https://chromium.googlesource.com/chromium/src/tools/clang.git#commit=d6072980974f9a4922d2eb27e4fd244ca3017031" + "bare-clones/spirv-headers::git+https://chromium.googlesource.com/external/github.com/KhronosGroup/SPIRV-Headers.git#commit=c8ad050fcb29e42a2f57d9f59e97488f465c436d" + "bare-clones/spirv-tools::git+https://chromium.googlesource.com/external/github.com/KhronosGroup/SPIRV-Tools.git#commit=257a227fbadf8176ea386c7d8fb9b889cbf08640" + "bare-clones/vulkan-headers::git+https://chromium.googlesource.com/external/github.com/KhronosGroup/Vulkan-Headers.git#commit=7cff847503174e2049b08253ee5f30428866fea3" + "bare-clones/vulkan-loader::git+https://chromium.googlesource.com/external/github.com/KhronosGroup/Vulkan-Loader.git#commit=235d1d2cf617af03a2ecbf6e951287595138feda" + "bare-clones/vulkan_memory_allocator::git+https://chromium.googlesource.com/external/github.com/GPUOpen-LibrariesAndSDKs/VulkanMemoryAllocator.git#commit=56300b29fbfcc693ee6609ddad3fdd5b7a449a21" + "bare-clones/vulkan-tools::git+https://chromium.googlesource.com/external/github.com/KhronosGroup/Vulkan-Tools.git#commit=5968d14a1ef8a7eeacf342e1542099e1aff20f70" + "bare-clones/vulkan-validation-layers::git+https://chromium.googlesource.com/external/github.com/KhronosGroup/Vulkan-ValidationLayers.git#commit=6f5b5e78b22cdd8d9535986e0d4c1b94ebe2d7b4" 001-add-mingw-toolchain.patch 002-buildflags-fixes.patch 003-angle-src-fixes.patch @@ -54,26 +55,25 @@ source=("${_realname}::git+https://chromium.googlesource.com/angle/angle.git#com rjson.gn zlib.gn angleproject.pc) -sha256sums=('SKIP' - 'SKIP' - 'SKIP' - 'SKIP' - 'ea1e3f0cc030911596b3fc4753a9228ea3a5a4eba6e21bb34b7a9867a3702738' - 'SKIP' - 'SKIP' - 'SKIP' - 'SKIP' - 'SKIP' - 'SKIP' - 'SKIP' - 'SKIP' - '573a9e12727926e2ddddf0863bed926ef3764ec64ab75d27e3ec48648849786d' - '926b273b0f32ce81b7508dea3dff8447e2f98bd84caa2c67fd52ede5e53a7213' - '04bcb05dc2f349639bf4e62ee92d758b756e56532ceb9184c2d7dca01e67a38e' - '55d291668fe98f9b095983fe9c17a7336097d3f6028a59ca749b77dac92be5b1' - 'ced98a61919f7fdb10dbff26dfbd4ea11b034eaaeb3433f0fa5c4c998519e171' - '276799dbae43ab2577547dcc7912353619ade2ba878b28947ddef545f48afffa' - '7fc7f35aedc101fe325c161c42d2966f974ec789025750705ceb0caf259fc1f6' +sha256sums=('8b51860cdeedda205ab6dc641c50943afd39018212701451f9a91d0b5f5be2cd' + 'f76c7c95066b1666ee2223f25d84cf7ddf7a891300e47b8eebd41bcd10dbba37' + 'a81c93d0eeff1f64765be1cf741aa44f300dea31441760b4e4c1dbe5ed4a0e56' + '6478d94a8295db87759f756c99a7c079d7f3710e4fb996f9851d7f9ca8982f11' + 'f58b2605f036b8c9c7992635ad5f2070abe4d527314915874766d654ae4eb429' + '47564925640c69eb6bef13ff7bca417d39e568208702e57c23cb6d4de3991b7a' + '4d0c3e559c632add51f5faa365218c2c45e8ab7e6430077b269575d75ac3e1e4' + '25ef9ac33ba80d13e44b2d3b45093451a20e41c4ed802c81f764934763408752' + '966446961563e5e8e7d1917093a71ddfa11e5ea4a686c7f7176e97053f1e0029' + '913fc3a85ae676025bafe63880c6413ffafe42495a04a52527ee914ee9ba3ae5' + '84a3afb0278156a286c37e3c166e4079a877ccb8d3da85b32d7c37986d78efbc' + '169327cafbfd0653a2937962cf17610d26c46dead8187f6ca1e21b20b637d9e1' + 'f82de30bbd868c75f7f3edd191e30fcce81c87825ff7c10713929295b5f4016f' + 'df927c5f804d51e6ce8f2c9324396d56d17aebbd674db3ba1c6ebafbebded0ac' + '36939a33c2f9fef5ecf07d5bd508057b2a49c1582e0e01891ad3e7d9e3ffb7fc' + '8209021bad1359426f24704395e67c2ca663a3c7b65eaaa3a2fc0e67fd155353' + '08441bed59aadcd6eb7079662a970e5c26dae3c77d4958af0485ac959d08a2fe' + 'cb5358e80a45f54e15a69bbe12ecb07eae405b491451ee38aea01ce4579b492b' + 'b69a6ff976df8192b776673f94fd494ba4c62e798708f753d9f8390f4fc0341e' '6d5c3d7888a671059d378e955c86d297dede5e6eee0d6aa0aeb12eb84c9e8ca1' 'bf878de3203a62e2a7f81bd4cd79237adc74804b4b692d9277da005ed56d4f2a' '86013781c2700219d4f64d7ac34ad16c40fcca9a641371385f67f642e23c643b' @@ -101,16 +101,15 @@ pkgver() { prepare() { echo ":: Patching build directory" cd "${srcdir}"/build - patch -p1 -i "${srcdir}"/001-add-mingw-toolchain.patch + apply_patch_with_msg \ + 001-add-mingw-toolchain.patch python "${srcdir}"/build/util/lastchange.py -o "${srcdir}"/build/util/LASTCHANGE - rm -rf "${srcdir}"/${_realname}/build - ln -sf "${srcdir}"/build "${srcdir}"/${_realname} - echo "checkout_google_benchmark = false" > "${srcdir}"/${_realname}/build/config/gclient_args.gni + cp -rf "${srcdir}"/build "${srcdir}"/${_realname} + echo "build_with_chromium = false" > "${srcdir}"/${_realname}/build/config/gclient_args.gni echo ":: Patching zlib directory" - mkdir -p "${srcdir}"/${_realname}/third_party/zlib - ln -sf "${srcdir}"/zlib.gn "${srcdir}"/${_realname}/third_party/zlib/BUILD.gn - ln -sf "${srcdir}"/zlib/google "${srcdir}"/${_realname}/third_party/zlib + cp -f "${srcdir}"/zlib.gn "${srcdir}"/${_realname}/third_party/zlib/BUILD.gn + cp -rf "${srcdir}"/zlib/google "${srcdir}"/${_realname}/third_party/zlib echo ":: Extracting SwiftShader" cd "${srcdir}" @@ -119,42 +118,41 @@ prepare() { echo ":: Patching SwiftShader directory" cd "${srcdir}"/SwiftShader - patch -p1 -i "${srcdir}"/004-swiftshader-updates.patch - patch -p1 -i "${srcdir}"/008-arm64-mingw-intrinsic.patch - ln -sf "${srcdir}"/SwiftShader "${srcdir}"/${_realname}/third_party + apply_patch_with_msg \ + 004-swiftshader-updates.patch \ + 008-arm64-mingw-intrinsic.patch + cp -rf "${srcdir}"/SwiftShader "${srcdir}"/${_realname}/third_party echo ":: Patching vulkan_memory_allocator directory" cd "${srcdir}"/vulkan_memory_allocator - patch -p1 -i "${srcdir}"/005-vulkan-memory-allocator-updates.patch - ln -sf "${srcdir}"/vulkan_memory_allocator "${srcdir}"/${_realname}/third_party + apply_patch_with_msg \ + 005-vulkan-memory-allocator-updates.patch + cp -rf "${srcdir}"/vulkan_memory_allocator "${srcdir}"/${_realname}/third_party echo ":: Patching spirv-tools directory" cd "${srcdir}"/spirv-tools - patch -p1 -i "${srcdir}"/006-spirv-updates.patch + apply_patch_with_msg \ + 006-spirv-updates.patch echo ":: Patching vulkan-loader directory" cd "${srcdir}"/vulkan-loader - patch -p1 -i "${srcdir}"/007-vulkan-loader-updates.patch + apply_patch_with_msg \ + 007-vulkan-loader-updates.patch - echo ":: Copying vulkan-deps files" - ln -sf "${srcdir}"/vulkan-deps "${srcdir}"/${_realname}/third_party - cp -rf "${srcdir}"/spirv-headers "${srcdir}"/${_realname}/third_party/vulkan-deps/spirv-headers/src - cp -rf "${srcdir}"/spirv-tools "${srcdir}"/${_realname}/third_party/vulkan-deps/spirv-tools/src - cp -rf "${srcdir}"/vulkan-headers "${srcdir}"/${_realname}/third_party/vulkan-deps/vulkan-headers/src - cp -rf "${srcdir}"/vulkan-loader "${srcdir}"/${_realname}/third_party/vulkan-deps/vulkan-loader/src - cp -rf "${srcdir}"/vulkan-tools "${srcdir}"/${_realname}/third_party/vulkan-deps/vulkan-tools/src - cp -rf "${srcdir}"/vulkan-validation-layers "${srcdir}"/${_realname}/third_party/vulkan-deps/vulkan-validation-layers/src + echo ":: Copying spirv and vulkan files" + cp -rf "${srcdir}"/spirv-headers/* "${srcdir}"/${_realname}/third_party/spirv-headers/src + cp -rf "${srcdir}"/spirv-tools/* "${srcdir}"/${_realname}/third_party/spirv-tools/src + cp -rf "${srcdir}"/vulkan-headers/* "${srcdir}"/${_realname}/third_party/vulkan-headers/src + cp -rf "${srcdir}"/vulkan-loader/* "${srcdir}"/${_realname}/third_party/vulkan-loader/src + cp -rf "${srcdir}"/vulkan-tools/* "${srcdir}"/${_realname}/third_party/vulkan-tools/src + cp -rf "${srcdir}"/vulkan-validation-layers/* "${srcdir}"/${_realname}/third_party/vulkan-validation-layers/src - echo ":: Soft linking extra repos" - mkdir -p "${srcdir}"/${_realname}/third_party/libjpeg - ln -sf "${srcdir}"/jpeg.gn "${srcdir}"/${_realname}/third_party/libjpeg/BUILD.gn - mkdir -p "${srcdir}"/${_realname}/third_party/jsoncpp - ln -sf "${srcdir}"/jsoncpp.gn "${srcdir}"/${_realname}/third_party/jsoncpp/BUILD.gn - rm -f "${srcdir}"/${_realname}/third_party/libpng/BUILD.gn - ln -sf "${srcdir}"/png.gn "${srcdir}"/${_realname}/third_party/libpng/BUILD.gn - rm -f "${srcdir}"/${_realname}/third_party/rapidjson/BUILD.gn - ln -sf "${srcdir}"/rjson.gn "${srcdir}"/${_realname}/third_party/rapidjson/BUILD.gn - ln -sf "${srcdir}"/clang "${srcdir}"/${_realname}/tools + echo ":: Updating extra repos" + cp -f "${srcdir}"/jpeg.gn "${srcdir}"/${_realname}/third_party/libjpeg_turbo/BUILD.gn + cp -f "${srcdir}"/jsoncpp.gn "${srcdir}"/${_realname}/third_party/jsoncpp/BUILD.gn + cp -f "${srcdir}"/png.gn "${srcdir}"/${_realname}/third_party/libpng/BUILD.gn + cp -f "${srcdir}"/rjson.gn "${srcdir}"/${_realname}/third_party/rapidjson/BUILD.gn + cp -rf "${srcdir}"/clang "${srcdir}"/${_realname}/tools echo ":: Patching angle source" cd "${srcdir}"/${_realname} @@ -182,8 +180,12 @@ build() { fi local _arch=x64 + local _cfg=true + local _swiftshader=true if [[ ${CARCH} == aarch64 ]]; then _arch=arm64 + _cfg=false + _swiftshader=false fi local _clang=false @@ -191,35 +193,24 @@ build() { _clang=true fi - local _swiftshader=false - if [[ ${MSYSTEM} == CLANG* ]] && [[ ${CARCH} != aarch64 ]]; then - _swiftshader=true - fi - - if [[ ${MSYSTEM} == CLANG* ]]; then - export CXX=clang++ - export CC=clang - export AR=llvm-ar - else - export CXX=g++ - export CC=gcc - export AR=ar - fi - gn gen out/${_target}-${MSYSTEM} --args=" target_cpu=\"${_arch}\" is_debug=${_debug} is_clang=${_clang} is_component_build=true + angle_build_tests=false angle_enable_abseil=false - angle_enable_metal=false - angle_enable_d3d11_compositor_native_window=false angle_enable_cl=false - angle_shared_libvulkan=false + angle_enable_metal=false angle_enable_swiftshader=${_swiftshader} + angle_shared_libvulkan=false chrome_pgo_phase=0 use_custom_libcxx=false + use_libcxx_modules=false + use_lld=false + use_siso=false use_sysroot=false + win_enable_cfg_guards=${_cfg} treat_warnings_as_errors=false" ninja -C out/${_target}-${MSYSTEM}