diff --git a/mingw-w64-v8/001-add-mingw-toolchain.patch b/mingw-w64-v8/001-add-mingw-toolchain.patch index 25c3ea12e2..4f3c18aaa8 100644 --- a/mingw-w64-v8/001-add-mingw-toolchain.patch +++ b/mingw-w64-v8/001-add-mingw-toolchain.patch @@ -1,8 +1,8 @@ diff --git a/config/BUILD.gn b/config/BUILD.gn -index 53511ac36..8c57b86b3 100644 +index 56ca3ca73..4b0b33318 100644 --- a/config/BUILD.gn +++ b/config/BUILD.gn -@@ -162,25 +162,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 = [ @@ -47,7 +47,7 @@ index 53511ac36..8c57b86b3 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 -@@ -196,9 +196,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 += [ @@ -60,8 +60,35 @@ index 53511ac36..8c57b86b3 100644 ] } } else if (is_android) { +@@ -253,7 +253,7 @@ group("common_deps_without_libcxx") { + } + } + +- 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_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. +@@ -418,7 +418,7 @@ config("precompiled_headers") { + + # Force include the header. + cflags = [ "/FI$precompiled_header" ] +- } else if (is_mac || is_linux) { ++ } else if (is_mac || is_linux || is_mingw) { + precompiled_source = "//build/precompile.h" + } + } diff --git a/config/BUILDCONFIG.gn b/config/BUILDCONFIG.gn -index 105e194dd..e661e359c 100644 +index 147226d72..07b31bfc5 100644 --- a/config/BUILDCONFIG.gn +++ b/config/BUILDCONFIG.gn @@ -135,6 +135,9 @@ declare_args() { @@ -74,7 +101,7 @@ index 105e194dd..e661e359c 100644 # Set to true when compiling with the Clang compiler. is_clang = current_os != "linux" || (current_cpu != "s390x" && current_cpu != "s390" && -@@ -210,16 +213,20 @@ 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. @@ -82,7 +109,7 @@ index 105e194dd..e661e359c 100644 - if (is_clang) { - host_toolchain = "//build/toolchain/win:win_clang_$target_cpu" + if (is_mingw) { -+ host_toolchain = "//build/toolchain/win:mingw_$target_cpu" ++ host_toolchain = "//build/toolchain/win:mingw_$target_cpu" + } else { + if (target_cpu == "x86" || target_cpu == "x64") { + if (is_clang) { @@ -103,7 +130,7 @@ index 105e194dd..e661e359c 100644 } } else if (host_os == "aix") { host_toolchain = "//build/toolchain/aix:$host_cpu" -@@ -253,10 +260,14 @@ 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 @@ -121,15 +148,24 @@ index 105e194dd..e661e359c 100644 } } else if (target_os == "winuwp") { # Only target WinUWP on for a Windows store application and only -@@ -309,6 +320,7 @@ is_win = current_os == "win" || current_os == "winuwp" +@@ -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_msvc = is_win && !is_mingw # ============================================================================= # TARGET DEFAULTS -@@ -412,7 +424,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. @@ -138,7 +174,7 @@ index 105e194dd..e661e359c 100644 # Many targets remove these configs, so they are not contained within # //build/config:executable_config for easy removal. _linker_configs = [ -@@ -434,7 +446,7 @@ default_executable_configs = default_compiler_configs + [ +@@ -473,7 +485,7 @@ default_executable_configs = default_compiler_configs + [ "//build/config:executable_config", ] + _linker_configs @@ -147,7 +183,7 @@ index 105e194dd..e661e359c 100644 # Turn on linker CFI for executables, and position it so it can be removed # if needed. default_executable_configs += [ "//build/config/win:cfi_linker" ] -@@ -458,7 +470,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 @@ -156,183 +192,164 @@ index 105e194dd..e661e359c 100644 # 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/clang.gni b/config/clang/clang.gni -index 1a065b5e3..97fd8c9f7 100644 ---- a/config/clang/clang.gni -+++ b/config/clang/clang.gni -@@ -12,7 +12,7 @@ declare_args() { - # coding guidelines, etc. Only used when compiling with Chrome's Clang, not - # Chrome OS's. - clang_use_chrome_plugins = -- is_clang && !is_nacl && current_os != "zos" && -+ is_clang && !is_nacl && !is_mingw && current_os != "zos" && - default_toolchain != "//build/toolchain/cros:target" - - enable_check_raw_ptr_fields = diff --git a/config/compiler/BUILD.gn b/config/compiler/BUILD.gn -index 06812fb9c..cd510594b 100644 +index 29c284ee0..0125019ad 100644 --- a/config/compiler/BUILD.gn +++ b/config/compiler/BUILD.gn -@@ -338,7 +338,7 @@ 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_msvc) { - # Common POSIX compiler flags setup. - # -------------------------------- - cflags += [ "-fno-strict-aliasing" ] # See http://crbug.com/32204 -@@ -414,7 +414,7 @@ config("compiler") { + configs += [ + # See the definitions below. +- ":clang_revision", +- ":rustc_revision", + ":compiler_cpu_abi", + ":compiler_codegen", + ":compiler_deterministic", + ":clang_warning_suppression", + ] + ++ 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" ] -@@ -567,11 +567,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_msvc) { - # 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" ] - } - } -@@ -582,7 +582,7 @@ config("compiler") { +@@ -605,7 +623,7 @@ config("compiler") { ldflags += [ "-Wl,-z,keep-text-section-prefix" ] } -- if (is_clang && !is_nacl && current_os != "zos") { -+ if (is_clang && !is_nacl && !is_mingw && current_os != "zos") { +- if (is_clang) { ++ if (is_clang && !is_mingw) { cflags += [ "-fcrash-diagnostics-dir=" + clang_diagnostic_dir ] if (save_reproducers_on_lld_crash && use_lld) { ldflags += [ -@@ -598,7 +598,7 @@ config("compiler") { - "-instcombine-lower-dbg-declare=0", - ] - if (!is_debug && use_thin_lto && is_a_target_toolchain) { -- if (is_win) { -+ if (is_msvc) { - ldflags += [ "-mllvm:-instcombine-lower-dbg-declare=0" ] - } else { - ldflags += [ "-Wl,-mllvm,-instcombine-lower-dbg-declare=0" ] -@@ -606,7 +606,7 @@ config("compiler") { - } - - # TODO(crbug.com/1235145): Investigate why/if this should be needed. -- if (is_win) { -+ if (is_msvc) { - cflags += [ "/clang:-ffp-contract=off" ] - } else { - cflags += [ "-ffp-contract=off" ] -@@ -615,9 +615,9 @@ config("compiler") { +@@ -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_clang) { -+ if (is_clang && !is_mingw) { +- 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" - # Since we build with -std=c* and not -std=gnu*, _GNU_SOURCE will not be -@@ -657,9 +657,9 @@ config("compiler") { - } else { - # The gcc bots are currently using GCC 9, which is not new enough to +@@ -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" ] -+ cflags_cc += [ "-std=${standard_prefix}++20" ] + cflags_cc += [ "-std=${standard_prefix}++2a" ] } - } else if (is_win) { + } else if (is_msvc) { cflags_c += [ "/std:c11" ] - if ((defined(use_cxx17) && use_cxx17) || - (!is_clang && defined(msvc_use_cxx17) && msvc_use_cxx17)) { -@@ -682,6 +682,10 @@ config("compiler") { - } - } - -+ if (is_mingw && !is_clang) { -+ cflags += [ "-fdiagnostics-color" ] -+ } -+ - if (is_clang && current_os != "zos") { - # C++17 removes trigraph support, but clang still warns that it ignores - # them when seeing them. Don't. -@@ -719,7 +723,7 @@ config("compiler") { - # should be able to better manage binary size increases on its own. - import_instr_limit = 30 - -- if (is_win) { -+ if (is_msvc) { - ldflags += [ - "/opt:lldltojobs=all", - "-mllvm:-import-instr-limit=$import_instr_limit", -@@ -808,7 +812,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_msvc) { cflags += [ # "Documented" here: # http://aras-p.info/blog/2017/10/23/Best-unknown-MSVC-flag-d2cgsummary/ -@@ -838,15 +842,15 @@ 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. - if (use_lld && !enable_call_graph_profile_sort) { -- if (is_win) { -+ if (is_msvc) { +- if (use_lld && !enable_call_graph_profile_sort) { ++ if (use_lld && !enable_call_graph_profile_sort && !is_mingw) { + if (is_win) { ldflags += [ "/call-graph-profile-sort:no" ] -- } else { -+ } else if (!is_mingw) { - ldflags += [ "-Wl,--no-call-graph-profile-sort" ] - } + } 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_msvc) { - # TODO(crbug.com/1223741): Goma mixes the -H and /showIncludes output. - assert(!use_goma, "show_includes on Windows is not reliable with goma") cflags += [ -@@ -865,7 +869,7 @@ config("compiler") { + "/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 && !is_nacl && target_os != "chromeos" && -- (is_win || use_custom_libcxx)) { -+ (is_msvc || use_custom_libcxx)) { +- 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" ] } -@@ -1030,7 +1034,7 @@ config("thinlto_optimize_default") { - if (!is_debug && use_thin_lto && is_a_target_toolchain) { - lto_opt_level = 0 - -- if (is_win) { -+ if (is_msvc) { - ldflags = [ "/opt:lldlto=" + lto_opt_level ] - } else { - ldflags = [ "-Wl,--lto-O" + lto_opt_level ] -@@ -1059,7 +1063,7 @@ config("thinlto_optimize_max") { - lto_opt_level = 0 - } - -- if (is_win) { -+ if (is_msvc) { - ldflags = [ "/opt:lldlto=" + lto_opt_level ] - } else { - ldflags = [ "-Wl,--lto-O" + lto_opt_level ] -@@ -1093,7 +1097,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) { @@ -340,16 +357,37 @@ index 06812fb9c..cd510594b 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") { -@@ -1127,7 +1131,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 && -+ if (is_clang && !is_android && !is_nacl && !is_fuchsia && !is_mingw && - !(is_chromeos_lacros && is_chromeos_device)) { +- 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" ] -@@ -1438,7 +1442,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) { @@ -358,13 +396,7 @@ index 06812fb9c..cd510594b 100644 cflags += [ "/wd4117", # Trying to define or undefine a predefined macro. "/D__DATE__=", -@@ -1476,12 +1480,12 @@ config("compiler_deterministic") { - cflags += [ "-ffile-compilation-dir=." ] - swiftflags += [ "-file-compilation-dir=." ] - } -- if (!is_win) { -+ if (!is_msvc) { - # We don't use clang -cc1as on Windows (yet? https://crbug.com/762167) +@@ -1635,7 +1657,7 @@ config("compiler_deterministic") { asmflags = [ "-Wa,-fdebug-compilation-dir,." ] } @@ -373,25 +405,43 @@ index 06812fb9c..cd510594b 100644 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 -@@ -1514,7 +1518,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_msvc && is_clang && clang_base_path == default_clang_base_path) { - update_args = [ - "--print-revision", - "--verify-version=$clang_version", -@@ -1648,7 +1652,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_msvc) { - if (treat_warnings_as_errors) { - cflags += [ "/WX" ] - } -@@ -1723,10 +1727,30 @@ config("default_warnings") { + if (fatal_linker_warnings) { + arflags = [ "/WX" ] + ldflags = [ "/WX" ] +@@ -2059,10 +2081,33 @@ config("default_warnings") { # files. cflags += [ "-Wno-packed-not-aligned" ] } @@ -400,12 +450,15 @@ index 06812fb9c..cd510594b 100644 + cflags += [ + "-Wno-attributes", # "__decspec(dllimport) inline" + "-Wno-format", # PRIu64 llu support on MinGW ++ "-Wno-uninitialized", + "-Wno-unknown-pragmas", + ] + if (!is_clang) { + cflags_cc += [ -+ "-Wno-invalid-offsetof", ++ "-Wno-ignored-attributes", ++ "-Wno-invalid-constexpr", + "-Wno-pessimizing-move", ++ "-Wno-shift-count-overflow", + "-Wno-subobject-linkage", # Tests having code in header files + ] + cflags += [ @@ -423,7 +476,7 @@ index 06812fb9c..cd510594b 100644 cflags += [ # Disables. "-Wno-missing-field-initializers", # "struct foo f = {0};" -@@ -1858,7 +1882,7 @@ config("prevent_unsafe_narrowing") { +@@ -2246,7 +2291,7 @@ config("prevent_unsafe_narrowing") { # part of Chromium. config("chromium_code") { @@ -432,7 +485,7 @@ index 06812fb9c..cd510594b 100644 if (is_clang) { cflags = [ "/W4" ] # Warning level 4. -@@ -1924,7 +1948,7 @@ config("chromium_code") { +@@ -2301,7 +2346,7 @@ config("chromium_code") { } } @@ -441,7 +494,7 @@ index 06812fb9c..cd510594b 100644 cflags += [ # Warn on missing break statements at the end of switch cases. # For intentional fallthrough, use [[fallthrough]]. -@@ -1959,7 +1983,7 @@ config("no_chromium_code") { +@@ -2354,7 +2399,7 @@ config("no_chromium_code") { cflags_cc = [] defines = [] @@ -450,7 +503,7 @@ index 06812fb9c..cd510594b 100644 if (is_clang) { cflags += [ "/W3" ] # Warning level 3. } -@@ -2026,7 +2050,7 @@ config("noshadowing") { +@@ -2405,7 +2450,7 @@ config("noshadowing") { # Allows turning Run-Time Type Identification on or off. config("rtti") { @@ -459,7 +512,7 @@ index 06812fb9c..cd510594b 100644 cflags_cc = [ "/GR" ] } else { cflags_cc = [ "-frtti" ] -@@ -2036,7 +2060,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) { @@ -468,16 +521,16 @@ index 06812fb9c..cd510594b 100644 cflags_cc = [ "/GR-" ] } else { cflags_cc = [ "-fno-rtti" ] -@@ -2080,7 +2104,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_msvc && use_lld) { arflags = [ "/llvmlibthin" ] } } -@@ -2091,7 +2115,7 @@ config("thin_archive") { +@@ -2478,7 +2523,7 @@ config("thin_archive") { # Note: exceptions are disallowed in Google code. config("exceptions") { @@ -486,18 +539,7 @@ index 06812fb9c..cd510594b 100644 # Enables exceptions in the STL. if (!use_custom_libcxx) { defines = [ "_HAS_EXCEPTIONS=1" ] -@@ -2100,11 +2124,18 @@ config("exceptions") { - } else { - cflags_cc = [ "-fexceptions" ] - cflags_objcc = cflags_cc -+ -+ if (is_mingw && exclude_unwind_tables) { -+ # With exceptions explicitly allowed, -+ # override exclude_unwind_tables or -+ # linking will fail on MinGW -+ cflags_cc += [ "-funwind-tables", "-fasynchronous-unwind-tables", ] -+ } - } +@@ -2491,7 +2536,7 @@ config("exceptions") { } config("no_exceptions") { @@ -506,38 +548,54 @@ index 06812fb9c..cd510594b 100644 # 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 -@@ -2115,8 +2146,10 @@ config("no_exceptions") { +@@ -2501,7 +2546,9 @@ config("no_exceptions") { + if (!use_custom_libcxx) { defines = [ "_HAS_EXCEPTIONS=0" ] } - } else { -- cflags_cc = [ "-fno-exceptions" ] -- cflags_objcc = cflags_cc -+ if (!is_mingw) { -+ cflags_cc = [ "-fno-exceptions" ] -+ cflags_objcc = cflags_cc -+ } +- } 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 } - } - -@@ -2170,7 +2203,7 @@ config("no_incompatible_pointer_warnings") { +@@ -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_msvc) { common_optimize_on_cflags = [ - "/Ob2", # Both explicit and auto inlining. "/Oy-", # Disable omitting frame pointers, must be after /O2. -@@ -2276,7 +2309,7 @@ config("default_stack_frames") { + "/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. - # 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_msvc) { - if (chrome_pgo_phase != 2) { - # Favor size over speed, /O1 must be before the common flags. - # /O1 implies /Os and /GF. -@@ -2335,7 +2368,7 @@ config("optimize") { + # 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") { @@ -546,66 +604,79 @@ index 06812fb9c..cd510594b 100644 cflags = [ "/Od", # Disable optimization. "/Ob0", # Disable all inlining (on by default). -@@ -2387,7 +2420,7 @@ config("optimize_max") { - configs = [ "//build/config/nacl:irt_optimize" ] - } else { - 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 -@@ -2420,7 +2453,7 @@ config("optimize_speed") { - configs = [ "//build/config/nacl:irt_optimize" ] - } else { - 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 -@@ -2568,7 +2601,7 @@ config("win_pdbaltpath") { - # Full symbols. +@@ -2799,7 +2846,7 @@ config("no_optimize") { + # elsewhere. + config("optimize_max") { + 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 +@@ -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. -@@ -2603,7 +2636,7 @@ config("symbols") { - } +@@ -3013,7 +3060,7 @@ config("symbols") { # On aix -gdwarf causes linker failures due to thread_local variables. -- if (!is_nacl && current_os != "aix") { -+ if (!is_nacl && !is_mingw && current_os != "aix") { + # 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" ] -@@ -2629,11 +2662,11 @@ config("symbols") { - # build-directory-independent output. - # Keeping -g2 for saigo as it's the only toolchain whose artifacts that are - # part of chromium release (other nacl toolchains are used only for tests). -- if ((!is_nacl || is_nacl_saigo) && current_os != "zos") { -+ if ((!is_nacl || is_nacl_saigo) && !is_mingw && current_os != "zos") { - cflags += [ "-g2" ] +@@ -3062,7 +3109,7 @@ config("symbols") { + ldflags += [ "-gsplit-dwarf" ] } -- if (!is_nacl && is_clang && !is_tsan && !is_asan) { -+ if (!is_nacl && !is_mingw && is_clang && !is_tsan && !is_asan) { - # gcc generates dwarf-aranges by default on -g1 and -g2. On clang it has - # to be manually enabled. - # -@@ -2665,7 +2698,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. -@@ -2717,7 +2750,7 @@ config("symbols") { +- _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 = [] @@ -614,16 +685,16 @@ index 06812fb9c..cd510594b 100644 # Functions, files, and line tables only. cflags = [] -@@ -2744,7 +2777,7 @@ config("minimal_symbols") { - # former. - cflags += [ "-gline-tables-only" ] - } -- } else { -+ } else if (!is_mingw) { - cflags = [] - if (is_mac && !use_dwarf5) { - # clang defaults to DWARF2 on macOS unless mac_deployment_target is -@@ -2801,7 +2834,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") { @@ -632,17 +703,30 @@ index 06812fb9c..cd510594b 100644 ldflags = [ "/DEBUG" ] # All configs using /DEBUG should include this: -@@ -2901,7 +2934,7 @@ buildflag_header("compiler_buildflags") { +@@ -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_win && !is_mingw) { ++ 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..fa462e560 100755 +index f4d31de67..158208895 100755 --- a/config/linux/pkg-config.py +++ b/config/linux/pkg-config.py @@ -108,7 +108,7 @@ def main(): @@ -655,10 +739,28 @@ index 2e38c7ffb..fa462e560 100755 return 0 diff --git a/config/sanitizers/BUILD.gn b/config/sanitizers/BUILD.gn -index a3426ea67..12186d762 100644 +index e2f39f029..53e4576e7 100644 --- a/config/sanitizers/BUILD.gn +++ b/config/sanitizers/BUILD.gn -@@ -228,7 +228,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") { } } } @@ -667,24 +769,16 @@ index a3426ea67..12186d762 100644 # Windows directly calls link.exe instead of the compiler driver when # linking. Hence, pass the runtime libraries instead of -fsanitize=address # or -fsanitize=fuzzer. -@@ -298,14 +298,14 @@ config("asan_flags") { - } - - config("link_executable") { -- if (is_asan && is_win && !is_component_build) { -+ if (is_asan && is_msvc && !is_component_build) { - assert(current_cpu == "x64", "WinASan unsupported architecture") - ldflags = [ "-wholearchive:clang_rt.asan-x86_64.lib" ] - } - } - - config("link_shared_library") { -- if (is_asan && is_win && !is_component_build) { -+ if (is_asan && is_msvc && !is_component_build) { - assert(current_cpu == "x64", "WinASan unsupported architecture") - libs = [ "clang_rt.asan_dll_thunk-x86_64.lib" ] - } -@@ -350,7 +350,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" ] @@ -693,11 +787,24 @@ index a3426ea67..12186d762 100644 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 497d47989..5a2f3f036 100644 +index aaeadc313..4803bd492 100644 --- a/config/win/BUILD.gn +++ b/config/win/BUILD.gn -@@ -49,6 +49,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") { @@ -705,13 +812,14 @@ index 497d47989..5a2f3f036 100644 if (current_cpu == "x86") { asmflags = [ # When /safeseh is specified, the linker will only produce an image if it -@@ -214,6 +215,14 @@ config("compiler") { +@@ -213,6 +214,15 @@ config("compiler") { # the source file is a no-op. "/ignore:4221", ] + } else { # is_mingw ++ cflags = [] + if (current_cpu != "arm64"){ -+ cflags = [ "-Wa,-mbig-obj" ] ++ cflags += [ "-Wa,-mbig-obj" ] + } + if (!is_clang) { + cflags += [ "-fno-keep-inline-dllexport" ] @@ -720,7 +828,7 @@ index 497d47989..5a2f3f036 100644 } # This is included by reference in the //build/config/compiler:runtime_library -@@ -302,7 +311,7 @@ config("winver") { +@@ -301,7 +311,7 @@ config("winver") { # Linker flags for Windows SDK setup, this is applied only to EXEs and DLLs. config("sdk_link") { @@ -729,7 +837,7 @@ index 497d47989..5a2f3f036 100644 ldflags = [ "/SAFESEH", # Not compatible with x64 so use only for x86. "/largeaddressaware", -@@ -314,19 +323,27 @@ config("sdk_link") { +@@ -313,19 +323,27 @@ config("sdk_link") { # targets who want different library configurations can remove this and specify # their own. config("common_linker_setup") { @@ -750,7 +858,7 @@ index 497d47989..5a2f3f036 100644 + ldflags = [ + "-Wl,-dynamicbase", + "-Wl,-nxcompat", -+ ] ++ ] + } else { + ldflags = [ + "/FIXED:NO", @@ -769,43 +877,36 @@ index 497d47989..5a2f3f036 100644 } } -@@ -337,12 +354,20 @@ config("default_cfg_compiler") { +@@ -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 (win_enable_cfg_guards) { - if (is_clang) { -- cflags = [ "/guard:cf" ] -+ if (is_mingw) { -+ cflags = [ "-fcf-protection=full" ] -+ } else { -+ cflags = [ "/guard:cf" ] -+ } +- if (is_clang) { ++ if (is_msvc && is_clang) { + cflags = [ "/guard:cf" ] ++ } else { ++ cflags = [ "-fcf-protection" ] } rustflags = [ "-Ccontrol-flow-guard" ] } else { - if (is_clang) { -- cflags = [ "/guard:cf,nochecks" ] -+ if (is_mingw) { -+ cflags = [ "-fcf-protection=none" ] -+ } else { -+ cflags = [ "/guard:cf,nochecks" ] -+ } +- if (is_clang) { ++ if (is_msvc && is_clang) { + cflags = [ "/guard:cf,nochecks" ] } rustflags = [ "-Ccontrol-flow-guard=nochecks" ] - } -@@ -355,7 +380,11 @@ config("disable_guards_cfg_compiler") { +@@ -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) { -- cflags = [ "/guard:cf,nochecks" ] -+ if (is_mingw) { -+ cflags = [ "-fcf-protection=none" ] -+ } else { -+ cflags = [ "/guard:cf,nochecks" ] -+ } +- if (is_clang) { ++ if (is_msvc && is_clang) { + cflags = [ "/guard:cf,nochecks" ] ++ } else { ++ cflags = [ "-fcf-protection=none" ] } rustflags = [ "-Ccontrol-flow-guard=nochecks" ] } -@@ -368,7 +397,7 @@ config("cfi_linker") { +@@ -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 @@ -814,22 +915,37 @@ index 497d47989..5a2f3f036 100644 # Turn on CFG bitmap generation and CFG load config. ldflags = [ "/guard:cf" ] } -@@ -475,12 +504,12 @@ config("delayloads_not_for_child_dll") { - # See https://msdn.microsoft.com/en-us/library/2kzt1wy3.aspx for a reference of - # what each value does. - config("default_crt") { -- if (is_component_build) { -+ if (is_msvc && is_component_build) { - # Component mode: dynamic CRT. Since the library is shared, it requires - # exceptions or will give errors about things not matching, so keep - # exceptions on. - configs = [ ":dynamic_crt" ] -- } else { -+ } else if (!is_mingw) { - if (current_os == "winuwp") { - # https://blogs.msdn.microsoft.com/vcblog/2014/06/10/the-great-c-runtime-crt-refactoring/ - # contains a details explanation of what is happening with the Windows -@@ -498,7 +527,7 @@ config("default_crt") { +@@ -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") { @@ -837,8 +953,8 @@ index 497d47989..5a2f3f036 100644 + if (is_msvc && is_component_build) { cflags = [ "/MD" ] - if (rust_prebuilt_stdlib) { -@@ -516,7 +545,7 @@ config("release_crt") { + # /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" ] } @@ -846,8 +962,8 @@ index 497d47989..5a2f3f036 100644 + } else if (!is_mingw) { cflags = [ "/MT" ] - if (rust_prebuilt_stdlib) { -@@ -536,7 +565,7 @@ config("release_crt") { + # /MT specifies libcmt.lib as the CRT library, which is the static+release +@@ -554,7 +580,7 @@ config("release_crt") { } config("dynamic_crt") { @@ -856,7 +972,7 @@ index 497d47989..5a2f3f036 100644 # This pulls in the DLL debug CRT and defines _DEBUG cflags = [ "/MDd" ] -@@ -550,7 +579,7 @@ config("dynamic_crt") { +@@ -570,7 +596,7 @@ config("dynamic_crt") { if (use_custom_libcxx) { ldflags = [ "/DEFAULTLIB:msvcprtd.lib" ] } @@ -864,8 +980,8 @@ index 497d47989..5a2f3f036 100644 + } else if (!is_mingw) { cflags = [ "/MD" ] - if (rust_prebuilt_stdlib) { -@@ -571,7 +600,7 @@ config("dynamic_crt") { + # /MD specifies msvcrt.lib as the CRT library, which is the dynamic+release +@@ -584,7 +610,7 @@ config("dynamic_crt") { } config("static_crt") { @@ -874,7 +990,7 @@ index 497d47989..5a2f3f036 100644 # This pulls in the static debug CRT and defines _DEBUG cflags = [ "/MTd" ] -@@ -585,7 +614,7 @@ config("static_crt") { +@@ -601,7 +627,7 @@ config("static_crt") { if (use_custom_libcxx) { ldflags = [ "/DEFAULTLIB:libcpmtd.lib" ] } @@ -882,22 +998,13 @@ index 497d47989..5a2f3f036 100644 + } else if (!is_mingw) { cflags = [ "/MT" ] - if (rust_prebuilt_stdlib) { -@@ -611,20 +640,28 @@ config("static_crt") { - 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" -+ subsystem_version_suffix = "5.02" - } else if (current_cpu == "arm64") { - # Windows ARM64 requires Windows 10. -- subsystem_version_suffix = ",10.0" -+ subsystem_version_suffix = "10.0" - } else { - # 5.01 = Windows XP. -- subsystem_version_suffix = ",5.01" -+ subsystem_version_suffix = "5.01" - } + # /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" ] @@ -917,7 +1024,7 @@ index 497d47989..5a2f3f036 100644 } # Incremental linking ---------------------------------------------------------- -@@ -634,7 +671,7 @@ config("default_incremental_linking") { +@@ -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. @@ -926,39 +1033,17 @@ index 497d47989..5a2f3f036 100644 ldflags = [ "/INCREMENTAL" ] if (use_lld) { # lld doesn't use ilk files and doesn't really have an incremental link -@@ -649,7 +686,7 @@ config("default_incremental_linking") { +@@ -651,7 +685,7 @@ config("default_incremental_linking") { # in lld-link. ldflags += [ "/OPT:NOICF" ] } - } else { -+ } else if (!is_mingw){ ++ } else if (!is_mingw) { ldflags = [ "/INCREMENTAL:NO" ] } } -@@ -682,3 +719,21 @@ config("lean_and_mean") { - config("nominmax") { - defines = [ "NOMINMAX" ] - } -+ -+# 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..579026d97 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" @@ -966,12 +1051,12 @@ index e1859eacd..579026d97 100644 # } -if (is_win) { -+if (is_win && !is_mingw) { ++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..e13e94d69 100644 +index bd4116693..65cd9a7ed 100644 --- a/config/win/visual_studio_version.gni +++ b/config/win/visual_studio_version.gni @@ -24,7 +24,7 @@ declare_args() { @@ -993,26 +1078,26 @@ index 1da479dd5..e13e94d69 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..0437a638b 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, @@ -1047,10 +1132,10 @@ index 03ef04261..0437a638b 100755 if dwp_proc: dwp_result = dwp_proc.wait() diff --git a/toolchain/gcc_toolchain.gni b/toolchain/gcc_toolchain.gni -index 20c106694..0985480d6 100644 +index c22ec9046..facba2cae 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 @@ -1058,7 +1143,7 @@ index 20c106694..0985480d6 100644 # # Optional parameters that control the tools: # -@@ -305,6 +306,11 @@ template("single_gcc_toolchain") { +@@ -264,6 +265,11 @@ template("single_gcc_toolchain") { } else { nm = "nm" } @@ -1070,8 +1155,8 @@ index 20c106694..0985480d6 100644 if (defined(invoker.dwp)) { dwp_switch = " --dwp=\"${invoker.dwp}\"" } else { -@@ -394,6 +400,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") { @@ -1079,13 +1164,33 @@ index 20c106694..0985480d6 100644 + command = "$rc -i {{source}} -o {{output}} {{include_dirs}} -O coff" + depsformat = "gcc" + description = "RC {{output}}" -+ outputs = [ "$object_subdir/{{source_name_part}}.o" ] ++ outputs = [ "$object_subdir/{{source_name_part}}.rc.o" ] + } + tool("asm") { # For GCC we can just use the C compiler to compile assembly. depfile = "{{output}}.d" -@@ -456,9 +470,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 (host_os == "win" && !is_mingw) { + tool_wrapper_path = + rebase_path("//build/toolchain/win/tool_wrapper.py", root_build_dir) + 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" + } +@@ -426,9 +442,12 @@ template("single_gcc_toolchain") { tocfile = sofile + ".TOC" soname_flag = "" @@ -1095,12 +1200,78 @@ index 20c106694..0985480d6 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}}" +@@ -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. +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 44dbc84d0..edf5b0c35 100644 +--- a/toolchain/toolchain.gni ++++ b/toolchain/toolchain.gni +@@ -67,7 +67,7 @@ if (host_os == "mac") { + } + + # Prefix for shared library files. +-if (is_posix || is_fuchsia) { ++if (is_posix || is_fuchsia || is_mingw) { + 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 fe0979038..0e36114e1 100644 +index 87d1e4aa1..60f618abf 100644 --- a/toolchain/win/BUILD.gn +++ b/toolchain/win/BUILD.gn @@ -15,7 +15,7 @@ assert(is_win, "Should only be running on Windows") @@ -1130,24 +1301,7 @@ index fe0979038..0e36114e1 100644 win_toolchains("arm64") { toolchain_arch = "arm64" } -@@ -53,10 +53,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_msvc) { -+ win_toolchains("nacl_win64") { -+ toolchain_arch = "x64" -+ toolchain_args = { -+ is_component_build = false -+ } - } - } - -@@ -92,3 +94,17 @@ if (target_os == "winuwp") { +@@ -80,3 +80,17 @@ if (target_os == "winuwp") { } } } @@ -1166,11 +1320,11 @@ index fe0979038..0e36114e1 100644 + } +} diff --git a/toolchain/win/toolchain.gni b/toolchain/win/toolchain.gni -index b296cfbdc..dfe0c8118 100644 +index 7dbd8a17e..1bf27f81d 100644 --- a/toolchain/win/toolchain.gni +++ b/toolchain/win/toolchain.gni -@@ -11,7 +11,12 @@ import("//build/toolchain/cc_wrapper.gni") - import("//build/toolchain/goma.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") @@ -1183,54 +1337,71 @@ index b296cfbdc..dfe0c8118 100644 assert(is_win, "Should only be running on Windows") -@@ -757,3 +762,29 @@ template("win_toolchains") { +@@ -867,3 +872,27 @@ template("win_toolchains") { } } } + -+if (is_mingw) { -+ template("mingw_toolchain") { -+ gcc_toolchain("mingw_" + target_name) { -+ forward_variables_from(invoker, "*") -+ 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_os = "win" -+ current_cpu = toolchain_arch -+ } ++template("mingw_toolchain") { ++ gcc_toolchain("mingw_" + target_name) { ++ forward_variables_from(invoker, "*") ++ 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_os = "win" ++ current_cpu = toolchain_arch + } + } +} 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..4f0b7b454 100644 +index 0c47c2c8c..e244ea4e9 100644 --- a/win/BUILD.gn +++ b/win/BUILD.gn @@ -16,7 +16,7 @@ windows_manifest("default_exe_manifest") { @@ -1238,7 +1409,7 @@ index 864581851..4f0b7b454 100644 } -if (is_win) { -+if (is_win && !is_mingw) { ++if (is_msvc) { assert(host_os != "mac" || target_cpu != "x86", "Windows cross-builds from Mac must be 64-bit.") diff --git a/mingw-w64-v8/002-buildflags-fixes.patch b/mingw-w64-v8/002-buildflags-fixes.patch index ce543eca61..68ddbe8f06 100644 --- a/mingw-w64-v8/002-buildflags-fixes.patch +++ b/mingw-w64-v8/002-buildflags-fixes.patch @@ -1,21 +1,29 @@ +diff --git a/.gn b/.gn +index e13ae6d5..332b811a 100644 +--- a/.gn ++++ b/.gn +@@ -41,5 +41,5 @@ default_args = { + # These are the list of GN files that run exec_script. This whitelist exists + # to force additional review for new uses of exec_script, which is strongly + # discouraged except for gypi_to_gn calls. +-exec_script_allowlist = build_dotfile_settings.exec_script_allowlist + +- [ "//build_overrides/build.gni" ] ++#exec_script_allowlist = build_dotfile_settings.exec_script_allowlist + ++# [ "//build_overrides/build.gni" ] diff --git a/BUILD.gn b/BUILD.gn -index 2cc9e36..8c70f78 100644 +index 905d947c..01f1f415 100644 --- a/BUILD.gn +++ b/BUILD.gn -@@ -39,10 +39,10 @@ declare_args() { - v8_enable_future = false +@@ -26,7 +26,7 @@ if (is_ios) { + } - # Sets -DENABLE_SYSTEM_INSTRUMENTATION. Enables OS-dependent event tracing -- v8_enable_system_instrumentation = (is_win || is_mac) && !v8_use_perfetto -+ v8_enable_system_instrumentation = (is_msvc || is_mac) && !v8_use_perfetto + # For faster Windows builds. See https://crbug.com/v8/8475. +-emit_builtins_as_inline_asm = is_win && is_clang ++emit_builtins_as_inline_asm = is_msvc && is_clang - # Sets -DV8_ENABLE_ETW_STACK_WALKING. Enables ETW Stack Walking -- v8_enable_etw_stack_walking = is_win -+ v8_enable_etw_stack_walking = is_msvc - - # Sets the GUID for the ETW provider - v8_etw_guid = "" -@@ -1363,7 +1363,12 @@ config("toolchain") { + declare_args() { + # Print to stdout on Android. +@@ -1633,12 +1633,16 @@ config("toolchain") { defines += [ "V8_TARGET_ARCH_IA32" ] if (is_win) { # Ensure no surprising artifacts from 80bit double math with x86. @@ -24,25 +32,17 @@ index 2cc9e36..8c70f78 100644 + cflags += [ "/arch:SSE2" ] + } else { + cflags += [ "-msse2" ] -+ defines += [ "V8_SWISS_TABLE_HAVE_SSE2_HOST=1" ] + } } } if (v8_current_cpu == "x64") { -@@ -1372,7 +1377,11 @@ config("toolchain") { + defines += [ "V8_TARGET_ARCH_X64" ] +- if (is_win) { ++ if (is_msvc) { # Increase the initial stack size. The default is 1MB, this is 2MB. This # applies only to executables and shared libraries produced by V8 since # ldflags are not pushed to dependants. -- ldflags += [ "/STACK:2097152" ] -+ if (is_msvc) { -+ ldflags += [ "/STACK:2097152" ] -+ } else { -+ ldflags += [ "-Wl,--stack,2097152" ] -+ } - } - } - if (is_android && v8_android_log_stdout) { -@@ -1430,7 +1439,7 @@ config("toolchain") { +@@ -1670,7 +1674,7 @@ config("toolchain") { } if (v8_no_inline) { @@ -51,34 +51,7 @@ index 2cc9e36..8c70f78 100644 cflags += [ "/Ob0" ] } else { cflags += [ -@@ -1474,7 +1483,7 @@ config("toolchain") { - ] - } - -- if (is_win) { -+ if (is_msvc) { - cflags += [ - "/wd4245", # Conversion with signed/unsigned mismatch. - "/wd4267", # Conversion with possible loss of data. -@@ -1496,7 +1505,7 @@ config("toolchain") { - ] - } - -- if (!is_clang && is_win) { -+ if (!is_clang && is_msvc) { - cflags += [ - "/wd4506", # Benign "no definition for inline function" - -@@ -1637,7 +1646,7 @@ config("toolchain") { - ] - } - -- if (!is_clang && !is_win) { -+ if (!is_clang && !is_msvc) { - cflags += [ - # Disable gcc warnings for optimizations based on the assumption that - # signed overflow does not occur. Generates false positives (see -@@ -6158,9 +6167,9 @@ v8_component("v8_libbase") { +@@ -6858,9 +6862,9 @@ v8_component("v8_libbase") { defines += [ "_CRT_RAND_S" ] # for rand_s() libs = [ @@ -91,21 +64,34 @@ index 2cc9e36..8c70f78 100644 ] if (v8_enable_etw_stack_walking) { -@@ -6374,7 +6383,7 @@ v8_source_set("v8_heap_base") { - "src/heap/base/worklist.cc", +@@ -7089,7 +7093,7 @@ v8_source_set("v8_heap_base") { ] -- if (is_clang || !is_win) { -+ if (is_clang || !is_msvc) { - if (current_cpu == "x64") { - sources += [ "src/heap/base/asm/x64/push_registers_asm.cc" ] - } else if (current_cpu == "x86") { -@@ -6394,7 +6403,7 @@ v8_source_set("v8_heap_base") { - } else if (current_cpu == "riscv64" || current_cpu == "riscv32") { - sources += [ "src/heap/base/asm/riscv/push_registers_asm.cc" ] - } -- } else if (is_win) { -+ } else if (is_msvc) { - if (current_cpu == "x64") { + if (current_cpu == "x64") { +- if (is_win) { ++ if (is_msvc) { + # Prefer a masm version with unwind directives. sources += [ "src/heap/base/asm/x64/push_registers_masm.asm" ] - } else if (current_cpu == "x86") { + } else { +@@ -7495,7 +7499,7 @@ if (current_toolchain == v8_snapshot_toolchain) { + # disable it while taking a V8 snapshot. + config("disable_icf") { + visibility = [ ":*" ] # Only targets in this file can depend on this. +- if (is_win) { ++ if (is_msvc) { + ldflags = [ "/OPT:NOICF" ] # link.exe, but also lld-link.exe. + } else if (is_apple && !use_lld) { + ldflags = [ "-Wl,-no_deduplicate" ] # ld64. +diff --git a/gni/v8.gni b/gni/v8.gni +index f13f530b..a8aa6d0b 100644 +--- a/gni/v8.gni ++++ b/gni/v8.gni +@@ -333,7 +333,7 @@ if (target_cpu == "mips64el" || target_cpu == "mips64") { + v8_add_configs += [ "//build/config/gcc:rpath_for_built_shared_libraries" ] + } + +-if (!build_with_chromium && is_clang) { ++if (!build_with_chromium && is_clang && !is_mingw) { + v8_remove_configs += [ "//build/config/clang:find_bad_constructs" ] + } + diff --git a/mingw-w64-v8/003-fix-macros-and-functions.patch b/mingw-w64-v8/003-fix-macros-and-functions.patch index a31905b7e9..908a115eab 100644 --- a/mingw-w64-v8/003-fix-macros-and-functions.patch +++ b/mingw-w64-v8/003-fix-macros-and-functions.patch @@ -1,8 +1,8 @@ diff --git a/src/base/macros.h b/src/base/macros.h -index 25a533c..fe2f37a 100644 +index e5e020d9..53af2187 100644 --- a/src/base/macros.h +++ b/src/base/macros.h -@@ -266,8 +266,12 @@ V8_INLINE A implicit_cast(A x) { +@@ -316,8 +316,12 @@ V8_INLINE A implicit_cast(A x) { # else # define V8_PTR_PREFIX "" # endif // V8_HOST_ARCH_64_BIT @@ -18,10 +18,10 @@ index 25a533c..fe2f37a 100644 # define V8_PTR_PREFIX "l" #else diff --git a/src/base/platform/platform-win32.cc b/src/base/platform/platform-win32.cc -index 152fbbf..e711182 100644 +index 11402689..ae2d7c08 100644 --- a/src/base/platform/platform-win32.cc +++ b/src/base/platform/platform-win32.cc -@@ -77,7 +77,6 @@ inline void MemoryFence() { +@@ -81,7 +81,6 @@ inline void MemoryFence() { __asm__ __volatile__("xchgl %%eax,%0 ":"=r" (barrier)); } @@ -29,7 +29,7 @@ index 152fbbf..e711182 100644 int localtime_s(tm* out_tm, const time_t* time) { -@@ -130,6 +129,7 @@ int strncpy_s(char* dest, size_t dest_size, const char* source, size_t count) { +@@ -134,6 +133,7 @@ int strncpy_s(char* dest, size_t dest_size, const char* source, size_t count) { return 0; } @@ -37,3 +37,73 @@ index 152fbbf..e711182 100644 #endif // __MINGW32__ namespace v8 { +diff --git a/src/bigint/mul-karatsuba.cc b/src/bigint/mul-karatsuba.cc +index 7df03401..67691f03 100644 +--- a/src/bigint/mul-karatsuba.cc ++++ b/src/bigint/mul-karatsuba.cc +@@ -48,7 +48,7 @@ uint32_t RoundUpLen(uint32_t len) { + // Round up, unless we're only just above the threshold. This smoothes + // the steps by which time goes up as input size increases. + uint32_t additive = ((1 << shift) - 1); +- if (shift >= 2 && (len & additive) < (1 << (shift - 2))) { ++ if (shift >= 2 && ((int)len & (int)additive) < (1 << (shift - 2))) { + return len; + } + return ((len + additive) >> shift) << shift; +diff --git a/src/libplatform/default-platform.cc b/src/libplatform/default-platform.cc +index 09ef613a..791adfa2 100644 +--- a/src/libplatform/default-platform.cc ++++ b/src/libplatform/default-platform.cc +@@ -24,10 +24,12 @@ namespace platform { + namespace { + + void PrintStackTrace() { ++#ifdef DEBUG + v8::base::debug::StackTrace trace; + trace.Print(); + // Avoid dumping duplicate stack trace on abort signal. + v8::base::debug::DisableSignalStackDump(); ++#endif + } + + constexpr int kMaxThreadPoolSize = 16; +@@ -47,9 +49,11 @@ std::unique_ptr NewDefaultPlatform( + InProcessStackDumping in_process_stack_dumping, + std::unique_ptr tracing_controller, + PriorityMode priority_mode) { ++#ifdef DEBUG + if (in_process_stack_dumping == InProcessStackDumping::kEnabled) { + v8::base::debug::EnableInProcessStackDumping(); + } ++#endif + thread_pool_size = GetActualThreadPoolSize(thread_pool_size); + auto platform = std::make_unique( + thread_pool_size, idle_task_support, std::move(tracing_controller), +@@ -61,9 +65,11 @@ std::unique_ptr NewSingleThreadedDefaultPlatform( + IdleTaskSupport idle_task_support, + InProcessStackDumping in_process_stack_dumping, + std::unique_ptr tracing_controller) { ++#ifdef DEBUG + if (in_process_stack_dumping == InProcessStackDumping::kEnabled) { + v8::base::debug::EnableInProcessStackDumping(); + } ++#endif + auto platform = std::make_unique( + 0, idle_task_support, std::move(tracing_controller)); + return platform; +diff --git a/src/objects/swiss-hash-table-helpers.h b/src/objects/swiss-hash-table-helpers.h +index f346c333..c5a0ba0f 100644 +--- a/src/objects/swiss-hash-table-helpers.h ++++ b/src/objects/swiss-hash-table-helpers.h +@@ -20,8 +20,9 @@ + // The following #defines are taken from Abseil's have_sse.h (but renamed). + #ifndef V8_SWISS_TABLE_HAVE_SSE2_HOST + #if (defined(__SSE2__) || \ +- (defined(_MSC_VER) && \ +- (defined(_M_X64) || (defined(_M_IX86) && _M_IX86_FP >= 2)))) ++ (defined(_WIN32) && \ ++ (defined(__x86_64__) || defined(__i686__) || \ ++ defined(_M_X64) || (defined(_M_IX86) && _M_IX86_FP >= 2)))) + #define V8_SWISS_TABLE_HAVE_SSE2_HOST 1 + #else + #define V8_SWISS_TABLE_HAVE_SSE2_HOST 0 diff --git a/mingw-w64-v8/004-fix-static-assert-implementations.patch b/mingw-w64-v8/004-fix-static-assert-implementations.patch index b218280cec..bfa0027e44 100644 --- a/mingw-w64-v8/004-fix-static-assert-implementations.patch +++ b/mingw-w64-v8/004-fix-static-assert-implementations.patch @@ -1,8 +1,8 @@ diff --git a/src/base/macros.h b/src/base/macros.h -index 25a533c..324df63 100644 +index e5e020d9..e9ee1e30 100644 --- a/src/base/macros.h +++ b/src/base/macros.h -@@ -176,7 +176,7 @@ V8_INLINE Dest bit_cast(Source const& source) { +@@ -199,7 +199,7 @@ V8_INLINE Dest bit_cast(Source const& source) { // DISABLE_CFI_ICALL -- Disable Control Flow Integrity indirect call checks, // useful because calls into JITed code can not be CFI verified. Same for // UBSan's function pointer type checks. @@ -12,10 +12,10 @@ index 25a533c..324df63 100644 #define DISABLE_CFI_ICALL \ V8_CLANG_NO_SANITIZE("cfi-icall") \ diff --git a/src/profiler/heap-snapshot-generator.cc b/src/profiler/heap-snapshot-generator.cc -index a9fd215..d8c5693 100644 +index 40ee39d7..fda19f27 100644 --- a/src/profiler/heap-snapshot-generator.cc +++ b/src/profiler/heap-snapshot-generator.cc -@@ -411,11 +411,11 @@ HeapSnapshot::HeapSnapshot(HeapProfiler* profiler, +@@ -427,11 +427,11 @@ HeapSnapshot::HeapSnapshot(HeapProfiler* profiler, static_assert(kSystemPointerSize != 4 || sizeof(HeapGraphEdge) == 12); static_assert(kSystemPointerSize != 8 || sizeof(HeapGraphEdge) == 24); static_assert(kSystemPointerSize != 4 || sizeof(HeapEntry) == 32); diff --git a/mingw-w64-v8/006-support-clang-in-mingw-mode.patch b/mingw-w64-v8/006-support-clang-in-mingw-mode.patch index b277102bcf..7dcf9fb87f 100644 --- a/mingw-w64-v8/006-support-clang-in-mingw-mode.patch +++ b/mingw-w64-v8/006-support-clang-in-mingw-mode.patch @@ -1,8 +1,8 @@ diff --git a/include/v8config.h b/include/v8config.h -index 33bb3f9..546830d 100644 +index 57b537e6..e3467c72 100644 --- a/include/v8config.h +++ b/include/v8config.h -@@ -340,6 +340,13 @@ path. Add it with -I to the command line +@@ -372,6 +372,13 @@ path. Add it with -I to the command line #if defined(__GNUC__) // Clang in gcc mode. # define V8_CC_GNU 1 @@ -16,7 +16,7 @@ index 33bb3f9..546830d 100644 #endif # define V8_HAS_ATTRIBUTE_ALWAYS_INLINE (__has_attribute(always_inline)) -@@ -749,7 +756,7 @@ V8 shared library set USING_V8_SHARED. +@@ -870,7 +877,7 @@ V8 shared library set USING_V8_SHARED. #elif defined(_M_IX86) || defined(__i386__) #define V8_HOST_ARCH_IA32 1 #define V8_HOST_ARCH_32_BIT 1 @@ -25,7 +25,7 @@ index 33bb3f9..546830d 100644 #define V8_HOST_ARCH_ARM64 1 #define V8_HOST_ARCH_64_BIT 1 #elif defined(__ARMEL__) -@@ -802,7 +809,7 @@ V8 shared library set USING_V8_SHARED. +@@ -916,7 +923,7 @@ V8 shared library set USING_V8_SHARED. #define V8_TARGET_ARCH_X64 1 #elif defined(_M_IX86) || defined(__i386__) #define V8_TARGET_ARCH_IA32 1 @@ -34,4 +34,3 @@ index 33bb3f9..546830d 100644 #define V8_TARGET_ARCH_ARM64 1 #elif defined(__ARMEL__) #define V8_TARGET_ARCH_ARM 1 - \ No newline at end of file diff --git a/mingw-w64-v8/008-prioritized-native-thread-on-windows.patch b/mingw-w64-v8/008-prioritized-native-thread-on-windows.patch index d09d2fcba1..ea3e174d67 100644 --- a/mingw-w64-v8/008-prioritized-native-thread-on-windows.patch +++ b/mingw-w64-v8/008-prioritized-native-thread-on-windows.patch @@ -1,17 +1,17 @@ diff --git a/src/base/platform/time.cc b/src/base/platform/time.cc -index b6da0a6..b1f5a55 100644 +index c2d36cc2..0b724fcc 100644 --- a/src/base/platform/time.cc +++ b/src/base/platform/time.cc -@@ -814,6 +814,8 @@ ThreadTicks ThreadTicks::Now() { - #endif +@@ -802,6 +802,8 @@ ThreadTicks ThreadTicks::Now() { + UNREACHABLE(); #elif V8_OS_DARWIN return ThreadTicks(ComputeThreadTicks()); +#elif V8_OS_WIN + return ThreadTicks::GetForThread(::GetCurrentThread()); #elif V8_OS_FUCHSIA return ThreadTicks(GetFuchsiaThreadTicks()); - #elif(defined(_POSIX_THREAD_CPUTIME) && (_POSIX_THREAD_CPUTIME >= 0)) || \ -@@ -821,8 +823,6 @@ ThreadTicks ThreadTicks::Now() { + #elif (defined(_POSIX_THREAD_CPUTIME) && (_POSIX_THREAD_CPUTIME >= 0)) || \ +@@ -809,8 +811,6 @@ ThreadTicks ThreadTicks::Now() { return ThreadTicks(ClockNow(CLOCK_THREAD_CPUTIME_ID)); #elif V8_OS_SOLARIS return ThreadTicks(gethrvtime() / Time::kNanosecondsPerMicrosecond); diff --git a/mingw-w64-v8/009-unicode-for-wide-char-functions.patch b/mingw-w64-v8/009-unicode-for-wide-char-functions.patch index e65c0ce890..17dd932cb6 100644 --- a/mingw-w64-v8/009-unicode-for-wide-char-functions.patch +++ b/mingw-w64-v8/009-unicode-for-wide-char-functions.patch @@ -1,5 +1,5 @@ diff --git a/src/base/debug/stack_trace_win.cc b/src/base/debug/stack_trace_win.cc -index f981bec..16655d5 100644 +index f981bec6..16655d51 100644 --- a/src/base/debug/stack_trace_win.cc +++ b/src/base/debug/stack_trace_win.cc @@ -81,7 +81,7 @@ bool InitializeSymbols() { @@ -12,10 +12,10 @@ index f981bec..16655d5 100644 // To get the path without the filename, we just need to remove the final // slash and everything after it. diff --git a/src/base/platform/platform-win32.cc b/src/base/platform/platform-win32.cc -index 152fbbf..2b7dea5 100644 +index 11402689..b8cfb30d 100644 --- a/src/base/platform/platform-win32.cc +++ b/src/base/platform/platform-win32.cc -@@ -760,13 +760,13 @@ void OS::EnsureWin32MemoryAPILoaded() { +@@ -802,13 +802,13 @@ void OS::EnsureWin32MemoryAPILoaded() { static bool loaded = false; if (!loaded) { VirtualAlloc2 = (VirtualAlloc2_t)GetProcAddress( @@ -32,7 +32,7 @@ index 152fbbf..2b7dea5 100644 loaded = true; } -@@ -1043,7 +1043,7 @@ bool OS::DiscardSystemPages(void* address, size_t size) { +@@ -1097,7 +1097,7 @@ bool OS::DiscardSystemPages(void* address, size_t size) { reinterpret_cast(-1)) discard_virtual_memory = reinterpret_cast(GetProcAddress( @@ -42,10 +42,10 @@ index 152fbbf..2b7dea5 100644 // MEM_RESET. DiscardVirtualMemoryFunction discard_function = discard_virtual_memory.load(); diff --git a/src/diagnostics/unwinding-info-win64.cc b/src/diagnostics/unwinding-info-win64.cc -index a71b866..5c8c601 100644 +index 1312609e..0290c5a0 100644 --- a/src/diagnostics/unwinding-info-win64.cc +++ b/src/diagnostics/unwinding-info-win64.cc -@@ -471,7 +471,7 @@ static decltype( +@@ -473,7 +473,7 @@ static decltype( void LoadNtdllUnwindingFunctionsOnce() { // Load functions from the ntdll.dll module. HMODULE ntdll_module = diff --git a/mingw-w64-v8/011-make-sure-that-__rdtsc-is-declared.patch b/mingw-w64-v8/011-make-sure-that-__rdtsc-is-declared.patch index 3376481982..6decfda44c 100644 --- a/mingw-w64-v8/011-make-sure-that-__rdtsc-is-declared.patch +++ b/mingw-w64-v8/011-make-sure-that-__rdtsc-is-declared.patch @@ -1,8 +1,8 @@ diff --git a/src/base/platform/time.cc b/src/base/platform/time.cc -index b6da0a6..34e7e38 100644 +index c2d36cc2..1948d0db 100644 --- a/src/base/platform/time.cc +++ b/src/base/platform/time.cc -@@ -876,6 +876,12 @@ void ThreadTicks::WaitUntilInitializedWin() { +@@ -864,6 +864,12 @@ void ThreadTicks::WaitUntilInitializedWin() { #endif } diff --git a/mingw-w64-v8/012-remove-dllimport-attributes.patch b/mingw-w64-v8/012-remove-dllimport-attributes.patch index 027eeefb3b..2c85d9ca38 100644 --- a/mingw-w64-v8/012-remove-dllimport-attributes.patch +++ b/mingw-w64-v8/012-remove-dllimport-attributes.patch @@ -1,47 +1,5 @@ -diff --git a/include/v8-fast-api-calls.h b/include/v8-fast-api-calls.h -index e40f106..c70808a 100644 ---- a/include/v8-fast-api-calls.h -+++ b/include/v8-fast-api-calls.h -@@ -328,7 +328,7 @@ class CTypeInfo { - struct FastApiTypedArrayBase { - public: - // Returns the length in number of elements. -- size_t V8_EXPORT length() const { return length_; } -+ size_t length() const { return length_; } - // Checks whether the given index is within the bounds of the collection. - void V8_EXPORT ValidateIndex(size_t index) const; - -diff --git a/src/common/assert-scope.h b/src/common/assert-scope.h -index 42d9649..064c33d 100644 ---- a/src/common/assert-scope.h -+++ b/src/common/assert-scope.h -@@ -147,7 +147,7 @@ class CombinationAssertScope; - template - class V8_NODISCARD CombinationAssertScope : public Scope { - public: -- V8_EXPORT_PRIVATE static bool IsAllowed() { -+ static bool IsAllowed() { - // Define IsAllowed() explicitly rather than with using Scope::IsAllowed, to - // allow SFINAE removal of IsAllowed() when it's not defined (under debug). - return Scope::IsAllowed(); -@@ -164,12 +164,12 @@ class CombinationAssertScope - - public: - // Constructor for per-thread scopes. -- V8_EXPORT_PRIVATE CombinationAssertScope() : Scope(), NextScopes() {} -+ CombinationAssertScope() : Scope(), NextScopes() {} - // Constructor for per-isolate scopes. -- V8_EXPORT_PRIVATE explicit CombinationAssertScope(Isolate* isolate) -+ explicit CombinationAssertScope(Isolate* isolate) - : Scope(isolate), NextScopes(isolate) {} - -- V8_EXPORT_PRIVATE static bool IsAllowed() { -+ static bool IsAllowed() { - return Scope::IsAllowed() && NextScopes::IsAllowed(); - } - diff --git a/src/execution/interrupts-scope.h b/src/execution/interrupts-scope.h -index 8be3ce9..76815c3 100644 +index 8be3ce98..76815c32 100644 --- a/src/execution/interrupts-scope.h +++ b/src/execution/interrupts-scope.h @@ -19,7 +19,7 @@ class V8_NODISCARD InterruptsScope { @@ -53,50 +11,63 @@ index 8be3ce9..76815c3 100644 Mode mode) : stack_guard_(nullptr), intercept_mask_(intercept_mask), -diff --git a/src/heap/new-spaces.h b/src/heap/new-spaces.h -index dc57faf..ec08364 100644 ---- a/src/heap/new-spaces.h -+++ b/src/heap/new-spaces.h -@@ -516,7 +516,7 @@ class V8_EXPORT_PRIVATE SemiSpaceNewSpace final : public NewSpace { - // ----------------------------------------------------------------------------- - // PagedNewSpace - --class V8_EXPORT_PRIVATE PagedSpaceForNewSpace final : public PagedSpaceBase { -+class PagedSpaceForNewSpace final : public PagedSpaceBase { +diff --git a/src/heap/conservative-stack-visitor.h b/src/heap/conservative-stack-visitor.h +index d5f92c35..ae75dd12 100644 +--- a/src/heap/conservative-stack-visitor.h ++++ b/src/heap/conservative-stack-visitor.h +@@ -33,7 +33,7 @@ class RootVisitor; + // 5) OnlyScanMainV8Heap() - returns true if the visitor does not handle the + // external code and trusted spaces. + template +-class V8_EXPORT_PRIVATE ConservativeStackVisitorBase ++class ConservativeStackVisitorBase + : public ::heap::base::StackVisitor { public: - // Creates an old space object. The constructor does not allocate pages - // from OS. + ConservativeStackVisitorBase(Isolate* isolate, RootVisitor* root_visitor); diff --git a/src/objects/js-objects.h b/src/objects/js-objects.h -index e0cd974..b9edff1 100644 +index 5900e514..14ea5b53 100644 --- a/src/objects/js-objects.h +++ b/src/objects/js-objects.h -@@ -663,7 +663,7 @@ class JSObject : public TorqueGeneratedJSObject { - Isolate* isolate, Handle object, PropertyNormalizationMode mode, - int expected_additional_properties, bool use_cache, const char* reason); +@@ -745,7 +745,7 @@ class JSObject : public TorqueGeneratedJSObject { + PropertyNormalizationMode mode, int expected_additional_properties, + bool use_cache, const char* reason); - V8_EXPORT_PRIVATE static void NormalizeProperties( + static void NormalizeProperties( - Isolate* isolate, Handle object, PropertyNormalizationMode mode, - int expected_additional_properties, const char* reason) { - const bool kUseCache = true; + Isolate* isolate, DirectHandle object, + PropertyNormalizationMode mode, int expected_additional_properties, + const char* reason) { diff --git a/src/objects/map.h b/src/objects/map.h -index 46930be..c0ff7e5 100644 +index 73838fa6..2021427b 100644 --- a/src/objects/map.h +++ b/src/objects/map.h -@@ -549,7 +549,7 @@ class Map : public TorqueGeneratedMap { - V8_EXPORT_PRIVATE static Handle Normalize( - Isolate* isolate, Handle map, ElementsKind new_elements_kind, - PropertyNormalizationMode mode, bool use_cache, const char* reason); -- V8_EXPORT_PRIVATE static Handle Normalize(Isolate* isolate, -+ static Handle Normalize(Isolate* isolate, - Handle map, - ElementsKind new_elements_kind, - PropertyNormalizationMode mode, +@@ -601,7 +601,7 @@ class Map : public TorqueGeneratedMap { + Isolate* isolate, DirectHandle map, ElementsKind new_elements_kind, + DirectHandle new_prototype, PropertyNormalizationMode mode, + bool use_cache, const char* reason); +- V8_EXPORT_PRIVATE static Handle Normalize( ++ static Handle Normalize( + Isolate* isolate, DirectHandle map, ElementsKind new_elements_kind, + DirectHandle new_prototype, PropertyNormalizationMode mode, + const char* reason) { +diff --git a/src/objects/string-inl.h b/src/objects/string-inl.h +index c1bbd1ea..1eb93ba9 100644 +--- a/src/objects/string-inl.h ++++ b/src/objects/string-inl.h +@@ -851,7 +851,7 @@ const Char* String::GetDirectStringChars( + // static + template