diff --git a/brave/.SRCINFO b/brave/.SRCINFO index 95e1613b5..a94e86c36 100644 --- a/brave/.SRCINFO +++ b/brave/.SRCINFO @@ -1,6 +1,6 @@ pkgbase = brave pkgdesc = Web browser that blocks ads and trackers by default - pkgver = 1.52.129 + pkgver = 1.57.49 pkgrel = 1 url = https://www.brave.com/download arch = x86_64 @@ -42,7 +42,6 @@ pkgbase = brave depends = hicolor-icon-theme depends = fontconfig depends = woff2 - depends = brotli depends = libjpeg depends = icu depends = dav1d @@ -65,16 +64,14 @@ pkgbase = brave optdepends = org.freedesktop.secrets: password storage backend on GNOME / Xfce optdepends = kwallet: support for storing passwords in KWallet on Plasma options = !lto - source = brave-browser::git+https://github.com/brave/brave-browser.git#tag=v1.52.129 - source = brave::git+https://github.com/brave/brave-core.git#tag=v1.52.129 - source = chromium-mirror::git+https://github.com/chromium/chromium.git#tag=114.0.5735.198 + source = brave-browser::git+https://github.com/brave/brave-browser.git#tag=v1.57.49 + source = brave::git+https://github.com/brave/brave-core.git#tag=v1.57.49 + source = chromium-mirror::git+https://github.com/chromium/chromium.git#tag=116.0.5845.96 source = depot_tools::git+https://chromium.googlesource.com/chromium/tools/depot_tools.git + source = https://github.com/stha09/chromium-patches/releases/download/chromium-116-patchset-2/chromium-116-patchset-2.tar.xz source = https://github.com/foutrelis/chromium-launcher/archive/refs/tags/v8/chromium-launcher-8.tar.gz source = chromium-launcher-electron-app.patch source = chromium-launcher-vendor.patch - source = system-rust-utils.patch - source = 0001-Fix-Rust-linking-on-component-and-debug-Windows-builds.patch - source = 0002-Remove-the-prebuilt-toolchain-from-the-Android-team.patch source = brave-1.19-BUILD.gn.patch source = brave-1.43-bitcoin-core_remove-serialize.h.patch source = brave-1.43-debounce-debounce_navigation_throttle_fix.patch @@ -84,23 +81,17 @@ pkgbase = brave source = brave-1.52-bitints-libstdcxx-bypass.patch source = brave-1.52-missing-includes.patch source = brave-1.52-playlist-user-agent-only-constructor.patch - source = https://gitlab.archlinux.org/archlinux/packaging/packages/chromium/-/raw/fa08adba87b6222bdf9ba31aaa41579e634ec444/add-some-typename-s-that-are-required-in-C-17.patch - source = https://gitlab.archlinux.org/archlinux/packaging/packages/chromium/-/raw/fa08adba87b6222bdf9ba31aaa41579e634ec444/REVERT-disable-autoupgrading-debug-info.patch - source = https://gitlab.archlinux.org/archlinux/packaging/packages/chromium/-/raw/fa08adba87b6222bdf9ba31aaa41579e634ec444/download-bubble-typename.patch - source = https://gitlab.archlinux.org/archlinux/packaging/packages/chromium/-/raw/fa08adba87b6222bdf9ba31aaa41579e634ec444/webauthn-variant.patch - source = https://gitlab.archlinux.org/archlinux/packaging/packages/chromium/-/raw/fa08adba87b6222bdf9ba31aaa41579e634ec444/random-fixes-for-gcc13.patch - source = https://gitlab.archlinux.org/archlinux/packaging/packages/chromium/-/raw/fa08adba87b6222bdf9ba31aaa41579e634ec444/disable-GlobalMediaControlsCastStartStop.patch - source = https://gitlab.archlinux.org/archlinux/packaging/packages/chromium/-/raw/fa08adba87b6222bdf9ba31aaa41579e634ec444/use-oauth2-client-switches-as-default.patch + source = https://gitlab.archlinux.org/archlinux/packaging/packages/chromium/-/raw/116.0.5845.96-1/REVERT-disable-autoupgrading-debug-info.patch + source = https://gitlab.archlinux.org/archlinux/packaging/packages/chromium/-/raw/116.0.5845.96-1/random-build-fixes.patch + source = https://gitlab.archlinux.org/archlinux/packaging/packages/chromium/-/raw/116.0.5845.96-1/use-oauth2-client-switches-as-default.patch sha256sums = SKIP sha256sums = SKIP sha256sums = SKIP sha256sums = SKIP + sha256sums = 25ad7c1a5e0b7332f80ed15ccf07d7e871d8ffb4af64df7c8fef325a527859b0 sha256sums = 213e50f48b67feb4441078d50b0fd431df34323be15be97c55302d3fdac4483a sha256sums = 9235485adc4acbfaf303605f4428a6995a7b0b3b5a95181b185afbcb9f1f6ae5 sha256sums = 404bf09df39310a1e374c5e7eb9c7311239798adf4e8cd85b7ff04fc79647f88 - sha256sums = dcaf12a8b2ba15cefafd6e3c053b2ec490b1b8e1c89a3309e41133c0cd183ed3 - sha256sums = dfb5ca39abe7dd449729d3af3724fe27208d8cda76ecc4916cc57a4ad9c8e1b1 - sha256sums = 01a809e8bf7eeed6e263bc7118d6e40395dca7ac8463dbe230303e13d17d673e sha256sums = 12a3d37ffca4c0fa25f89f02efdf79d24f6412ee29ec35e8a00f9086dba4e822 sha256sums = 984bb0257ed6fe4af543c3fb803ed81bddc97ff367ccd93620404be60cb78eb3 sha256sums = 30a6a9ca2a6dd965cb2d9f02639079130948bf45d483f0c629f2cf8394a1c22f @@ -110,12 +101,8 @@ pkgbase = brave sha256sums = f781d6315e4147b775350d7a36481c3ce43b582eee5ee228768e42c30d9dd9ca sha256sums = 1654fa922d10a591d5c28159a6d22d1183bcbd3448f175d7f3e2e11879588ddd sha256sums = 7cf8569ff905666889842c36e82d51c08d482745cd2f71e48fa1296824f09839 - sha256sums = 621ed210d75d0e846192c1571bb30db988721224a41572c27769c0288d361c11 sha256sums = 1b782b0f6d4f645e4e0daa8a4852d63f0c972aa0473319216ff04613a0592a69 - sha256sums = d464eed4be4e9bf6187b4c40a759c523b7befefa25ba34ad6401b2a07649ca2a - sha256sums = 590fabbb26270947cb477378b53a9dcd17855739076b4af9983e1e54dfcab6d7 - sha256sums = ba4dd0a25a4fc3267ed19ccb39f28b28176ca3f97f53a4e9f5e9215280040ea0 - sha256sums = 7f3b1b22d6a271431c1f9fc92b6eb49c6d80b8b3f868bdee07a6a1a16630a302 + sha256sums = e938c6ee7087eed8f0de83ffb0ca89e328575808fafa4fe3950aeb1bc58b9411 sha256sums = e393174d7695d0bafed69e868c5fbfecf07aa6969f3b64596d0bae8b067e1711 pkgname = brave diff --git a/brave/.SRCINFO.rej b/brave/.SRCINFO.rej new file mode 100644 index 000000000..a4858b176 --- /dev/null +++ b/brave/.SRCINFO.rej @@ -0,0 +1,81 @@ +--- .SRCINFO ++++ .SRCINFO +@@ -1,6 +1,6 @@ + pkgbase = brave + pkgdesc = Web browser that blocks ads and trackers by default +- pkgver = 1.52.129 ++ pkgver = 1.57.49 + pkgrel = 1 + url = https://www.brave.com/download + arch = x86_64 +@@ -42,7 +42,6 @@ pkgbase = brave + depends = hicolor-icon-theme + depends = fontconfig + depends = woff2 +- depends = brotli + depends = libjpeg + depends = icu + depends = dav1d +@@ -65,16 +64,14 @@ pkgbase = brave + optdepends = org.freedesktop.secrets: password storage backend on GNOME / Xfce + optdepends = kwallet: support for storing passwords in KWallet on Plasma + options = !lto +- source = brave-browser::git+https://github.com/brave/brave-browser.git#tag=v1.52.129 +- source = brave::git+https://github.com/brave/brave-core.git#tag=v1.52.129 +- source = chromium-mirror::git+https://github.com/chromium/chromium.git#tag=114.0.5735.198 ++ source = brave-browser::git+https://github.com/brave/brave-browser.git#tag=v1.57.49 ++ source = brave::git+https://github.com/brave/brave-core.git#tag=v1.57.49 ++ source = chromium-mirror::git+https://github.com/chromium/chromium.git#tag=116.0.5845.96 + source = depot_tools::git+https://chromium.googlesource.com/chromium/tools/depot_tools.git ++ source = https://github.com/stha09/chromium-patches/releases/download/chromium-116-patchset-2/chromium-116-patchset-2.tar.xz + source = https://github.com/foutrelis/chromium-launcher/archive/refs/tags/v8/chromium-launcher-8.tar.gz + source = chromium-launcher-electron-app.patch + source = chromium-launcher-vendor.patch +- source = system-rust-utils.patch +- source = 0001-Fix-Rust-linking-on-component-and-debug-Windows-builds.patch +- source = 0002-Remove-the-prebuilt-toolchain-from-the-Android-team.patch + source = brave-1.19-BUILD.gn.patch + source = brave-1.43-bitcoin-core_remove-serialize.h.patch + source = brave-1.43-debounce-debounce_navigation_throttle_fix.patch +@@ -84,23 +81,17 @@ pkgbase = brave + source = brave-1.52-bitints-libstdcxx-bypass.patch + source = brave-1.52-missing-includes.patch + source = brave-1.52-playlist-user-agent-only-constructor.patch +- source = https://gitlab.archlinux.org/archlinux/packaging/packages/chromium/-/raw/fa08adba87b6222bdf9ba31aaa41579e634ec444/add-some-typename-s-that-are-required-in-C-17.patch +- source = https://gitlab.archlinux.org/archlinux/packaging/packages/chromium/-/raw/fa08adba87b6222bdf9ba31aaa41579e634ec444/REVERT-disable-autoupgrading-debug-info.patch +- source = https://gitlab.archlinux.org/archlinux/packaging/packages/chromium/-/raw/fa08adba87b6222bdf9ba31aaa41579e634ec444/download-bubble-typename.patch +- source = https://gitlab.archlinux.org/archlinux/packaging/packages/chromium/-/raw/fa08adba87b6222bdf9ba31aaa41579e634ec444/webauthn-variant.patch +- source = https://gitlab.archlinux.org/archlinux/packaging/packages/chromium/-/raw/fa08adba87b6222bdf9ba31aaa41579e634ec444/random-fixes-for-gcc13.patch +- source = https://gitlab.archlinux.org/archlinux/packaging/packages/chromium/-/raw/fa08adba87b6222bdf9ba31aaa41579e634ec444/disable-GlobalMediaControlsCastStartStop.patch +- source = https://gitlab.archlinux.org/archlinux/packaging/packages/chromium/-/raw/fa08adba87b6222bdf9ba31aaa41579e634ec444/use-oauth2-client-switches-as-default.patch ++ source = https://gitlab.archlinux.org/archlinux/packaging/packages/chromium/-/raw/116.0.5845.96-1/REVERT-disable-autoupgrading-debug-info.patch ++ source = https://gitlab.archlinux.org/archlinux/packaging/packages/chromium/-/raw/116.0.5845.96-1/random-build-fixes.patch ++ source = https://gitlab.archlinux.org/archlinux/packaging/packages/chromium/-/raw/116.0.5845.96-1/use-oauth2-client-switches-as-default.patch + sha256sums = SKIP + sha256sums = SKIP + sha256sums = SKIP + sha256sums = SKIP ++ sha256sums = 25ad7c1a5e0b7332f80ed15ccf07d7e871d8ffb4af64df7c8fef325a527859b0 + sha256sums = 213e50f48b67feb4441078d50b0fd431df34323be15be97c55302d3fdac4483a + sha256sums = 9235485adc4acbfaf303605f4428a6995a7b0b3b5a95181b185afbcb9f1f6ae5 + sha256sums = 404bf09df39310a1e374c5e7eb9c7311239798adf4e8cd85b7ff04fc79647f88 +- sha256sums = dcaf12a8b2ba15cefafd6e3c053b2ec490b1b8e1c89a3309e41133c0cd183ed3 +- sha256sums = dfb5ca39abe7dd449729d3af3724fe27208d8cda76ecc4916cc57a4ad9c8e1b1 +- sha256sums = 01a809e8bf7eeed6e263bc7118d6e40395dca7ac8463dbe230303e13d17d673e + sha256sums = 12a3d37ffca4c0fa25f89f02efdf79d24f6412ee29ec35e8a00f9086dba4e822 + sha256sums = 984bb0257ed6fe4af543c3fb803ed81bddc97ff367ccd93620404be60cb78eb3 + sha256sums = 30a6a9ca2a6dd965cb2d9f02639079130948bf45d483f0c629f2cf8394a1c22f +@@ -110,12 +101,8 @@ pkgbase = brave + sha256sums = f781d6315e4147b775350d7a36481c3ce43b582eee5ee228768e42c30d9dd9ca + sha256sums = 1654fa922d10a591d5c28159a6d22d1183bcbd3448f175d7f3e2e11879588ddd + sha256sums = 7cf8569ff905666889842c36e82d51c08d482745cd2f71e48fa1296824f09839 +- sha256sums = 621ed210d75d0e846192c1571bb30db988721224a41572c27769c0288d361c11 + sha256sums = 1b782b0f6d4f645e4e0daa8a4852d63f0c972aa0473319216ff04613a0592a69 +- sha256sums = d464eed4be4e9bf6187b4c40a759c523b7befefa25ba34ad6401b2a07649ca2a +- sha256sums = 590fabbb26270947cb477378b53a9dcd17855739076b4af9983e1e54dfcab6d7 +- sha256sums = ba4dd0a25a4fc3267ed19ccb39f28b28176ca3f97f53a4e9f5e9215280040ea0 +- sha256sums = 7f3b1b22d6a271431c1f9fc92b6eb49c6d80b8b3f868bdee07a6a1a16630a302 ++ sha256sums = e938c6ee7087eed8f0de83ffb0ca89e328575808fafa4fe3950aeb1bc58b9411 + sha256sums = e393174d7695d0bafed69e868c5fbfecf07aa6969f3b64596d0bae8b067e1711 + + pkgname = brave diff --git a/brave/0001-Fix-Rust-linking-on-component-and-debug-Windows-builds.patch b/brave/0001-Fix-Rust-linking-on-component-and-debug-Windows-builds.patch deleted file mode 100644 index 8bcc450dd..000000000 --- a/brave/0001-Fix-Rust-linking-on-component-and-debug-Windows-builds.patch +++ /dev/null @@ -1,1045 +0,0 @@ -From e917deabc983569acfd001b06fa71ea3471d8ff3 Mon Sep 17 00:00:00 2001 -From: danakj -Date: Thu, 04 May 2023 16:03:06 +0000 -Subject: [PATCH] Fix Rust linking on component and debug Windows builds - -1. The CRT can be specified from rustc but only static/dynamic, -not release/debug. This is tracked upstream in -https://github.com/rust-lang/libs-team/issues/211 - -Because of this, we must not use the CRT command line options -from rustc, and instead specify the library directly. This is -done at the same location where the CRT is chosen for C++ -targets via the "/MD" and friends flags. - -Then, we must not have rustc try to also link the CRT and we -disable that by setting -Zlink-directives=false for the libc -crate. - -2. After the above, we have two sets of libraries that must be -linked when using the rust stdlib. - -Internal dependencies, which are #[link] directives from the -libc crate (other than the CRT), which must be linked any time -the rust lib is used. - -Public dependencies, which are linked automatically by rustc -but are not linked by C++ targets that depend on Rust targets. - -So we split these into two configs, and expose the latter on -the BUILD rule for C++ targets that depend on Rust. - -3. The local build of stdlib is here to stay and is always used -with the Chromium toolchain, so remove a bunch of configuration -levers around it and just hardcode the stdlib in when using the -Chromium toolchain. And hardcode the prebuilt stdlib path when -not using the Chromium toolchain. This removes a bunch of -branches elsewhere in our GN rules as we can simply depend on -the "rust stdlib target" instead of choosing between them. - -Then drop the test build target that was opting into the local -stdlib as all our Rust build tests do that now. - -4. Don't use __attribute__((visibility("default"))) on Windows, -use __declspec(dllexport) instead. - -I don't know that this fixes anything, but that attribute doesn't -exist on Windows, so yeah. - -5. In the component build, C++ targets are linked with the dynamic -CRT. In order to have mixed targets, Rust needs to as well. Then -Rust build script exes are linked with the dynamic CRT and they are -unable to find the DLL on the bots (which don't have Visual Studio) -installed. The CRT DLL is placed in root_out_dir, so we move build -script exes to the root_out_dir in order to have them find the DLL -and be able to execute. - -6. Ensure the CRT DLLs are present on the bots when running the -tests by adding a data_deps edge to them for build_rust_tests. -Normally this edge comes from a dependency on //base which basically -everything has, but our Rust build tests don't. - -7. Disable rust_shared_library unit test on Windows component build -while we figure out how to get the right `data_deps` edge from the -test to the library so that it's included in the isolate. When -building a library's tests, the library itself is recompiled under -cfg=test as part of the test exe. So the rlib or shared library -itself is not used. But we still need to depend on any transitive -deps of that library when building the unit tests, so the unit tests -add a deps edge onto the library. - -For shared libraries this deps edge doesn't do anything on Linux, or -on Windows non-component builds. But on Windows component builds, the -unit test EXE acquires a dependency on the DLL (as shown by dumpbin) -and thus the DLL needs to be present when running the test. - -Bug: 1442273, 1434719 - -Change-Id: I157a0728ec25f636d0b78973b8ab81205e7b25ef -Cq-Include-Trybots: luci.chromium.try:win-rust-x64-rel,win-rust-x64-dbg,linux-rust-x64-rel,linux-rust-x64-dbg,android-rust-arm64-rel,android-rust-arm64-dbg,android-rust-arm32-rel -Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/4499979 -Reviewed-by: Bruce Dawson -Commit-Queue: danakj -Reviewed-by: Adrian Taylor -Cr-Commit-Position: refs/heads/main@{#1139572} ---- - -diff --git a/build/config/BUILD.gn b/build/config/BUILD.gn -index 210ba0d..596bd9d 100644 ---- a/build/config/BUILD.gn -+++ b/build/config/BUILD.gn -@@ -335,7 +335,6 @@ - - if (is_win) { - configs += _windows_linker_configs -- configs += [ "//build/config/win:exe_flags" ] - } else if (is_mac) { - configs += [ "//build/config/mac:mac_dynamic_flags" ] - } else if (is_ios) { -diff --git a/build/config/rust.gni b/build/config/rust.gni -index 75d236fd..c0d934c 100644 ---- a/build/config/rust.gni -+++ b/build/config/rust.gni -@@ -38,12 +38,6 @@ - # Use the Rust toolchain built in-tree. See //tools/rust. - use_chromium_rust_toolchain = true - -- # Build libstd locally with GN and use that instead of the prebuilts, where -- # applicable. If this is false the prebuilt libstd will always be used. If -- # true, the local build is only used with the Chromium Rust toolchain and only -- # on supported platforms and GN targets. -- enable_local_libstd = true -- - # Chromium currently has a Rust toolchain for Android and Linux, but - # if you wish to experiment on more platforms you can use this - # argument to specify an alternative toolchain. -@@ -87,13 +81,6 @@ - # Use a separate declare_args so these variables' defaults can depend on the - # ones above. - -- # When true, uses the locally-built std in all Rust targets. -- # -- # As an internal implementation detail this can be overridden on specific -- # targets (e.g. to run build.rs scripts while building std), but this -- # generally should not be done. -- use_local_std_by_default = enable_local_libstd && use_chromium_rust_toolchain -- - # Individual Rust components. - - # Conversions between Rust types and C++ types. -@@ -286,13 +273,6 @@ - use_unverified_rust_toolchain, - "Must use Chromium Rust toolchain for LTO") - --# Determine whether the local libstd can and should be built. --local_libstd_supported = enable_local_libstd && use_chromium_rust_toolchain -- --# Determine whether the prebuilt libstd can be used --prebuilt_libstd_supported = !use_chromium_rust_toolchain || -- (target_os == "linux" && target_cpu == "x64") -- - # Arguments for Rust invocation. - # This is common between gcc/clang, Mac and Windows toolchains so specify once, - # here. This is not the complete command-line: toolchains should add -o -diff --git a/build/config/win/BUILD.gn b/build/config/win/BUILD.gn -index 8a3bfbbb..ff7d345 100644 ---- a/build/config/win/BUILD.gn -+++ b/build/config/win/BUILD.gn -@@ -329,11 +329,6 @@ - } - } - --# Flags that should be applied to building .exe files but not .dll files. --config("exe_flags") { -- rustflags = [ "-Ctarget-feature=+crt-static" ] --} -- - config("default_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 -@@ -506,11 +501,25 @@ - if (is_debug) { - # This pulls in the DLL debug CRT and defines _DEBUG - cflags = [ "/MDd" ] -+ -+ # /MDd specifies msvcrtd.lib as the CRT library. Rust needs to agree, so -+ # we specify it explicitly. -+ # Once https://github.com/rust-lang/rust/issues/39016 is resolved we should -+ # instead tell rustc which CRT to use (static/dynamic + release/debug). -+ rustflags = [ "-Clink-arg=msvcrtd.lib" ] -+ - if (use_custom_libcxx) { - ldflags = [ "/DEFAULTLIB:msvcprtd.lib" ] - } - } else { - cflags = [ "/MD" ] -+ -+ # /MD specifies msvcrt.lib as the CRT library. Rust needs to agree, so -+ # we specify it explicitly. -+ # Once https://github.com/rust-lang/rust/issues/39016 is resolved we should -+ # instead tell rustc which CRT to use (static/dynamic + release/debug). -+ rustflags = [ "-Clink-arg=msvcrt.lib" ] -+ - if (use_custom_libcxx) { - ldflags = [ "/DEFAULTLIB:msvcprt.lib" ] - } -@@ -521,11 +530,25 @@ - if (is_debug) { - # This pulls in the static debug CRT and defines _DEBUG - cflags = [ "/MTd" ] -+ -+ # /MTd specifies libcmtd.lib as the CRT library. Rust needs to agree, so -+ # we specify it explicitly. -+ # Once https://github.com/rust-lang/rust/issues/39016 is resolved we should -+ # instead tell rustc which CRT to use (static/dynamic + release/debug). -+ rustflags = [ "-Clink-arg=libcmtd.lib" ] -+ - if (use_custom_libcxx) { - ldflags = [ "/DEFAULTLIB:libcpmtd.lib" ] - } - } else { - cflags = [ "/MT" ] -+ -+ # /MT specifies libcmt.lib as the CRT library. Rust needs to agree, so -+ # we specify it explicitly. -+ # Once https://github.com/rust-lang/rust/issues/39016 is resolved we should -+ # instead tell rustc which CRT to use (static/dynamic + release/debug). -+ rustflags = [ "-Clink-arg=libcmt.lib" ] -+ - if (use_custom_libcxx) { - ldflags = [ "/DEFAULTLIB:libcpmt.lib" ] - } -diff --git a/build/rust/BUILD.gn b/build/rust/BUILD.gn -index d7ae149..4995459 100644 ---- a/build/rust/BUILD.gn -+++ b/build/rust/BUILD.gn -@@ -37,19 +37,7 @@ - # Depending on the C++ bindings side of cxx then requires also depending - # on the Rust bindings, since one calls the other. And the Rust bindings - # require the Rust standard library. -- # Normally the Rust stdlib is brought in as a dependency by depending -- # on any first-party Rust target. But in this case, it's conceivable -- # that pure-C++ targets will not depend on any 1p Rust code so we'll add -- # the Rust stdlib explicitly. - deps = [ ":cxx_rustdeps" ] -- -- if (use_local_std_by_default) { -- deps += [ "//build/rust/std:link_local_std" ] -- } else { -- assert(prebuilt_libstd_supported, -- "Prebuilt Rust stdlib is not available for this target") -- deps += [ "//build/rust/std:link_prebuilt_std" ] -- } - } - - # The required dependencies for cxx-generated bindings, that must be included -diff --git a/build/rust/cargo_crate.gni b/build/rust/cargo_crate.gni -index bca790f7..ca047c8a 100644 ---- a/build/rust/cargo_crate.gni -+++ b/build/rust/cargo_crate.gni -@@ -266,13 +266,12 @@ - ":${_build_script_name}($host_toolchain_no_sanitizers)" - deps = [ build_script_target ] - -- # The build script output is always in the name-specific output dir. It -- # may be built with a different toolchain when cross-compiling (the host -- # toolchain) so we must find the path relative to that. -- _build_script_target_out_dir = -- get_label_info(build_script_target, "target_out_dir") -- _build_script_exe = -- "$_build_script_target_out_dir/$_orig_target_name/$_build_script_name" -+ # The build script may be built with a different toolchain when -+ # cross-compiling (the host toolchain) so we must find the path relative -+ # to that. -+ _build_script_root_out_dir = -+ get_label_info(build_script_target, "root_out_dir") -+ _build_script_exe = "$_build_script_root_out_dir/$_build_script_name" - if (is_win) { - _build_script_exe = "${_build_script_exe}.exe" - } -@@ -328,11 +327,14 @@ - deps = invoker.build_deps - } - -- # An rlib's build script may be built differently for tests and for -- # production, so they must be in a name specific to the GN target. The -- # ${_build_script_name}_output target looks for the exe in this -- # location. -- output_dir = "$target_out_dir/$_orig_target_name" -+ # The ${_build_script_name}_output target looks for the exe in this -+ # location. Due to how the Windows component build works, this has to -+ # be $root_out_dir for all EXEs. In component build, C++ links to the -+ # CRT as a DLL, and if Rust does not match, we can't link mixed target -+ # Rust EXE/DLLs, as the headers in C++ said something different than -+ # what Rust links. Since the CRT DLL is placed in the $root_out_dir, -+ # an EXE can find it if it's also placed in that dir. -+ output_dir = root_out_dir - rustenv = _rustenv - forward_variables_from(invoker, - [ -diff --git a/build/rust/rust_target.gni b/build/rust/rust_target.gni -index b4d3e94..6f78f28 100644 ---- a/build/rust/rust_target.gni -+++ b/build/rust/rust_target.gni -@@ -104,11 +104,6 @@ - _visibility = invoker.visibility - } - -- _use_local_std = use_local_std_by_default -- if (defined(invoker.use_local_std)) { -- _use_local_std = invoker.use_local_std -- } -- - _rustflags = [] - if (defined(invoker.rustflags)) { - _rustflags += invoker.rustflags -@@ -133,6 +128,10 @@ - _configs += invoker.proc_macro_configs - _test_configs += [ "//build/rust:proc_macro_extern" ] - } -+ } else if (invoker.target_type == "rust_proc_macro") { -+ if (defined(invoker.shared_library_configs)) { -+ _configs += invoker.shared_library_configs -+ } - } else { - if (defined(invoker.library_configs)) { - _configs += invoker.library_configs -@@ -223,7 +222,6 @@ - "_rustflags", - "_support_use_from_cpp", - "_testonly", -- "_use_local_std", - "_visibility", - ]) - } else { -@@ -262,23 +260,11 @@ - # target that depends on a rust target directly may need access to Cxx - # as well, which means it must appear in public_deps. - public_deps += [ "//build/rust:cxx_cppdeps" ] -- -- # cxx_cppdeps pulls in the default libstd, so make sure the default was -- # not overridden. -- assert( -- _use_local_std == use_local_std_by_default, -- "Rust targets with cxx bindings cannot override the default libstd") - } else if (!defined(invoker.no_std) || !invoker.no_std) { - # If C++ depends on and links in the library, we need to make sure C++ - # links in the Rust stdlib. This is orthogonal to if the library exports - # bindings for C++ to use. -- if (_use_local_std) { -- deps = [ "//build/rust/std:link_local_std" ] -- } else { -- assert(prebuilt_libstd_supported, -- "Prebuilt Rust stdlib is not available for this target") -- deps = [ "//build/rust/std:link_prebuilt_std" ] -- } -+ deps = [ "//build/rust/std:stdlib_for_clang" ] - } - } - -@@ -298,13 +284,7 @@ - } - - if (!defined(invoker.no_std) || !invoker.no_std) { -- if (_use_local_std) { -- _rust_deps += [ "//build/rust/std:local_std_for_rustc" ] -- } else { -- _rust_deps += [ "//build/rust/std:prebuilt_std_for_rustc" ] -- } -- } else { -- not_needed([ "_use_local_std" ]) -+ _rust_deps += [ "//build/rust/std:stdlib_for_rustc" ] - } - - # You must go through the groups above to get to these targets. -@@ -449,5 +429,6 @@ - set_defaults("rust_target") { - executable_configs = default_executable_configs - library_configs = default_compiler_configs -+ shared_library_configs = default_shared_library_configs - proc_macro_configs = default_rust_proc_macro_configs - } -diff --git a/build/rust/std/BUILD.gn b/build/rust/std/BUILD.gn -index 90cfec7..03b8943 100644 ---- a/build/rust/std/BUILD.gn -+++ b/build/rust/std/BUILD.gn -@@ -16,8 +16,8 @@ - # * Remap some generic allocator symbols to the specific allocator symbols - # in use. - # This file takes care of equivalent tasks for our C++ toolchains. --# C++ targets should depend upon either link_local_std or --# link_prebuilt_std to ensure that Rust code can be linked into their -+# C++ targets should depend upon either local_stdlib_for_clang or -+# prebuilt_stdlib_for_clang to ensure that Rust code can be linked into their - # C++ executables. - # - # This is obviously a bit fragile - rustc might do other magic in future. -@@ -70,16 +70,6 @@ - "unwind", - ] - -- if (is_win) { -- # Our C++ builds already link against a wide variety of Windows API import libraries, -- # but the Rust stdlib requires a few extra. -- _windows_lib_deps = [ -- "bcrypt.lib", -- "ntdll.lib", -- "userenv.lib", -- ] -- } -- - # rlibs explicitly ignored when copying prebuilt sysroot libraries. - # find_std_rlibs.py rightfully errors out if an unexpected prebuilt lib is - # encountered, since it usually indicates we missed something. This ignore -@@ -89,7 +79,7 @@ - # proc_macro is special: we only run proc macros on the host, so we only want - # it for our host toolchain. - if (current_toolchain == host_toolchain_no_sanitizers) { -- # Directs the local_std_for_rustc target to depend on proc_macro, and -+ # Directs the local stdlib_for_rustc target to depend on proc_macro, and - # includes proc_macro in the prebuilts copied in find_stdlib. Otherwise it - # is not built or copied. - stdlib_files += [ "proc_macro" ] -@@ -114,7 +104,133 @@ - "rustc_std_workspace_core", - "rustc_std_workspace_std", - ] -- if (prebuilt_libstd_supported) { -+ -+ config("stdlib_dependent_libs") { -+ # TODO(crbug.com/1434092): These should really be `libs`, however that -+ # breaks. Normally, we specify lib files with the `.lib` suffix but -+ # then when rustc links an EXE, it invokes lld-link with `.lib.lib` -+ # instead. -+ # -+ # Omitting the `.lib` suffix breaks linking as well, when clang drives -+ # the linking step of a C++ EXE that depends on Rust. -+ if (is_win) { -+ # The libc crate tries to link in the Windows CRT, but we specify the CRT -+ # library ourselves in //build/config/win:dynamic_crt and -+ # //build/config/win:static_crt because Rustc does not allow us to specify -+ # using the debug CRT: https://github.com/rust-lang/rust/issues/39016 -+ # -+ # As such, we have disabled all #[link] directives from the libc crate, and -+ # we need to add any non-CRT libs here. -+ ldflags = [ "legacy_stdio_definitions.lib" ] -+ } -+ } -+ config("stdlib_public_dependent_libs") { -+ # TODO(crbug.com/1434092): These should really be `libs`, however that -+ # breaks. Normally, we specify lib files with the `.lib` suffix but -+ # then when rustc links an EXE, it invokes lld-link with `.lib.lib` -+ # instead. -+ # -+ # Omitting the `.lib` suffix breaks linking as well, when clang drives -+ # the linking step of a C++ EXE that depends on Rust. -+ if (is_win) { -+ # These libs provide functions that are used by the stdlib. Rust crates -+ # will try to link them in with #[link] directives. However these don't get -+ # propagated to the linker if Rust isn't driving the linking (a C++ target -+ # that depends on a Rust rlib). So these need to be specified explicitly. -+ ldflags = [ -+ "advapi32.lib", -+ "bcrypt.lib", -+ "kernel32.lib", -+ "ntdll.lib", -+ "userenv.lib", -+ "ws2_32.lib", -+ ] -+ } -+ } -+ -+ # Construct sysroots for rustc invocations to better control what libraries -+ # are linked. We have two: one with copied prebuilt libraries, and one with -+ # our locally-built std. Both reside in root_out_dir: we must only have one of -+ # each per GN toolchain anyway. -+ -+ sysroot_lib_subdir = "lib/rustlib/$rust_abi_target/lib" -+ -+ if (use_chromium_rust_toolchain) { -+ local_rustc_sysroot = "$root_out_dir/local_rustc_sysroot" -+ -+ # All std targets starting with core build with our sysroot. It starts empty -+ # and is incrementally built. The directory must exist at the start. -+ generated_file("empty_sysroot_for_std_build") { -+ outputs = [ "$local_rustc_sysroot/$sysroot_lib_subdir/.empty" ] -+ contents = "" -+ visibility = [ ":*" ] -+ } -+ -+ # Target to be depended on by std build targets. Creates the initially empty -+ # sysroot. -+ group("std_build_deps") { -+ deps = [ ":empty_sysroot_for_std_build" ] -+ public_configs = [ ":local_stdlib_sysroot" ] -+ visibility = [ "rules:*" ] -+ } -+ -+ profiler_builtins_crates = [ -+ "core", -+ "compiler_builtins", -+ "profiler_builtins", -+ ] -+ -+ # When using instrumentation, profiler_builtins and its deps must be built -+ # before other std crates. Other crates depend on this target so they are -+ # built in the right order. -+ group("profiler_builtins_group") { -+ deps = [] -+ foreach(libname, profiler_builtins_crates) { -+ deps += [ "rules:$libname" ] -+ } -+ visibility = [ "rules:*" ] -+ } -+ -+ config("local_stdlib_sysroot") { -+ sysroot = rebase_path(local_rustc_sysroot, root_build_dir) -+ rustflags = [ "--sysroot=$sysroot" ] -+ visibility = [ ":*" ] -+ } -+ -+ group("local_stdlib_libs") { -+ assert( -+ enable_rust, -+ "Some C++ target is including Rust code even though enable_rust=false") -+ all_dependent_configs = [ ":stdlib_dependent_libs" ] -+ deps = [] -+ foreach(libname, stdlib_files + skip_stdlib_files) { -+ deps += [ "rules:$libname" ] -+ } -+ visibility = [ ":*" ] -+ } -+ -+ # Builds the stdlib and points the rustc `--sysroot` to them. Used by -+ # targets for which linking is driven by Rust (bins and dylibs). -+ group("stdlib_for_rustc") { -+ assert( -+ enable_rust, -+ "Some C++ target is including Rust code even though enable_rust=false") -+ all_dependent_configs = [ ":local_stdlib_sysroot" ] -+ public_deps = [ ":local_stdlib_libs" ] -+ } -+ -+ # Builds and links against the Rust stdlib. Used by targets for which -+ # linking is driven by C++. -+ group("stdlib_for_clang") { -+ all_dependent_configs = [ ":stdlib_public_dependent_libs" ] -+ public_deps = [ -+ ":local_stdlib_libs", -+ ":remap_alloc", -+ ] -+ } -+ -+ not_needed([ "ignore_stdlib_files" ]) -+ } else { - action("find_stdlib") { - # Collect prebuilt Rust libraries from toolchain package and copy to a known - # location. -@@ -199,44 +315,28 @@ - foreach(lib, extra_sysroot_libs) { - outputs += [ "$target_out_dir/$lib" ] - } -+ -+ visibility = [ ":*" ] - } -- } else { -- not_needed([ "ignore_stdlib_files" ]) -- } - -- # Construct sysroots for rustc invocations to better control what libraries -- # are linked. We have two: one with copied prebuilt libraries, and one with -- # our locally-built std. Both reside in root_out_dir: we must only have one of -- # each per GN toolchain anyway. -- -- sysroot_lib_subdir = "lib/rustlib/$rust_abi_target/lib" -- -- if (prebuilt_libstd_supported) { - prebuilt_rustc_sysroot = "$root_out_dir/prebuilt_rustc_sysroot" -- copy("prebuilt_rustc_sysroot") { -+ copy("prebuilt_rustc_copy_to_sysroot") { - deps = [ ":find_stdlib" ] - sources = get_target_outputs(":find_stdlib") - outputs = - [ "$prebuilt_rustc_sysroot/$sysroot_lib_subdir/{{source_file_part}}" ] -+ -+ visibility = [ ":*" ] - } - -- config("prebuilt_stdlib_for_rustc") { -- # Match the output directory of :prebuilt_rustc_sysroot -+ config("prebuilt_stdlib_sysroot") { -+ # Match the output directory of :prebuilt_rustc_copy_to_sysroot - sysroot = rebase_path(prebuilt_rustc_sysroot, root_build_dir) - rustflags = [ "--sysroot=$sysroot" ] -+ visibility = [ ":*" ] - } - -- # Use the sysroot generated by :prebuilt_rustc_sysroot. Almost all Rust targets should depend -- # on this. -- group("prebuilt_std_for_rustc") { -- assert( -- enable_rust, -- "Some C++ target is including Rust code even though enable_rust=false") -- all_dependent_configs = [ ":prebuilt_stdlib_for_rustc" ] -- deps = [ ":prebuilt_rustc_sysroot" ] -- } -- -- config("prebuilt_rust_stdlib_config") { -+ config("prebuilt_stdlib_libs") { - ldflags = [] - lib_dir = rebase_path("$prebuilt_rustc_sysroot/$sysroot_lib_subdir", - root_build_dir) -@@ -266,80 +366,29 @@ - # the linking step of a C++ EXE that depends on Rust. - ldflags += _windows_lib_deps - } -- } -- -- # Provides std libs to non-rustc linkers. -- group("link_prebuilt_std") { -- assert( -- enable_rust, -- "Some C++ target is including Rust code even though enable_rust=false") -- all_dependent_configs = [ ":prebuilt_rust_stdlib_config" ] -- deps = [ -- ":prebuilt_rustc_sysroot", -- ":remap_alloc", -- ] -- } -- } -- -- if (local_libstd_supported) { -- local_rustc_sysroot = "$root_out_dir/local_rustc_sysroot" -- -- # All std targets starting with core build with our sysroot. It starts empty -- # and is incrementally built. The directory must exist at the start. -- generated_file("empty_sysroot_for_std_build") { -- outputs = [ "$local_rustc_sysroot/$sysroot_lib_subdir/.empty" ] -- contents = "" - } - -- config("local_stdlib_for_rustc") { -- sysroot = rebase_path(local_rustc_sysroot, root_build_dir) -- rustflags = [ "--sysroot=$sysroot" ] -- } -- -- # Target to be depended on by std build targets. Creates the initially empty -- # sysroot. -- group("std_build_deps") { -- deps = [ ":empty_sysroot_for_std_build" ] -- public_configs = [ ":local_stdlib_for_rustc" ] -- } -- -- # Use the sysroot generated by :local_rustc_sysroot, which transitively builds -- # std. Only for use in specific tests for now. -- group("local_std_for_rustc") { -+ # Use the sysroot generated by :prebuilt_rustc_copy_to_sysroot. -+ group("stdlib_for_rustc") { - assert( - enable_rust, - "Some C++ target is including Rust code even though enable_rust=false") -- all_dependent_configs = [ ":local_stdlib_for_rustc" ] -- -- deps = [] -- foreach(libname, stdlib_files + skip_stdlib_files) { -- deps += [ "rules:$libname" ] -- } -+ all_dependent_configs = [ ":prebuilt_stdlib_sysroot" ] -+ deps = [ ":prebuilt_rustc_copy_to_sysroot" ] - } - -- config("local_rust_stdlib_config") { -- if (is_win) { -- # TODO(crbug.com/1434092): This should really be `libs`, however that -- # breaks. Normally, we specify lib files with the `.lib` suffix but -- # then when rustc links an EXE, it invokes lld-link with `.lib.lib` -- # instead. -- # -- # Omitting the `.lib` suffix breaks linking as well, when clang drives -- # the linking step of a C++ EXE that depends on Rust. -- ldflags = _windows_lib_deps -- } -- } -- -- # TODO(crbug.com/1368806): rework this so when using locally-built std, we -- # don't link the prebuilt std as well. -- -- group("link_local_std") { -+ # Links the Rust stdlib. Used by targets for which linking is driven by -+ # C++. -+ group("stdlib_for_clang") { - assert( - enable_rust, - "Some C++ target is including Rust code even though enable_rust=false") -- all_dependent_configs = [ ":local_rust_stdlib_config" ] -+ all_dependent_configs = [ -+ ":prebuilt_stdlib_libs", -+ ":stdlib_public_dependent_libs", -+ ] - deps = [ -- ":local_std_for_rustc", -+ ":prebuilt_rustc_copy_to_sysroot", - ":remap_alloc", - ] - } -diff --git a/build/rust/std/gnrt_config.toml b/build/rust/std/gnrt_config.toml -index 9102ff8..76f9968b 100644 ---- a/build/rust/std/gnrt_config.toml -+++ b/build/rust/std/gnrt_config.toml -@@ -51,6 +51,11 @@ - 'libc_non_exhaustive', 'libc_long_array', 'libc_ptr_addr_of', - 'libc_underscore_const_names', 'libc_const_extern_fn' - ] -+# The libc crate tries to link in the Windows CRT, but we specify the CRT -+# library ourselves in //build/config/win:dynamic_crt and -+# //build/config/win:static_crt because Rustc does not allow us to specify -+# using the debug CRT: https://github.com/rust-lang/rust/issues/39016 -+rustflags = ['-Zlink-directives=false'] - - # This target is #[no_core] when included by std, which is incompatible with - # profiling. -diff --git a/build/rust/std/remap_alloc.cc b/build/rust/std/remap_alloc.cc -index 7f8aa1d..1a9d226 100644 ---- a/build/rust/std/remap_alloc.cc -+++ b/build/rust/std/remap_alloc.cc -@@ -65,13 +65,17 @@ - extern "C" { - - #ifdef COMPONENT_BUILD -+#if BUILDFLAG(IS_WIN) -+#define REMAP_ALLOC_ATTRIBUTES __declspec(dllexport) __attribute__((weak)) -+#else - #define REMAP_ALLOC_ATTRIBUTES \ - __attribute__((visibility("default"))) __attribute__((weak)) -+#endif - #else - #define REMAP_ALLOC_ATTRIBUTES __attribute__((weak)) - #endif // COMPONENT_BUILD - --void* REMAP_ALLOC_ATTRIBUTES __rust_alloc(size_t size, size_t align) { -+REMAP_ALLOC_ATTRIBUTES void* __rust_alloc(size_t size, size_t align) { - // This mirrors kMaxSupportedAlignment from - // base/allocator/partition_allocator/partition_alloc_constants.h. - // ParitionAlloc will crash if given an alignment larger than this. -@@ -114,11 +118,11 @@ - } - } - --void REMAP_ALLOC_ATTRIBUTES __rust_dealloc(void* p, size_t size, size_t align) { -+REMAP_ALLOC_ATTRIBUTES void __rust_dealloc(void* p, size_t size, size_t align) { - free(p); - } - --void* REMAP_ALLOC_ATTRIBUTES __rust_realloc(void* p, -+REMAP_ALLOC_ATTRIBUTES void* __rust_realloc(void* p, - size_t old_size, - size_t align, - size_t new_size) { -@@ -131,7 +135,7 @@ - } - } - --void* REMAP_ALLOC_ATTRIBUTES __rust_alloc_zeroed(size_t size, size_t align) { -+REMAP_ALLOC_ATTRIBUTES void* __rust_alloc_zeroed(size_t size, size_t align) { - if (align <= alignof(std::max_align_t)) { - return calloc(size, 1); - } else { -@@ -141,12 +145,12 @@ - } - } - --void REMAP_ALLOC_ATTRIBUTES __rust_alloc_error_handler(size_t size, -+REMAP_ALLOC_ATTRIBUTES void __rust_alloc_error_handler(size_t size, - size_t align) { - IMMEDIATE_CRASH(); - } - --extern const unsigned char REMAP_ALLOC_ATTRIBUTES -+REMAP_ALLOC_ATTRIBUTES extern const unsigned char - __rust_alloc_error_handler_should_panic = 0; - - } // extern "C" -diff --git a/build/rust/std/rules/BUILD.gn b/build/rust/std/rules/BUILD.gn -index ef8d439..379809f 100644 ---- a/build/rust/std/rules/BUILD.gn -+++ b/build/rust/std/rules/BUILD.gn -@@ -362,6 +362,7 @@ - "--cfg=libc_ptr_addr_of", - "--cfg=libc_underscore_const_names", - "--cfg=libc_const_extern_fn", -+ "-Zlink-directives=false", - "-Zforce-unstable-if-unmarked", - ] - output_dir = -diff --git a/build/rust/tests/BUILD.gn b/build/rust/tests/BUILD.gn -index 25e2b3f..22c74b6 100644 ---- a/build/rust/tests/BUILD.gn -+++ b/build/rust/tests/BUILD.gn -@@ -53,6 +53,7 @@ - deps += [ - "bindgen_test:bindgen_test_lib_unittests", - "test_aliased_deps:test_aliased_deps_unittests", -+ "test_cpp_including_rust:test_cpp_including_rust_dylib_unittests", - "test_cpp_including_rust:test_cpp_including_rust_unittests", - "test_rlib_crate:target1_test_rlib_crate_v0_2_unittests", - "test_rlib_crate:target2_test_rlib_crate_v0_2_unittests", -@@ -60,7 +61,6 @@ - "test_rust_metadata:test_rust_metadata_unittests", - "test_rust_multiple_dep_versions_exe/v1:test_lib_v1_unittests", - "test_rust_multiple_dep_versions_exe/v2:test_lib_v2_unittests", -- "test_rust_shared_library:test_rust_shared_library_unittests", - "test_rust_static_library:test_rust_static_library_unittests", - "test_rust_static_library_non_standard_arrangement:foo_tests", - "test_rust_unittests", -@@ -71,6 +71,12 @@ - # `//build/rust/run_rs_bindings_from_cc.py`. - #"test_rs_bindings_from_cc:test_rs_bindings_from_cc_unittests", - ] -+ if (!is_win || !is_component_build) { -+ # TODO(crbug.com/1442273): The shared library unittest EXE ends up -+ # requiring the DLL to run, even though it does not use the DLL. -+ deps += -+ [ "test_rust_shared_library:test_rust_shared_library_unittests" ] -+ } - if (current_toolchain == host_toolchain_no_sanitizers) { - # Build these proc macro tests only on toolchains where we'd build the - # proc macro itself. -@@ -78,16 +84,6 @@ - } - } - -- if (local_libstd_supported) { -- deps += [ -- "test_local_std", -- "test_local_std:test_local_std_exe", -- ] -- if (can_build_rust_unit_tests) { -- deps += [ "test_local_std:test_local_std_unittests" ] -- } -- } -- - if (is_win) { - deps += [ "test_control_flow_guard" ] - } -diff --git a/build/rust/tests/test_cpp_including_rust/BUILD.gn b/build/rust/tests/test_cpp_including_rust/BUILD.gn -index 2157b79..8464e9e1b 100644 ---- a/build/rust/tests/test_cpp_including_rust/BUILD.gn -+++ b/build/rust/tests/test_cpp_including_rust/BUILD.gn -@@ -11,7 +11,7 @@ - } - - test("test_cpp_including_rust_unittests") { -- sources = [ "unittests.cc" ] -+ sources = [ "static_unittests.cc" ] - deps = [ - "//base", - "//base/allocator:buildflags", -@@ -21,3 +21,15 @@ - "//testing/gtest", - ] - } -+ -+test("test_cpp_including_rust_dylib_unittests") { -+ sources = [ "shared_unittests.cc" ] -+ deps = [ -+ "//base", -+ "//base/allocator:buildflags", -+ "//base/test:run_all_unittests", -+ "//build/rust/tests/test_rust_shared_library", -+ "//testing/gmock", -+ "//testing/gtest", -+ ] -+} -diff --git a/build/rust/tests/test_cpp_including_rust/shared_unittests.cc b/build/rust/tests/test_cpp_including_rust/shared_unittests.cc -new file mode 100644 -index 0000000..b2071962 ---- /dev/null -+++ b/build/rust/tests/test_cpp_including_rust/shared_unittests.cc -@@ -0,0 +1,31 @@ -+// Copyright 2023 The Chromium Authors -+// Use of this source code is governed by a BSD-style license that can be -+// found in the LICENSE file. -+ -+#include -+ -+#include -+ -+#include "base/allocator/buildflags.h" -+#include "base/allocator/partition_allocator/address_pool_manager_bitmap.h" -+#include "base/allocator/partition_allocator/partition_address_space.h" -+#include "build/build_config.h" -+#include "build/buildflag.h" -+#include "testing/gtest/include/gtest/gtest.h" -+ -+#include "build/rust/tests/test_rust_shared_library/src/lib.rs.h" -+ -+TEST(RustSharedTest, CppCallingIntoRust_BasicFFI) { -+ EXPECT_EQ(7, add_two_ints_via_rust(3, 4)); -+} -+ -+TEST(RustSharedTest, RustComponentUsesPartitionAlloc) { -+ // Verify that PartitionAlloc is consistently used in C++ and Rust. -+ auto cpp_allocated_int = std::make_unique(); -+ SomeStruct* rust_allocated_ptr = allocate_via_rust().into_raw(); -+ EXPECT_EQ(partition_alloc::IsManagedByPartitionAlloc( -+ reinterpret_cast(rust_allocated_ptr)), -+ partition_alloc::IsManagedByPartitionAlloc( -+ reinterpret_cast(cpp_allocated_int.get()))); -+ rust::Box::from_raw(rust_allocated_ptr); -+} -diff --git a/build/rust/tests/test_cpp_including_rust/static_unittests.cc b/build/rust/tests/test_cpp_including_rust/static_unittests.cc -new file mode 100644 -index 0000000..77efd8d ---- /dev/null -+++ b/build/rust/tests/test_cpp_including_rust/static_unittests.cc -@@ -0,0 +1,31 @@ -+// Copyright 2023 The Chromium Authors -+// Use of this source code is governed by a BSD-style license that can be -+// found in the LICENSE file. -+ -+#include -+ -+#include -+ -+#include "base/allocator/buildflags.h" -+#include "base/allocator/partition_allocator/address_pool_manager_bitmap.h" -+#include "base/allocator/partition_allocator/partition_address_space.h" -+#include "build/build_config.h" -+#include "build/buildflag.h" -+#include "testing/gtest/include/gtest/gtest.h" -+ -+#include "build/rust/tests/test_rust_static_library/src/lib.rs.h" -+ -+TEST(RustStaticTest, CppCallingIntoRust_BasicFFI) { -+ EXPECT_EQ(7, add_two_ints_via_rust(3, 4)); -+} -+ -+TEST(RustStaticTest, RustComponentUsesPartitionAlloc) { -+ // Verify that PartitionAlloc is consistently used in C++ and Rust. -+ auto cpp_allocated_int = std::make_unique(); -+ SomeStruct* rust_allocated_ptr = allocate_via_rust().into_raw(); -+ EXPECT_EQ(partition_alloc::IsManagedByPartitionAlloc( -+ reinterpret_cast(rust_allocated_ptr)), -+ partition_alloc::IsManagedByPartitionAlloc( -+ reinterpret_cast(cpp_allocated_int.get()))); -+ rust::Box::from_raw(rust_allocated_ptr); -+} -diff --git a/build/rust/tests/test_cpp_including_rust/unittests.cc b/build/rust/tests/test_cpp_including_rust/unittests.cc -deleted file mode 100644 -index f3b65ad..0000000 ---- a/build/rust/tests/test_cpp_including_rust/unittests.cc -+++ /dev/null -@@ -1,31 +0,0 @@ --// Copyright 2021 The Chromium Authors --// Use of this source code is governed by a BSD-style license that can be --// found in the LICENSE file. -- --#include -- --#include -- --#include "base/allocator/buildflags.h" --#include "base/allocator/partition_allocator/address_pool_manager_bitmap.h" --#include "base/allocator/partition_allocator/partition_address_space.h" --#include "build/build_config.h" --#include "build/buildflag.h" --#include "testing/gtest/include/gtest/gtest.h" -- --#include "build/rust/tests/test_rust_static_library/src/lib.rs.h" -- --TEST(RustTest, CppCallingIntoRust_BasicFFI) { -- EXPECT_EQ(7, add_two_ints_via_rust(3, 4)); --} -- --TEST(RustTest, RustComponentUsesPartitionAlloc) { -- // Verify that PartitionAlloc is consistently used in C++ and Rust. -- auto cpp_allocated_int = std::make_unique(); -- SomeStruct* rust_allocated_ptr = allocate_via_rust().into_raw(); -- EXPECT_EQ(partition_alloc::IsManagedByPartitionAlloc( -- reinterpret_cast(rust_allocated_ptr)), -- partition_alloc::IsManagedByPartitionAlloc( -- reinterpret_cast(cpp_allocated_int.get()))); -- rust::Box::from_raw(rust_allocated_ptr); --} -diff --git a/build/rust/tests/test_local_std/BUILD.gn b/build/rust/tests/test_local_std/BUILD.gn -deleted file mode 100644 -index 499aebd..0000000 ---- a/build/rust/tests/test_local_std/BUILD.gn -+++ /dev/null -@@ -1,23 +0,0 @@ --# Copyright 2023 The Chromium Authors --# Use of this source code is governed by a BSD-style license that can be --# found in the LICENSE file. -- --import("//build/config/rust.gni") --import("//build/rust/rust_executable.gni") --import("//build/rust/rust_static_library.gni") -- --assert(local_libstd_supported) -- --rust_static_library("test_local_std") { -- sources = [ "lib.rs" ] -- crate_root = "lib.rs" -- build_native_rust_unit_tests = true -- use_local_std = true --} -- --rust_executable("test_local_std_exe") { -- sources = [ "main.rs" ] -- crate_root = "main.rs" -- deps = [ ":test_local_std" ] -- use_local_std = true --} -diff --git a/build/rust/tests/test_local_std/lib.rs b/build/rust/tests/test_local_std/lib.rs -deleted file mode 100644 -index 6328cf41..0000000 ---- a/build/rust/tests/test_local_std/lib.rs -+++ /dev/null -@@ -1,8 +0,0 @@ --// Copyright 2023 The Chromium Authors --// Use of this source code is governed by a BSD-style license that can be --// found in the LICENSE file. -- --#[test] --fn test_test() { -- assert_eq!(1, 1); --} -diff --git a/build/rust/tests/test_local_std/main.rs b/build/rust/tests/test_local_std/main.rs -deleted file mode 100644 -index 746e021..0000000 ---- a/build/rust/tests/test_local_std/main.rs -+++ /dev/null -@@ -1,7 +0,0 @@ --// Copyright 2023 The Chromium Authors --// Use of this source code is governed by a BSD-style license that can be --// found in the LICENSE file. -- --fn main() { -- println!("hello world"); --} -diff --git a/build/rust/tests/test_rust_shared_library/src/lib.rs b/build/rust/tests/test_rust_shared_library/src/lib.rs -index eabfa27..2fa77c3 100644 ---- a/build/rust/tests/test_rust_shared_library/src/lib.rs -+++ b/build/rust/tests/test_rust_shared_library/src/lib.rs -@@ -34,8 +34,8 @@ - x + y - } - --// The next function is used from the --// AllocatorTest.RustComponentUsesPartitionAlloc unit test. -+// The next function is used from the RustComponentUsesPartitionAlloc unit -+// tests. - pub fn allocate_via_rust() -> Box { - Box::new(ffi::SomeStruct { a: 43 }) - } -diff --git a/build/rust/tests/test_simple_rust_exe/BUILD.gn b/build/rust/tests/test_simple_rust_exe/BUILD.gn -index a800720..9e94819f 100644 ---- a/build/rust/tests/test_simple_rust_exe/BUILD.gn -+++ b/build/rust/tests/test_simple_rust_exe/BUILD.gn -@@ -8,5 +8,5 @@ - # //build/rust/rust_executable.gni. - executable("test_simple_rust_exe") { - crate_root = "main.rs" -- deps = [ "//build/rust/std:local_std_for_rustc" ] -+ deps = [ "//build/rust/std:stdlib_for_rustc" ] - } diff --git a/brave/0001-upgpkg-brave-1.57.49.patch b/brave/0001-upgpkg-brave-1.57.49.patch new file mode 100644 index 000000000..fba723d7b --- /dev/null +++ b/brave/0001-upgpkg-brave-1.57.49.patch @@ -0,0 +1,1778 @@ +From ed6e7caa51ac38937833b3ca8e3ce13d169f4802 Mon Sep 17 00:00:00 2001 +From: Martin Rodriguez Reboredo +Date: Fri, 21 Jul 2023 16:38:48 -0300 +Subject: [PATCH] upgpkg: brave 1.57.49 + +upstream release + +Signed-off-by: Martin Rodriguez Reboredo +--- + .SRCINFO | 33 +- + ...n-component-and-debug-Windows-builds.patch | 1045 ----------------- + ...uilt-toolchain-from-the-Android-team.patch | 383 ------ + PKGBUILD | 84 +- + system-rust-utils.patch | 46 - + 5 files changed, 48 insertions(+), 1543 deletions(-) + delete mode 100644 0001-Fix-Rust-linking-on-component-and-debug-Windows-builds.patch + delete mode 100644 0002-Remove-the-prebuilt-toolchain-from-the-Android-team.patch + delete mode 100644 system-rust-utils.patch + +diff --git a/.SRCINFO b/.SRCINFO +index 95e1613..a94e86c 100644 +--- a/.SRCINFO ++++ b/.SRCINFO +@@ -1,6 +1,6 @@ + pkgbase = brave + pkgdesc = Web browser that blocks ads and trackers by default +- pkgver = 1.52.129 ++ pkgver = 1.57.49 + pkgrel = 1 + url = https://www.brave.com/download + arch = x86_64 +@@ -42,7 +42,6 @@ pkgbase = brave + depends = hicolor-icon-theme + depends = fontconfig + depends = woff2 +- depends = brotli + depends = libjpeg + depends = icu + depends = dav1d +@@ -65,16 +64,14 @@ pkgbase = brave + optdepends = org.freedesktop.secrets: password storage backend on GNOME / Xfce + optdepends = kwallet: support for storing passwords in KWallet on Plasma + options = !lto +- source = brave-browser::git+https://github.com/brave/brave-browser.git#tag=v1.52.129 +- source = brave::git+https://github.com/brave/brave-core.git#tag=v1.52.129 +- source = chromium-mirror::git+https://github.com/chromium/chromium.git#tag=114.0.5735.198 ++ source = brave-browser::git+https://github.com/brave/brave-browser.git#tag=v1.57.49 ++ source = brave::git+https://github.com/brave/brave-core.git#tag=v1.57.49 ++ source = chromium-mirror::git+https://github.com/chromium/chromium.git#tag=116.0.5845.96 + source = depot_tools::git+https://chromium.googlesource.com/chromium/tools/depot_tools.git ++ source = https://github.com/stha09/chromium-patches/releases/download/chromium-116-patchset-2/chromium-116-patchset-2.tar.xz + source = https://github.com/foutrelis/chromium-launcher/archive/refs/tags/v8/chromium-launcher-8.tar.gz + source = chromium-launcher-electron-app.patch + source = chromium-launcher-vendor.patch +- source = system-rust-utils.patch +- source = 0001-Fix-Rust-linking-on-component-and-debug-Windows-builds.patch +- source = 0002-Remove-the-prebuilt-toolchain-from-the-Android-team.patch + source = brave-1.19-BUILD.gn.patch + source = brave-1.43-bitcoin-core_remove-serialize.h.patch + source = brave-1.43-debounce-debounce_navigation_throttle_fix.patch +@@ -84,23 +81,17 @@ pkgbase = brave + source = brave-1.52-bitints-libstdcxx-bypass.patch + source = brave-1.52-missing-includes.patch + source = brave-1.52-playlist-user-agent-only-constructor.patch +- source = https://gitlab.archlinux.org/archlinux/packaging/packages/chromium/-/raw/fa08adba87b6222bdf9ba31aaa41579e634ec444/add-some-typename-s-that-are-required-in-C-17.patch +- source = https://gitlab.archlinux.org/archlinux/packaging/packages/chromium/-/raw/fa08adba87b6222bdf9ba31aaa41579e634ec444/REVERT-disable-autoupgrading-debug-info.patch +- source = https://gitlab.archlinux.org/archlinux/packaging/packages/chromium/-/raw/fa08adba87b6222bdf9ba31aaa41579e634ec444/download-bubble-typename.patch +- source = https://gitlab.archlinux.org/archlinux/packaging/packages/chromium/-/raw/fa08adba87b6222bdf9ba31aaa41579e634ec444/webauthn-variant.patch +- source = https://gitlab.archlinux.org/archlinux/packaging/packages/chromium/-/raw/fa08adba87b6222bdf9ba31aaa41579e634ec444/random-fixes-for-gcc13.patch +- source = https://gitlab.archlinux.org/archlinux/packaging/packages/chromium/-/raw/fa08adba87b6222bdf9ba31aaa41579e634ec444/disable-GlobalMediaControlsCastStartStop.patch +- source = https://gitlab.archlinux.org/archlinux/packaging/packages/chromium/-/raw/fa08adba87b6222bdf9ba31aaa41579e634ec444/use-oauth2-client-switches-as-default.patch ++ source = https://gitlab.archlinux.org/archlinux/packaging/packages/chromium/-/raw/116.0.5845.96-1/REVERT-disable-autoupgrading-debug-info.patch ++ source = https://gitlab.archlinux.org/archlinux/packaging/packages/chromium/-/raw/116.0.5845.96-1/random-build-fixes.patch ++ source = https://gitlab.archlinux.org/archlinux/packaging/packages/chromium/-/raw/116.0.5845.96-1/use-oauth2-client-switches-as-default.patch + sha256sums = SKIP + sha256sums = SKIP + sha256sums = SKIP + sha256sums = SKIP ++ sha256sums = 25ad7c1a5e0b7332f80ed15ccf07d7e871d8ffb4af64df7c8fef325a527859b0 + sha256sums = 213e50f48b67feb4441078d50b0fd431df34323be15be97c55302d3fdac4483a + sha256sums = 9235485adc4acbfaf303605f4428a6995a7b0b3b5a95181b185afbcb9f1f6ae5 + sha256sums = 404bf09df39310a1e374c5e7eb9c7311239798adf4e8cd85b7ff04fc79647f88 +- sha256sums = dcaf12a8b2ba15cefafd6e3c053b2ec490b1b8e1c89a3309e41133c0cd183ed3 +- sha256sums = dfb5ca39abe7dd449729d3af3724fe27208d8cda76ecc4916cc57a4ad9c8e1b1 +- sha256sums = 01a809e8bf7eeed6e263bc7118d6e40395dca7ac8463dbe230303e13d17d673e + sha256sums = 12a3d37ffca4c0fa25f89f02efdf79d24f6412ee29ec35e8a00f9086dba4e822 + sha256sums = 984bb0257ed6fe4af543c3fb803ed81bddc97ff367ccd93620404be60cb78eb3 + sha256sums = 30a6a9ca2a6dd965cb2d9f02639079130948bf45d483f0c629f2cf8394a1c22f +@@ -110,12 +101,8 @@ pkgbase = brave + sha256sums = f781d6315e4147b775350d7a36481c3ce43b582eee5ee228768e42c30d9dd9ca + sha256sums = 1654fa922d10a591d5c28159a6d22d1183bcbd3448f175d7f3e2e11879588ddd + sha256sums = 7cf8569ff905666889842c36e82d51c08d482745cd2f71e48fa1296824f09839 +- sha256sums = 621ed210d75d0e846192c1571bb30db988721224a41572c27769c0288d361c11 + sha256sums = 1b782b0f6d4f645e4e0daa8a4852d63f0c972aa0473319216ff04613a0592a69 +- sha256sums = d464eed4be4e9bf6187b4c40a759c523b7befefa25ba34ad6401b2a07649ca2a +- sha256sums = 590fabbb26270947cb477378b53a9dcd17855739076b4af9983e1e54dfcab6d7 +- sha256sums = ba4dd0a25a4fc3267ed19ccb39f28b28176ca3f97f53a4e9f5e9215280040ea0 +- sha256sums = 7f3b1b22d6a271431c1f9fc92b6eb49c6d80b8b3f868bdee07a6a1a16630a302 ++ sha256sums = e938c6ee7087eed8f0de83ffb0ca89e328575808fafa4fe3950aeb1bc58b9411 + sha256sums = e393174d7695d0bafed69e868c5fbfecf07aa6969f3b64596d0bae8b067e1711 + + pkgname = brave +diff --git a/0001-Fix-Rust-linking-on-component-and-debug-Windows-builds.patch b/0001-Fix-Rust-linking-on-component-and-debug-Windows-builds.patch +deleted file mode 100644 +index 8bcc450..0000000 +--- a/0001-Fix-Rust-linking-on-component-and-debug-Windows-builds.patch ++++ /dev/null +@@ -1,1045 +0,0 @@ +-From e917deabc983569acfd001b06fa71ea3471d8ff3 Mon Sep 17 00:00:00 2001 +-From: danakj +-Date: Thu, 04 May 2023 16:03:06 +0000 +-Subject: [PATCH] Fix Rust linking on component and debug Windows builds +- +-1. The CRT can be specified from rustc but only static/dynamic, +-not release/debug. This is tracked upstream in +-https://github.com/rust-lang/libs-team/issues/211 +- +-Because of this, we must not use the CRT command line options +-from rustc, and instead specify the library directly. This is +-done at the same location where the CRT is chosen for C++ +-targets via the "/MD" and friends flags. +- +-Then, we must not have rustc try to also link the CRT and we +-disable that by setting -Zlink-directives=false for the libc +-crate. +- +-2. After the above, we have two sets of libraries that must be +-linked when using the rust stdlib. +- +-Internal dependencies, which are #[link] directives from the +-libc crate (other than the CRT), which must be linked any time +-the rust lib is used. +- +-Public dependencies, which are linked automatically by rustc +-but are not linked by C++ targets that depend on Rust targets. +- +-So we split these into two configs, and expose the latter on +-the BUILD rule for C++ targets that depend on Rust. +- +-3. The local build of stdlib is here to stay and is always used +-with the Chromium toolchain, so remove a bunch of configuration +-levers around it and just hardcode the stdlib in when using the +-Chromium toolchain. And hardcode the prebuilt stdlib path when +-not using the Chromium toolchain. This removes a bunch of +-branches elsewhere in our GN rules as we can simply depend on +-the "rust stdlib target" instead of choosing between them. +- +-Then drop the test build target that was opting into the local +-stdlib as all our Rust build tests do that now. +- +-4. Don't use __attribute__((visibility("default"))) on Windows, +-use __declspec(dllexport) instead. +- +-I don't know that this fixes anything, but that attribute doesn't +-exist on Windows, so yeah. +- +-5. In the component build, C++ targets are linked with the dynamic +-CRT. In order to have mixed targets, Rust needs to as well. Then +-Rust build script exes are linked with the dynamic CRT and they are +-unable to find the DLL on the bots (which don't have Visual Studio) +-installed. The CRT DLL is placed in root_out_dir, so we move build +-script exes to the root_out_dir in order to have them find the DLL +-and be able to execute. +- +-6. Ensure the CRT DLLs are present on the bots when running the +-tests by adding a data_deps edge to them for build_rust_tests. +-Normally this edge comes from a dependency on //base which basically +-everything has, but our Rust build tests don't. +- +-7. Disable rust_shared_library unit test on Windows component build +-while we figure out how to get the right `data_deps` edge from the +-test to the library so that it's included in the isolate. When +-building a library's tests, the library itself is recompiled under +-cfg=test as part of the test exe. So the rlib or shared library +-itself is not used. But we still need to depend on any transitive +-deps of that library when building the unit tests, so the unit tests +-add a deps edge onto the library. +- +-For shared libraries this deps edge doesn't do anything on Linux, or +-on Windows non-component builds. But on Windows component builds, the +-unit test EXE acquires a dependency on the DLL (as shown by dumpbin) +-and thus the DLL needs to be present when running the test. +- +-Bug: 1442273, 1434719 +- +-Change-Id: I157a0728ec25f636d0b78973b8ab81205e7b25ef +-Cq-Include-Trybots: luci.chromium.try:win-rust-x64-rel,win-rust-x64-dbg,linux-rust-x64-rel,linux-rust-x64-dbg,android-rust-arm64-rel,android-rust-arm64-dbg,android-rust-arm32-rel +-Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/4499979 +-Reviewed-by: Bruce Dawson +-Commit-Queue: danakj +-Reviewed-by: Adrian Taylor +-Cr-Commit-Position: refs/heads/main@{#1139572} +---- +- +-diff --git a/build/config/BUILD.gn b/build/config/BUILD.gn +-index 210ba0d..596bd9d 100644 +---- a/build/config/BUILD.gn +-+++ b/build/config/BUILD.gn +-@@ -335,7 +335,6 @@ +- +- if (is_win) { +- configs += _windows_linker_configs +-- configs += [ "//build/config/win:exe_flags" ] +- } else if (is_mac) { +- configs += [ "//build/config/mac:mac_dynamic_flags" ] +- } else if (is_ios) { +-diff --git a/build/config/rust.gni b/build/config/rust.gni +-index 75d236fd..c0d934c 100644 +---- a/build/config/rust.gni +-+++ b/build/config/rust.gni +-@@ -38,12 +38,6 @@ +- # Use the Rust toolchain built in-tree. See //tools/rust. +- use_chromium_rust_toolchain = true +- +-- # Build libstd locally with GN and use that instead of the prebuilts, where +-- # applicable. If this is false the prebuilt libstd will always be used. If +-- # true, the local build is only used with the Chromium Rust toolchain and only +-- # on supported platforms and GN targets. +-- enable_local_libstd = true +-- +- # Chromium currently has a Rust toolchain for Android and Linux, but +- # if you wish to experiment on more platforms you can use this +- # argument to specify an alternative toolchain. +-@@ -87,13 +81,6 @@ +- # Use a separate declare_args so these variables' defaults can depend on the +- # ones above. +- +-- # When true, uses the locally-built std in all Rust targets. +-- # +-- # As an internal implementation detail this can be overridden on specific +-- # targets (e.g. to run build.rs scripts while building std), but this +-- # generally should not be done. +-- use_local_std_by_default = enable_local_libstd && use_chromium_rust_toolchain +-- +- # Individual Rust components. +- +- # Conversions between Rust types and C++ types. +-@@ -286,13 +273,6 @@ +- use_unverified_rust_toolchain, +- "Must use Chromium Rust toolchain for LTO") +- +--# Determine whether the local libstd can and should be built. +--local_libstd_supported = enable_local_libstd && use_chromium_rust_toolchain +-- +--# Determine whether the prebuilt libstd can be used +--prebuilt_libstd_supported = !use_chromium_rust_toolchain || +-- (target_os == "linux" && target_cpu == "x64") +-- +- # Arguments for Rust invocation. +- # This is common between gcc/clang, Mac and Windows toolchains so specify once, +- # here. This is not the complete command-line: toolchains should add -o +-diff --git a/build/config/win/BUILD.gn b/build/config/win/BUILD.gn +-index 8a3bfbbb..ff7d345 100644 +---- a/build/config/win/BUILD.gn +-+++ b/build/config/win/BUILD.gn +-@@ -329,11 +329,6 @@ +- } +- } +- +--# Flags that should be applied to building .exe files but not .dll files. +--config("exe_flags") { +-- rustflags = [ "-Ctarget-feature=+crt-static" ] +--} +-- +- config("default_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 +-@@ -506,11 +501,25 @@ +- if (is_debug) { +- # This pulls in the DLL debug CRT and defines _DEBUG +- cflags = [ "/MDd" ] +-+ +-+ # /MDd specifies msvcrtd.lib as the CRT library. Rust needs to agree, so +-+ # we specify it explicitly. +-+ # Once https://github.com/rust-lang/rust/issues/39016 is resolved we should +-+ # instead tell rustc which CRT to use (static/dynamic + release/debug). +-+ rustflags = [ "-Clink-arg=msvcrtd.lib" ] +-+ +- if (use_custom_libcxx) { +- ldflags = [ "/DEFAULTLIB:msvcprtd.lib" ] +- } +- } else { +- cflags = [ "/MD" ] +-+ +-+ # /MD specifies msvcrt.lib as the CRT library. Rust needs to agree, so +-+ # we specify it explicitly. +-+ # Once https://github.com/rust-lang/rust/issues/39016 is resolved we should +-+ # instead tell rustc which CRT to use (static/dynamic + release/debug). +-+ rustflags = [ "-Clink-arg=msvcrt.lib" ] +-+ +- if (use_custom_libcxx) { +- ldflags = [ "/DEFAULTLIB:msvcprt.lib" ] +- } +-@@ -521,11 +530,25 @@ +- if (is_debug) { +- # This pulls in the static debug CRT and defines _DEBUG +- cflags = [ "/MTd" ] +-+ +-+ # /MTd specifies libcmtd.lib as the CRT library. Rust needs to agree, so +-+ # we specify it explicitly. +-+ # Once https://github.com/rust-lang/rust/issues/39016 is resolved we should +-+ # instead tell rustc which CRT to use (static/dynamic + release/debug). +-+ rustflags = [ "-Clink-arg=libcmtd.lib" ] +-+ +- if (use_custom_libcxx) { +- ldflags = [ "/DEFAULTLIB:libcpmtd.lib" ] +- } +- } else { +- cflags = [ "/MT" ] +-+ +-+ # /MT specifies libcmt.lib as the CRT library. Rust needs to agree, so +-+ # we specify it explicitly. +-+ # Once https://github.com/rust-lang/rust/issues/39016 is resolved we should +-+ # instead tell rustc which CRT to use (static/dynamic + release/debug). +-+ rustflags = [ "-Clink-arg=libcmt.lib" ] +-+ +- if (use_custom_libcxx) { +- ldflags = [ "/DEFAULTLIB:libcpmt.lib" ] +- } +-diff --git a/build/rust/BUILD.gn b/build/rust/BUILD.gn +-index d7ae149..4995459 100644 +---- a/build/rust/BUILD.gn +-+++ b/build/rust/BUILD.gn +-@@ -37,19 +37,7 @@ +- # Depending on the C++ bindings side of cxx then requires also depending +- # on the Rust bindings, since one calls the other. And the Rust bindings +- # require the Rust standard library. +-- # Normally the Rust stdlib is brought in as a dependency by depending +-- # on any first-party Rust target. But in this case, it's conceivable +-- # that pure-C++ targets will not depend on any 1p Rust code so we'll add +-- # the Rust stdlib explicitly. +- deps = [ ":cxx_rustdeps" ] +-- +-- if (use_local_std_by_default) { +-- deps += [ "//build/rust/std:link_local_std" ] +-- } else { +-- assert(prebuilt_libstd_supported, +-- "Prebuilt Rust stdlib is not available for this target") +-- deps += [ "//build/rust/std:link_prebuilt_std" ] +-- } +- } +- +- # The required dependencies for cxx-generated bindings, that must be included +-diff --git a/build/rust/cargo_crate.gni b/build/rust/cargo_crate.gni +-index bca790f7..ca047c8a 100644 +---- a/build/rust/cargo_crate.gni +-+++ b/build/rust/cargo_crate.gni +-@@ -266,13 +266,12 @@ +- ":${_build_script_name}($host_toolchain_no_sanitizers)" +- deps = [ build_script_target ] +- +-- # The build script output is always in the name-specific output dir. It +-- # may be built with a different toolchain when cross-compiling (the host +-- # toolchain) so we must find the path relative to that. +-- _build_script_target_out_dir = +-- get_label_info(build_script_target, "target_out_dir") +-- _build_script_exe = +-- "$_build_script_target_out_dir/$_orig_target_name/$_build_script_name" +-+ # The build script may be built with a different toolchain when +-+ # cross-compiling (the host toolchain) so we must find the path relative +-+ # to that. +-+ _build_script_root_out_dir = +-+ get_label_info(build_script_target, "root_out_dir") +-+ _build_script_exe = "$_build_script_root_out_dir/$_build_script_name" +- if (is_win) { +- _build_script_exe = "${_build_script_exe}.exe" +- } +-@@ -328,11 +327,14 @@ +- deps = invoker.build_deps +- } +- +-- # An rlib's build script may be built differently for tests and for +-- # production, so they must be in a name specific to the GN target. The +-- # ${_build_script_name}_output target looks for the exe in this +-- # location. +-- output_dir = "$target_out_dir/$_orig_target_name" +-+ # The ${_build_script_name}_output target looks for the exe in this +-+ # location. Due to how the Windows component build works, this has to +-+ # be $root_out_dir for all EXEs. In component build, C++ links to the +-+ # CRT as a DLL, and if Rust does not match, we can't link mixed target +-+ # Rust EXE/DLLs, as the headers in C++ said something different than +-+ # what Rust links. Since the CRT DLL is placed in the $root_out_dir, +-+ # an EXE can find it if it's also placed in that dir. +-+ output_dir = root_out_dir +- rustenv = _rustenv +- forward_variables_from(invoker, +- [ +-diff --git a/build/rust/rust_target.gni b/build/rust/rust_target.gni +-index b4d3e94..6f78f28 100644 +---- a/build/rust/rust_target.gni +-+++ b/build/rust/rust_target.gni +-@@ -104,11 +104,6 @@ +- _visibility = invoker.visibility +- } +- +-- _use_local_std = use_local_std_by_default +-- if (defined(invoker.use_local_std)) { +-- _use_local_std = invoker.use_local_std +-- } +-- +- _rustflags = [] +- if (defined(invoker.rustflags)) { +- _rustflags += invoker.rustflags +-@@ -133,6 +128,10 @@ +- _configs += invoker.proc_macro_configs +- _test_configs += [ "//build/rust:proc_macro_extern" ] +- } +-+ } else if (invoker.target_type == "rust_proc_macro") { +-+ if (defined(invoker.shared_library_configs)) { +-+ _configs += invoker.shared_library_configs +-+ } +- } else { +- if (defined(invoker.library_configs)) { +- _configs += invoker.library_configs +-@@ -223,7 +222,6 @@ +- "_rustflags", +- "_support_use_from_cpp", +- "_testonly", +-- "_use_local_std", +- "_visibility", +- ]) +- } else { +-@@ -262,23 +260,11 @@ +- # target that depends on a rust target directly may need access to Cxx +- # as well, which means it must appear in public_deps. +- public_deps += [ "//build/rust:cxx_cppdeps" ] +-- +-- # cxx_cppdeps pulls in the default libstd, so make sure the default was +-- # not overridden. +-- assert( +-- _use_local_std == use_local_std_by_default, +-- "Rust targets with cxx bindings cannot override the default libstd") +- } else if (!defined(invoker.no_std) || !invoker.no_std) { +- # If C++ depends on and links in the library, we need to make sure C++ +- # links in the Rust stdlib. This is orthogonal to if the library exports +- # bindings for C++ to use. +-- if (_use_local_std) { +-- deps = [ "//build/rust/std:link_local_std" ] +-- } else { +-- assert(prebuilt_libstd_supported, +-- "Prebuilt Rust stdlib is not available for this target") +-- deps = [ "//build/rust/std:link_prebuilt_std" ] +-- } +-+ deps = [ "//build/rust/std:stdlib_for_clang" ] +- } +- } +- +-@@ -298,13 +284,7 @@ +- } +- +- if (!defined(invoker.no_std) || !invoker.no_std) { +-- if (_use_local_std) { +-- _rust_deps += [ "//build/rust/std:local_std_for_rustc" ] +-- } else { +-- _rust_deps += [ "//build/rust/std:prebuilt_std_for_rustc" ] +-- } +-- } else { +-- not_needed([ "_use_local_std" ]) +-+ _rust_deps += [ "//build/rust/std:stdlib_for_rustc" ] +- } +- +- # You must go through the groups above to get to these targets. +-@@ -449,5 +429,6 @@ +- set_defaults("rust_target") { +- executable_configs = default_executable_configs +- library_configs = default_compiler_configs +-+ shared_library_configs = default_shared_library_configs +- proc_macro_configs = default_rust_proc_macro_configs +- } +-diff --git a/build/rust/std/BUILD.gn b/build/rust/std/BUILD.gn +-index 90cfec7..03b8943 100644 +---- a/build/rust/std/BUILD.gn +-+++ b/build/rust/std/BUILD.gn +-@@ -16,8 +16,8 @@ +- # * Remap some generic allocator symbols to the specific allocator symbols +- # in use. +- # This file takes care of equivalent tasks for our C++ toolchains. +--# C++ targets should depend upon either link_local_std or +--# link_prebuilt_std to ensure that Rust code can be linked into their +-+# C++ targets should depend upon either local_stdlib_for_clang or +-+# prebuilt_stdlib_for_clang to ensure that Rust code can be linked into their +- # C++ executables. +- # +- # This is obviously a bit fragile - rustc might do other magic in future. +-@@ -70,16 +70,6 @@ +- "unwind", +- ] +- +-- if (is_win) { +-- # Our C++ builds already link against a wide variety of Windows API import libraries, +-- # but the Rust stdlib requires a few extra. +-- _windows_lib_deps = [ +-- "bcrypt.lib", +-- "ntdll.lib", +-- "userenv.lib", +-- ] +-- } +-- +- # rlibs explicitly ignored when copying prebuilt sysroot libraries. +- # find_std_rlibs.py rightfully errors out if an unexpected prebuilt lib is +- # encountered, since it usually indicates we missed something. This ignore +-@@ -89,7 +79,7 @@ +- # proc_macro is special: we only run proc macros on the host, so we only want +- # it for our host toolchain. +- if (current_toolchain == host_toolchain_no_sanitizers) { +-- # Directs the local_std_for_rustc target to depend on proc_macro, and +-+ # Directs the local stdlib_for_rustc target to depend on proc_macro, and +- # includes proc_macro in the prebuilts copied in find_stdlib. Otherwise it +- # is not built or copied. +- stdlib_files += [ "proc_macro" ] +-@@ -114,7 +104,133 @@ +- "rustc_std_workspace_core", +- "rustc_std_workspace_std", +- ] +-- if (prebuilt_libstd_supported) { +-+ +-+ config("stdlib_dependent_libs") { +-+ # TODO(crbug.com/1434092): These should really be `libs`, however that +-+ # breaks. Normally, we specify lib files with the `.lib` suffix but +-+ # then when rustc links an EXE, it invokes lld-link with `.lib.lib` +-+ # instead. +-+ # +-+ # Omitting the `.lib` suffix breaks linking as well, when clang drives +-+ # the linking step of a C++ EXE that depends on Rust. +-+ if (is_win) { +-+ # The libc crate tries to link in the Windows CRT, but we specify the CRT +-+ # library ourselves in //build/config/win:dynamic_crt and +-+ # //build/config/win:static_crt because Rustc does not allow us to specify +-+ # using the debug CRT: https://github.com/rust-lang/rust/issues/39016 +-+ # +-+ # As such, we have disabled all #[link] directives from the libc crate, and +-+ # we need to add any non-CRT libs here. +-+ ldflags = [ "legacy_stdio_definitions.lib" ] +-+ } +-+ } +-+ config("stdlib_public_dependent_libs") { +-+ # TODO(crbug.com/1434092): These should really be `libs`, however that +-+ # breaks. Normally, we specify lib files with the `.lib` suffix but +-+ # then when rustc links an EXE, it invokes lld-link with `.lib.lib` +-+ # instead. +-+ # +-+ # Omitting the `.lib` suffix breaks linking as well, when clang drives +-+ # the linking step of a C++ EXE that depends on Rust. +-+ if (is_win) { +-+ # These libs provide functions that are used by the stdlib. Rust crates +-+ # will try to link them in with #[link] directives. However these don't get +-+ # propagated to the linker if Rust isn't driving the linking (a C++ target +-+ # that depends on a Rust rlib). So these need to be specified explicitly. +-+ ldflags = [ +-+ "advapi32.lib", +-+ "bcrypt.lib", +-+ "kernel32.lib", +-+ "ntdll.lib", +-+ "userenv.lib", +-+ "ws2_32.lib", +-+ ] +-+ } +-+ } +-+ +-+ # Construct sysroots for rustc invocations to better control what libraries +-+ # are linked. We have two: one with copied prebuilt libraries, and one with +-+ # our locally-built std. Both reside in root_out_dir: we must only have one of +-+ # each per GN toolchain anyway. +-+ +-+ sysroot_lib_subdir = "lib/rustlib/$rust_abi_target/lib" +-+ +-+ if (use_chromium_rust_toolchain) { +-+ local_rustc_sysroot = "$root_out_dir/local_rustc_sysroot" +-+ +-+ # All std targets starting with core build with our sysroot. It starts empty +-+ # and is incrementally built. The directory must exist at the start. +-+ generated_file("empty_sysroot_for_std_build") { +-+ outputs = [ "$local_rustc_sysroot/$sysroot_lib_subdir/.empty" ] +-+ contents = "" +-+ visibility = [ ":*" ] +-+ } +-+ +-+ # Target to be depended on by std build targets. Creates the initially empty +-+ # sysroot. +-+ group("std_build_deps") { +-+ deps = [ ":empty_sysroot_for_std_build" ] +-+ public_configs = [ ":local_stdlib_sysroot" ] +-+ visibility = [ "rules:*" ] +-+ } +-+ +-+ profiler_builtins_crates = [ +-+ "core", +-+ "compiler_builtins", +-+ "profiler_builtins", +-+ ] +-+ +-+ # When using instrumentation, profiler_builtins and its deps must be built +-+ # before other std crates. Other crates depend on this target so they are +-+ # built in the right order. +-+ group("profiler_builtins_group") { +-+ deps = [] +-+ foreach(libname, profiler_builtins_crates) { +-+ deps += [ "rules:$libname" ] +-+ } +-+ visibility = [ "rules:*" ] +-+ } +-+ +-+ config("local_stdlib_sysroot") { +-+ sysroot = rebase_path(local_rustc_sysroot, root_build_dir) +-+ rustflags = [ "--sysroot=$sysroot" ] +-+ visibility = [ ":*" ] +-+ } +-+ +-+ group("local_stdlib_libs") { +-+ assert( +-+ enable_rust, +-+ "Some C++ target is including Rust code even though enable_rust=false") +-+ all_dependent_configs = [ ":stdlib_dependent_libs" ] +-+ deps = [] +-+ foreach(libname, stdlib_files + skip_stdlib_files) { +-+ deps += [ "rules:$libname" ] +-+ } +-+ visibility = [ ":*" ] +-+ } +-+ +-+ # Builds the stdlib and points the rustc `--sysroot` to them. Used by +-+ # targets for which linking is driven by Rust (bins and dylibs). +-+ group("stdlib_for_rustc") { +-+ assert( +-+ enable_rust, +-+ "Some C++ target is including Rust code even though enable_rust=false") +-+ all_dependent_configs = [ ":local_stdlib_sysroot" ] +-+ public_deps = [ ":local_stdlib_libs" ] +-+ } +-+ +-+ # Builds and links against the Rust stdlib. Used by targets for which +-+ # linking is driven by C++. +-+ group("stdlib_for_clang") { +-+ all_dependent_configs = [ ":stdlib_public_dependent_libs" ] +-+ public_deps = [ +-+ ":local_stdlib_libs", +-+ ":remap_alloc", +-+ ] +-+ } +-+ +-+ not_needed([ "ignore_stdlib_files" ]) +-+ } else { +- action("find_stdlib") { +- # Collect prebuilt Rust libraries from toolchain package and copy to a known +- # location. +-@@ -199,44 +315,28 @@ +- foreach(lib, extra_sysroot_libs) { +- outputs += [ "$target_out_dir/$lib" ] +- } +-+ +-+ visibility = [ ":*" ] +- } +-- } else { +-- not_needed([ "ignore_stdlib_files" ]) +-- } +- +-- # Construct sysroots for rustc invocations to better control what libraries +-- # are linked. We have two: one with copied prebuilt libraries, and one with +-- # our locally-built std. Both reside in root_out_dir: we must only have one of +-- # each per GN toolchain anyway. +-- +-- sysroot_lib_subdir = "lib/rustlib/$rust_abi_target/lib" +-- +-- if (prebuilt_libstd_supported) { +- prebuilt_rustc_sysroot = "$root_out_dir/prebuilt_rustc_sysroot" +-- copy("prebuilt_rustc_sysroot") { +-+ copy("prebuilt_rustc_copy_to_sysroot") { +- deps = [ ":find_stdlib" ] +- sources = get_target_outputs(":find_stdlib") +- outputs = +- [ "$prebuilt_rustc_sysroot/$sysroot_lib_subdir/{{source_file_part}}" ] +-+ +-+ visibility = [ ":*" ] +- } +- +-- config("prebuilt_stdlib_for_rustc") { +-- # Match the output directory of :prebuilt_rustc_sysroot +-+ config("prebuilt_stdlib_sysroot") { +-+ # Match the output directory of :prebuilt_rustc_copy_to_sysroot +- sysroot = rebase_path(prebuilt_rustc_sysroot, root_build_dir) +- rustflags = [ "--sysroot=$sysroot" ] +-+ visibility = [ ":*" ] +- } +- +-- # Use the sysroot generated by :prebuilt_rustc_sysroot. Almost all Rust targets should depend +-- # on this. +-- group("prebuilt_std_for_rustc") { +-- assert( +-- enable_rust, +-- "Some C++ target is including Rust code even though enable_rust=false") +-- all_dependent_configs = [ ":prebuilt_stdlib_for_rustc" ] +-- deps = [ ":prebuilt_rustc_sysroot" ] +-- } +-- +-- config("prebuilt_rust_stdlib_config") { +-+ config("prebuilt_stdlib_libs") { +- ldflags = [] +- lib_dir = rebase_path("$prebuilt_rustc_sysroot/$sysroot_lib_subdir", +- root_build_dir) +-@@ -266,80 +366,29 @@ +- # the linking step of a C++ EXE that depends on Rust. +- ldflags += _windows_lib_deps +- } +-- } +-- +-- # Provides std libs to non-rustc linkers. +-- group("link_prebuilt_std") { +-- assert( +-- enable_rust, +-- "Some C++ target is including Rust code even though enable_rust=false") +-- all_dependent_configs = [ ":prebuilt_rust_stdlib_config" ] +-- deps = [ +-- ":prebuilt_rustc_sysroot", +-- ":remap_alloc", +-- ] +-- } +-- } +-- +-- if (local_libstd_supported) { +-- local_rustc_sysroot = "$root_out_dir/local_rustc_sysroot" +-- +-- # All std targets starting with core build with our sysroot. It starts empty +-- # and is incrementally built. The directory must exist at the start. +-- generated_file("empty_sysroot_for_std_build") { +-- outputs = [ "$local_rustc_sysroot/$sysroot_lib_subdir/.empty" ] +-- contents = "" +- } +- +-- config("local_stdlib_for_rustc") { +-- sysroot = rebase_path(local_rustc_sysroot, root_build_dir) +-- rustflags = [ "--sysroot=$sysroot" ] +-- } +-- +-- # Target to be depended on by std build targets. Creates the initially empty +-- # sysroot. +-- group("std_build_deps") { +-- deps = [ ":empty_sysroot_for_std_build" ] +-- public_configs = [ ":local_stdlib_for_rustc" ] +-- } +-- +-- # Use the sysroot generated by :local_rustc_sysroot, which transitively builds +-- # std. Only for use in specific tests for now. +-- group("local_std_for_rustc") { +-+ # Use the sysroot generated by :prebuilt_rustc_copy_to_sysroot. +-+ group("stdlib_for_rustc") { +- assert( +- enable_rust, +- "Some C++ target is including Rust code even though enable_rust=false") +-- all_dependent_configs = [ ":local_stdlib_for_rustc" ] +-- +-- deps = [] +-- foreach(libname, stdlib_files + skip_stdlib_files) { +-- deps += [ "rules:$libname" ] +-- } +-+ all_dependent_configs = [ ":prebuilt_stdlib_sysroot" ] +-+ deps = [ ":prebuilt_rustc_copy_to_sysroot" ] +- } +- +-- config("local_rust_stdlib_config") { +-- if (is_win) { +-- # TODO(crbug.com/1434092): This should really be `libs`, however that +-- # breaks. Normally, we specify lib files with the `.lib` suffix but +-- # then when rustc links an EXE, it invokes lld-link with `.lib.lib` +-- # instead. +-- # +-- # Omitting the `.lib` suffix breaks linking as well, when clang drives +-- # the linking step of a C++ EXE that depends on Rust. +-- ldflags = _windows_lib_deps +-- } +-- } +-- +-- # TODO(crbug.com/1368806): rework this so when using locally-built std, we +-- # don't link the prebuilt std as well. +-- +-- group("link_local_std") { +-+ # Links the Rust stdlib. Used by targets for which linking is driven by +-+ # C++. +-+ group("stdlib_for_clang") { +- assert( +- enable_rust, +- "Some C++ target is including Rust code even though enable_rust=false") +-- all_dependent_configs = [ ":local_rust_stdlib_config" ] +-+ all_dependent_configs = [ +-+ ":prebuilt_stdlib_libs", +-+ ":stdlib_public_dependent_libs", +-+ ] +- deps = [ +-- ":local_std_for_rustc", +-+ ":prebuilt_rustc_copy_to_sysroot", +- ":remap_alloc", +- ] +- } +-diff --git a/build/rust/std/gnrt_config.toml b/build/rust/std/gnrt_config.toml +-index 9102ff8..76f9968b 100644 +---- a/build/rust/std/gnrt_config.toml +-+++ b/build/rust/std/gnrt_config.toml +-@@ -51,6 +51,11 @@ +- 'libc_non_exhaustive', 'libc_long_array', 'libc_ptr_addr_of', +- 'libc_underscore_const_names', 'libc_const_extern_fn' +- ] +-+# The libc crate tries to link in the Windows CRT, but we specify the CRT +-+# library ourselves in //build/config/win:dynamic_crt and +-+# //build/config/win:static_crt because Rustc does not allow us to specify +-+# using the debug CRT: https://github.com/rust-lang/rust/issues/39016 +-+rustflags = ['-Zlink-directives=false'] +- +- # This target is #[no_core] when included by std, which is incompatible with +- # profiling. +-diff --git a/build/rust/std/remap_alloc.cc b/build/rust/std/remap_alloc.cc +-index 7f8aa1d..1a9d226 100644 +---- a/build/rust/std/remap_alloc.cc +-+++ b/build/rust/std/remap_alloc.cc +-@@ -65,13 +65,17 @@ +- extern "C" { +- +- #ifdef COMPONENT_BUILD +-+#if BUILDFLAG(IS_WIN) +-+#define REMAP_ALLOC_ATTRIBUTES __declspec(dllexport) __attribute__((weak)) +-+#else +- #define REMAP_ALLOC_ATTRIBUTES \ +- __attribute__((visibility("default"))) __attribute__((weak)) +-+#endif +- #else +- #define REMAP_ALLOC_ATTRIBUTES __attribute__((weak)) +- #endif // COMPONENT_BUILD +- +--void* REMAP_ALLOC_ATTRIBUTES __rust_alloc(size_t size, size_t align) { +-+REMAP_ALLOC_ATTRIBUTES void* __rust_alloc(size_t size, size_t align) { +- // This mirrors kMaxSupportedAlignment from +- // base/allocator/partition_allocator/partition_alloc_constants.h. +- // ParitionAlloc will crash if given an alignment larger than this. +-@@ -114,11 +118,11 @@ +- } +- } +- +--void REMAP_ALLOC_ATTRIBUTES __rust_dealloc(void* p, size_t size, size_t align) { +-+REMAP_ALLOC_ATTRIBUTES void __rust_dealloc(void* p, size_t size, size_t align) { +- free(p); +- } +- +--void* REMAP_ALLOC_ATTRIBUTES __rust_realloc(void* p, +-+REMAP_ALLOC_ATTRIBUTES void* __rust_realloc(void* p, +- size_t old_size, +- size_t align, +- size_t new_size) { +-@@ -131,7 +135,7 @@ +- } +- } +- +--void* REMAP_ALLOC_ATTRIBUTES __rust_alloc_zeroed(size_t size, size_t align) { +-+REMAP_ALLOC_ATTRIBUTES void* __rust_alloc_zeroed(size_t size, size_t align) { +- if (align <= alignof(std::max_align_t)) { +- return calloc(size, 1); +- } else { +-@@ -141,12 +145,12 @@ +- } +- } +- +--void REMAP_ALLOC_ATTRIBUTES __rust_alloc_error_handler(size_t size, +-+REMAP_ALLOC_ATTRIBUTES void __rust_alloc_error_handler(size_t size, +- size_t align) { +- IMMEDIATE_CRASH(); +- } +- +--extern const unsigned char REMAP_ALLOC_ATTRIBUTES +-+REMAP_ALLOC_ATTRIBUTES extern const unsigned char +- __rust_alloc_error_handler_should_panic = 0; +- +- } // extern "C" +-diff --git a/build/rust/std/rules/BUILD.gn b/build/rust/std/rules/BUILD.gn +-index ef8d439..379809f 100644 +---- a/build/rust/std/rules/BUILD.gn +-+++ b/build/rust/std/rules/BUILD.gn +-@@ -362,6 +362,7 @@ +- "--cfg=libc_ptr_addr_of", +- "--cfg=libc_underscore_const_names", +- "--cfg=libc_const_extern_fn", +-+ "-Zlink-directives=false", +- "-Zforce-unstable-if-unmarked", +- ] +- output_dir = +-diff --git a/build/rust/tests/BUILD.gn b/build/rust/tests/BUILD.gn +-index 25e2b3f..22c74b6 100644 +---- a/build/rust/tests/BUILD.gn +-+++ b/build/rust/tests/BUILD.gn +-@@ -53,6 +53,7 @@ +- deps += [ +- "bindgen_test:bindgen_test_lib_unittests", +- "test_aliased_deps:test_aliased_deps_unittests", +-+ "test_cpp_including_rust:test_cpp_including_rust_dylib_unittests", +- "test_cpp_including_rust:test_cpp_including_rust_unittests", +- "test_rlib_crate:target1_test_rlib_crate_v0_2_unittests", +- "test_rlib_crate:target2_test_rlib_crate_v0_2_unittests", +-@@ -60,7 +61,6 @@ +- "test_rust_metadata:test_rust_metadata_unittests", +- "test_rust_multiple_dep_versions_exe/v1:test_lib_v1_unittests", +- "test_rust_multiple_dep_versions_exe/v2:test_lib_v2_unittests", +-- "test_rust_shared_library:test_rust_shared_library_unittests", +- "test_rust_static_library:test_rust_static_library_unittests", +- "test_rust_static_library_non_standard_arrangement:foo_tests", +- "test_rust_unittests", +-@@ -71,6 +71,12 @@ +- # `//build/rust/run_rs_bindings_from_cc.py`. +- #"test_rs_bindings_from_cc:test_rs_bindings_from_cc_unittests", +- ] +-+ if (!is_win || !is_component_build) { +-+ # TODO(crbug.com/1442273): The shared library unittest EXE ends up +-+ # requiring the DLL to run, even though it does not use the DLL. +-+ deps += +-+ [ "test_rust_shared_library:test_rust_shared_library_unittests" ] +-+ } +- if (current_toolchain == host_toolchain_no_sanitizers) { +- # Build these proc macro tests only on toolchains where we'd build the +- # proc macro itself. +-@@ -78,16 +84,6 @@ +- } +- } +- +-- if (local_libstd_supported) { +-- deps += [ +-- "test_local_std", +-- "test_local_std:test_local_std_exe", +-- ] +-- if (can_build_rust_unit_tests) { +-- deps += [ "test_local_std:test_local_std_unittests" ] +-- } +-- } +-- +- if (is_win) { +- deps += [ "test_control_flow_guard" ] +- } +-diff --git a/build/rust/tests/test_cpp_including_rust/BUILD.gn b/build/rust/tests/test_cpp_including_rust/BUILD.gn +-index 2157b79..8464e9e1b 100644 +---- a/build/rust/tests/test_cpp_including_rust/BUILD.gn +-+++ b/build/rust/tests/test_cpp_including_rust/BUILD.gn +-@@ -11,7 +11,7 @@ +- } +- +- test("test_cpp_including_rust_unittests") { +-- sources = [ "unittests.cc" ] +-+ sources = [ "static_unittests.cc" ] +- deps = [ +- "//base", +- "//base/allocator:buildflags", +-@@ -21,3 +21,15 @@ +- "//testing/gtest", +- ] +- } +-+ +-+test("test_cpp_including_rust_dylib_unittests") { +-+ sources = [ "shared_unittests.cc" ] +-+ deps = [ +-+ "//base", +-+ "//base/allocator:buildflags", +-+ "//base/test:run_all_unittests", +-+ "//build/rust/tests/test_rust_shared_library", +-+ "//testing/gmock", +-+ "//testing/gtest", +-+ ] +-+} +-diff --git a/build/rust/tests/test_cpp_including_rust/shared_unittests.cc b/build/rust/tests/test_cpp_including_rust/shared_unittests.cc +-new file mode 100644 +-index 0000000..b2071962 +---- /dev/null +-+++ b/build/rust/tests/test_cpp_including_rust/shared_unittests.cc +-@@ -0,0 +1,31 @@ +-+// Copyright 2023 The Chromium Authors +-+// Use of this source code is governed by a BSD-style license that can be +-+// found in the LICENSE file. +-+ +-+#include +-+ +-+#include +-+ +-+#include "base/allocator/buildflags.h" +-+#include "base/allocator/partition_allocator/address_pool_manager_bitmap.h" +-+#include "base/allocator/partition_allocator/partition_address_space.h" +-+#include "build/build_config.h" +-+#include "build/buildflag.h" +-+#include "testing/gtest/include/gtest/gtest.h" +-+ +-+#include "build/rust/tests/test_rust_shared_library/src/lib.rs.h" +-+ +-+TEST(RustSharedTest, CppCallingIntoRust_BasicFFI) { +-+ EXPECT_EQ(7, add_two_ints_via_rust(3, 4)); +-+} +-+ +-+TEST(RustSharedTest, RustComponentUsesPartitionAlloc) { +-+ // Verify that PartitionAlloc is consistently used in C++ and Rust. +-+ auto cpp_allocated_int = std::make_unique(); +-+ SomeStruct* rust_allocated_ptr = allocate_via_rust().into_raw(); +-+ EXPECT_EQ(partition_alloc::IsManagedByPartitionAlloc( +-+ reinterpret_cast(rust_allocated_ptr)), +-+ partition_alloc::IsManagedByPartitionAlloc( +-+ reinterpret_cast(cpp_allocated_int.get()))); +-+ rust::Box::from_raw(rust_allocated_ptr); +-+} +-diff --git a/build/rust/tests/test_cpp_including_rust/static_unittests.cc b/build/rust/tests/test_cpp_including_rust/static_unittests.cc +-new file mode 100644 +-index 0000000..77efd8d +---- /dev/null +-+++ b/build/rust/tests/test_cpp_including_rust/static_unittests.cc +-@@ -0,0 +1,31 @@ +-+// Copyright 2023 The Chromium Authors +-+// Use of this source code is governed by a BSD-style license that can be +-+// found in the LICENSE file. +-+ +-+#include +-+ +-+#include +-+ +-+#include "base/allocator/buildflags.h" +-+#include "base/allocator/partition_allocator/address_pool_manager_bitmap.h" +-+#include "base/allocator/partition_allocator/partition_address_space.h" +-+#include "build/build_config.h" +-+#include "build/buildflag.h" +-+#include "testing/gtest/include/gtest/gtest.h" +-+ +-+#include "build/rust/tests/test_rust_static_library/src/lib.rs.h" +-+ +-+TEST(RustStaticTest, CppCallingIntoRust_BasicFFI) { +-+ EXPECT_EQ(7, add_two_ints_via_rust(3, 4)); +-+} +-+ +-+TEST(RustStaticTest, RustComponentUsesPartitionAlloc) { +-+ // Verify that PartitionAlloc is consistently used in C++ and Rust. +-+ auto cpp_allocated_int = std::make_unique(); +-+ SomeStruct* rust_allocated_ptr = allocate_via_rust().into_raw(); +-+ EXPECT_EQ(partition_alloc::IsManagedByPartitionAlloc( +-+ reinterpret_cast(rust_allocated_ptr)), +-+ partition_alloc::IsManagedByPartitionAlloc( +-+ reinterpret_cast(cpp_allocated_int.get()))); +-+ rust::Box::from_raw(rust_allocated_ptr); +-+} +-diff --git a/build/rust/tests/test_cpp_including_rust/unittests.cc b/build/rust/tests/test_cpp_including_rust/unittests.cc +-deleted file mode 100644 +-index f3b65ad..0000000 +---- a/build/rust/tests/test_cpp_including_rust/unittests.cc +-+++ /dev/null +-@@ -1,31 +0,0 @@ +--// Copyright 2021 The Chromium Authors +--// Use of this source code is governed by a BSD-style license that can be +--// found in the LICENSE file. +-- +--#include +-- +--#include +-- +--#include "base/allocator/buildflags.h" +--#include "base/allocator/partition_allocator/address_pool_manager_bitmap.h" +--#include "base/allocator/partition_allocator/partition_address_space.h" +--#include "build/build_config.h" +--#include "build/buildflag.h" +--#include "testing/gtest/include/gtest/gtest.h" +-- +--#include "build/rust/tests/test_rust_static_library/src/lib.rs.h" +-- +--TEST(RustTest, CppCallingIntoRust_BasicFFI) { +-- EXPECT_EQ(7, add_two_ints_via_rust(3, 4)); +--} +-- +--TEST(RustTest, RustComponentUsesPartitionAlloc) { +-- // Verify that PartitionAlloc is consistently used in C++ and Rust. +-- auto cpp_allocated_int = std::make_unique(); +-- SomeStruct* rust_allocated_ptr = allocate_via_rust().into_raw(); +-- EXPECT_EQ(partition_alloc::IsManagedByPartitionAlloc( +-- reinterpret_cast(rust_allocated_ptr)), +-- partition_alloc::IsManagedByPartitionAlloc( +-- reinterpret_cast(cpp_allocated_int.get()))); +-- rust::Box::from_raw(rust_allocated_ptr); +--} +-diff --git a/build/rust/tests/test_local_std/BUILD.gn b/build/rust/tests/test_local_std/BUILD.gn +-deleted file mode 100644 +-index 499aebd..0000000 +---- a/build/rust/tests/test_local_std/BUILD.gn +-+++ /dev/null +-@@ -1,23 +0,0 @@ +--# Copyright 2023 The Chromium Authors +--# Use of this source code is governed by a BSD-style license that can be +--# found in the LICENSE file. +-- +--import("//build/config/rust.gni") +--import("//build/rust/rust_executable.gni") +--import("//build/rust/rust_static_library.gni") +-- +--assert(local_libstd_supported) +-- +--rust_static_library("test_local_std") { +-- sources = [ "lib.rs" ] +-- crate_root = "lib.rs" +-- build_native_rust_unit_tests = true +-- use_local_std = true +--} +-- +--rust_executable("test_local_std_exe") { +-- sources = [ "main.rs" ] +-- crate_root = "main.rs" +-- deps = [ ":test_local_std" ] +-- use_local_std = true +--} +-diff --git a/build/rust/tests/test_local_std/lib.rs b/build/rust/tests/test_local_std/lib.rs +-deleted file mode 100644 +-index 6328cf41..0000000 +---- a/build/rust/tests/test_local_std/lib.rs +-+++ /dev/null +-@@ -1,8 +0,0 @@ +--// Copyright 2023 The Chromium Authors +--// Use of this source code is governed by a BSD-style license that can be +--// found in the LICENSE file. +-- +--#[test] +--fn test_test() { +-- assert_eq!(1, 1); +--} +-diff --git a/build/rust/tests/test_local_std/main.rs b/build/rust/tests/test_local_std/main.rs +-deleted file mode 100644 +-index 746e021..0000000 +---- a/build/rust/tests/test_local_std/main.rs +-+++ /dev/null +-@@ -1,7 +0,0 @@ +--// Copyright 2023 The Chromium Authors +--// Use of this source code is governed by a BSD-style license that can be +--// found in the LICENSE file. +-- +--fn main() { +-- println!("hello world"); +--} +-diff --git a/build/rust/tests/test_rust_shared_library/src/lib.rs b/build/rust/tests/test_rust_shared_library/src/lib.rs +-index eabfa27..2fa77c3 100644 +---- a/build/rust/tests/test_rust_shared_library/src/lib.rs +-+++ b/build/rust/tests/test_rust_shared_library/src/lib.rs +-@@ -34,8 +34,8 @@ +- x + y +- } +- +--// The next function is used from the +--// AllocatorTest.RustComponentUsesPartitionAlloc unit test. +-+// The next function is used from the RustComponentUsesPartitionAlloc unit +-+// tests. +- pub fn allocate_via_rust() -> Box { +- Box::new(ffi::SomeStruct { a: 43 }) +- } +-diff --git a/build/rust/tests/test_simple_rust_exe/BUILD.gn b/build/rust/tests/test_simple_rust_exe/BUILD.gn +-index a800720..9e94819f 100644 +---- a/build/rust/tests/test_simple_rust_exe/BUILD.gn +-+++ b/build/rust/tests/test_simple_rust_exe/BUILD.gn +-@@ -8,5 +8,5 @@ +- # //build/rust/rust_executable.gni. +- executable("test_simple_rust_exe") { +- crate_root = "main.rs" +-- deps = [ "//build/rust/std:local_std_for_rustc" ] +-+ deps = [ "//build/rust/std:stdlib_for_rustc" ] +- } +diff --git a/0002-Remove-the-prebuilt-toolchain-from-the-Android-team.patch b/0002-Remove-the-prebuilt-toolchain-from-the-Android-team.patch +deleted file mode 100644 +index 036be1c..0000000 +--- a/0002-Remove-the-prebuilt-toolchain-from-the-Android-team.patch ++++ /dev/null +@@ -1,383 +0,0 @@ +-From 635f82e7dd5802b338a5a404f92672b1ed878df1 Mon Sep 17 00:00:00 2001 +-From: danakj +-Date: Thu, 4 May 2023 16:33:48 +0000 +-Subject: [PATCH] Remove the prebuilt toolchain from the Android team +- +-We build our own compiler and stdlib for Chrome unconditionally now, so +-this is no longer used. +- +-These paths were broken while fixing the Windows build, so time for +-them to go. +- +-Bug: 1292038 +-Change-Id: I9d43875671245e5be08fa63aff06f13c0b2243d9 +-Cq-Include-Trybots: luci.chromium.try:android-rust-arm32-rel,android-rust-arm64-dbg,android-rust-arm64-rel,linux-rust-x64-rel,linux-rust-x64-dbg,win-rust-x64-rel,win-rust-x64-dbg +-Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/4500460 +-Reviewed-by: Adrian Taylor +-Commit-Queue: danakj +-Reviewed-by: Ben Pastene +-Cr-Commit-Position: refs/heads/main@{#1139597} +---- +- DEPS | 13 ---- +- build/config/rust.gni | 75 +++++++------------ +- build/rust/std/BUILD.gn | 57 ++++---------- +- build/rust/std/find_std_rlibs.py | 32 -------- +- .../ci/android-rust-arm32-rel/properties.json | 3 +- +- .../ci/android-rust-arm64-dbg/properties.json | 3 +- +- .../ci/android-rust-arm64-rel/properties.json | 3 +- +- .../android-rust-arm32-rel/properties.json | 3 +- +- .../android-rust-arm64-dbg/properties.json | 3 +- +- .../android-rust-arm64-rel/properties.json | 3 +- +- .../chromium/ci/chromium.rust.star | 3 - +- 11 files changed, 47 insertions(+), 151 deletions(-) +- +-diff --git a/DEPS b/DEPS +-index 98d20c55e07a5..9606cafe4c800 100644 +---- a/DEPS +-+++ b/DEPS +-@@ -241,9 +241,6 @@ vars = { +- # Fetch Rust toolchain. +- 'checkout_rust': 'host_os == "linux"', +- +-- # Fetch the Android team's Rust toolchain. +-- 'fetch_android_chromium_rust_toolchain': False, +-- +- # See //docs/testing/regression-test-selection.md +- # for info on RTS +- 'checkout_rts_model': False, +-@@ -560,16 +557,6 @@ deps = { +- ], +- 'dep_type': 'cipd', +- }, +-- 'src/third_party/android_rust_toolchain/toolchain': { +-- 'packages': [ +-- { +-- 'package': 'chromium/third_party/android_rust_toolchain/linux-amd64', +-- 'version': 'version:2@1.64.0.cr2', +-- }, +-- ], +-- 'dep_type': 'cipd', +-- 'condition': 'fetch_android_chromium_rust_toolchain', +-- }, +- +- # We don't know target_cpu at deps time. At least until there's a universal +- # binary of httpd-php, pull both intel and arm versions in DEPS and then pick +-diff --git a/build/config/rust.gni b/build/config/rust.gni +-index c0d934ce193f2..544ca33a8e036 100644 +---- a/build/config/rust.gni +-+++ b/build/config/rust.gni +-@@ -35,19 +35,18 @@ declare_args() { +- # all Rust features enabled. +- enable_all_rust_features = false +- +-- # Use the Rust toolchain built in-tree. See //tools/rust. +-- use_chromium_rust_toolchain = true +-- +-- # Chromium currently has a Rust toolchain for Android and Linux, but +-- # if you wish to experiment on more platforms you can use this +-- # argument to specify an alternative toolchain. +-- # This should be an absolute path to a directory +-- # containing a 'bin' directory and others. Commonly +-+ # Chromium provides a Rust toolchain in //third_party/rust-toolchain when +-+ # checkout_rust is True (which is being rolled out by default over time). +-+ # +-+ # To use a custom toolchain instead, specify an absolute path to the root of +-+ # a Rust sysroot, which will have a 'bin' directory and others. Commonly +- # /.rustup/toolchains/nightly-- +- rust_sysroot_absolute = "" +- +-- # If you're using an external Rust toolchain, set this to a Rust +-- # the output of rustc -V. +-+ # If you're using a Rust toolchain as specified by rust_sysroot_absolute, +-+ # set this to the output of `rustc -V`. Changing this string will cause all +-+ # Rust targets to be rebuilt, which allows you to update your toolchain and +-+ # not break incremental builds. +- rustc_version = "" +- +- # If you're using a Rust toolchain as specified by rust_sysroot_absolute, +-@@ -77,10 +76,9 @@ declare_args() { +- host_toolchain_no_sanitizers = host_toolchain +- } +- +-+# Use a separate declare_args so these variables' defaults can depend on the +-+# ones above. +- declare_args() { +-- # Use a separate declare_args so these variables' defaults can depend on the +-- # ones above. +-- +- # Individual Rust components. +- +- # Conversions between Rust types and C++ types. +-@@ -105,36 +103,33 @@ declare_args() { +- enable_rust_boringssl = enable_all_rust_features +- } +- +--# Platform support for "official" toolchains (Android or Chromium) +--android_toolchain_supports_platform = +-- (!is_nacl && +-- (is_android && (current_cpu == "arm" || current_cpu == "arm64" || +-- current_cpu == "x64" || current_cpu == "x86"))) || +-- (is_linux && current_cpu == "x64") +-+# Use the Rust toolchain built in-tree. When false, we use the prebuilt Rust +-+# stdlibs that come with the specified custom toolchain. +-+use_chromium_rust_toolchain = rust_sysroot_absolute == "" +-+ +-+# Platform support for the Rust toolchain. +- chromium_toolchain_supports_platform = !is_nacl +- custom_toolchain_supports_platform = !is_nacl || rust_toolchain_supports_nacl +- +--toolchain_has_rust = +-- enable_rust && +-- ((use_chromium_rust_toolchain && chromium_toolchain_supports_platform) || +-- (!use_chromium_rust_toolchain && android_toolchain_supports_platform) || +-- (rust_sysroot_absolute != "" && custom_toolchain_supports_platform)) +-+# Not all target triples (GN toolchains) are supported by the Rust compiler. +-+# Define if we support the current GN toolchain. +-+toolchain_has_rust = false +- +- # The rustc_revision is used to introduce a dependency on the toolchain version +- # (so e.g. rust targets are rebuilt, and the standard library is re-copied when +- # the toolchain changes). It is left empty for custom toolchains. +- rustc_revision = "" +--if (toolchain_has_rust) { +-+ +-+if (enable_rust) { +- if (use_chromium_rust_toolchain) { +-+ toolchain_has_rust = chromium_toolchain_supports_platform +- update_rust_args = [ "--print-package-version" ] +- rustc_revision = exec_script("//tools/rust/update_rust.py", +- update_rust_args, +- "trim string") +-- } else if (rust_sysroot_absolute != "") { +-- rustc_revision = rustc_version +- } else { +-- # Android toolchain version. +-- rustc_revision = "rustc 1.64.0-dev (Android Rust Toolchain version 9099361)" +-+ toolchain_has_rust = custom_toolchain_supports_platform +-+ rustc_revision = rustc_version +- } +- } +- +-@@ -150,21 +145,10 @@ build_rust_crash = toolchain_has_rust && enable_rust_crash +- # portability. In practice if an external toolchain was specified, it might +- # be an absolute path, but we'll do our best. +- if (enable_rust) { +-- if (rust_sysroot_absolute != "") { +-- rust_sysroot = get_path_info(rust_sysroot_absolute, "abspath") +-- use_unverified_rust_toolchain = true +-- } else if (use_chromium_rust_toolchain) { +-+ if (use_chromium_rust_toolchain) { +- rust_sysroot = "//third_party/rust-toolchain" +-- use_unverified_rust_toolchain = false +- } else { +-- if (host_os != "linux") { +-- assert(false, +-- "Attempt to use Android Rust toolchain on an unsupported platform") +-- } +-- +-- rust_sysroot = "//third_party/android_rust_toolchain/toolchain" +-- use_unverified_rust_toolchain = false +-- extra_sysroot_libs += [ "libunwind.a" ] +-+ rust_sysroot = get_path_info(rust_sysroot_absolute, "abspath") +- } +- } +- +-@@ -266,13 +250,6 @@ if (current_cpu == "x86") { +- +- assert(!toolchain_has_rust || rust_target_arch != "") +- +--# Must use Chromium Rust toolchain to get precisely matching LLVM versions +--# in order to enable LTO. Some say that LTO probably works if LLVM is "close +--# enough", but we don't want to take that risk. +--assert(!use_thin_lto || !enable_rust || use_chromium_rust_toolchain || +-- use_unverified_rust_toolchain, +-- "Must use Chromium Rust toolchain for LTO") +-- +- # Arguments for Rust invocation. +- # This is common between gcc/clang, Mac and Windows toolchains so specify once, +- # here. This is not the complete command-line: toolchains should add -o +-diff --git a/build/rust/std/BUILD.gn b/build/rust/std/BUILD.gn +-index 03b894327c0d0..60aea480a42a1 100644 +---- a/build/rust/std/BUILD.gn +-+++ b/build/rust/std/BUILD.gn +-@@ -70,12 +70,6 @@ if (toolchain_has_rust) { +- "unwind", +- ] +- +-- # rlibs explicitly ignored when copying prebuilt sysroot libraries. +-- # find_std_rlibs.py rightfully errors out if an unexpected prebuilt lib is +-- # encountered, since it usually indicates we missed something. This ignore +-- # list is also passed to it. This has no effect on the local std build. +-- ignore_stdlib_files = [] +-- +- # proc_macro is special: we only run proc macros on the host, so we only want +- # it for our host toolchain. +- if (current_toolchain == host_toolchain_no_sanitizers) { +-@@ -83,10 +77,6 @@ if (toolchain_has_rust) { +- # includes proc_macro in the prebuilts copied in find_stdlib. Otherwise it +- # is not built or copied. +- stdlib_files += [ "proc_macro" ] +-- } else { +-- # Explicitly ignore it from the prebuilts. Nothing needs to be done for the +-- # local std build. +-- ignore_stdlib_files += [ "proc_macro" ] +- } +- +- # Different Rust toolchains may add or remove files relative to the above +-@@ -198,9 +188,11 @@ if (toolchain_has_rust) { +- } +- +- group("local_stdlib_libs") { +-- assert( +-- enable_rust, +-- "Some C++ target is including Rust code even though enable_rust=false") +-+ assert(toolchain_has_rust, +-+ "Some C++ target is depending on Rust code even though " + +-+ "toolchain_has_rust=false. Usually this would mean" + +-+ "a NaCl target is depending on Rust, as there's no Rust " + +-+ "toolchain targetting NaCl.") +- all_dependent_configs = [ ":stdlib_dependent_libs" ] +- deps = [] +- foreach(libname, stdlib_files + skip_stdlib_files) { +-@@ -212,9 +204,6 @@ if (toolchain_has_rust) { +- # Builds the stdlib and points the rustc `--sysroot` to them. Used by +- # targets for which linking is driven by Rust (bins and dylibs). +- group("stdlib_for_rustc") { +-- assert( +-- enable_rust, +-- "Some C++ target is including Rust code even though enable_rust=false") +- all_dependent_configs = [ ":local_stdlib_sysroot" ] +- public_deps = [ ":local_stdlib_libs" ] +- } +-@@ -228,27 +217,25 @@ if (toolchain_has_rust) { +- ":remap_alloc", +- ] +- } +-- +-- not_needed([ "ignore_stdlib_files" ]) +- } else { +- action("find_stdlib") { +-- # Collect prebuilt Rust libraries from toolchain package and copy to a known +-- # location. +-+ # Collect prebuilt Rust libraries from toolchain package and copy to a +-+ # known location. +- # +- # The Rust toolchain contains prebuilt rlibs for the standard library and +- # its dependencies. However, they have unstable names: an unpredictable +- # metadata hash is appended to the known crate name. +- # +- # We must depend on these rlibs explicitly when rustc is not in charge of +-- # linking. However, it is difficult to construct GN rules to do so when the +-- # names can't be known statically. +-+ # linking. However, it is difficult to construct GN rules to do so when +-+ # the names can't be known statically. +- # +- # This action copies the prebuilt rlibs to a known location, removing the +- # metadata part of the name. In the process it verifies we have all the +-- # libraries we expect and none that we don't. A depfile is generated so this +-- # step is re-run when any libraries change. The action script additionally +-- # verifies rustc matches the expected version, which is unrelated but this +-- # is a convenient place to do so. +-+ # libraries we expect and none that we don't. A depfile is generated so +-+ # this step is re-run when any libraries change. The action script +-+ # additionally verifies rustc matches the expected version, which is +-+ # unrelated but this is a convenient place to do so. +- # +- # The action refers to `stdlib_files`, `skip_stdlib_files`, and the +- # associated //build/config/rust.gni vars `removed_rust_stdlib_libs` and +-@@ -259,8 +246,8 @@ if (toolchain_has_rust) { +- out_libdir = rebase_path(target_out_dir, root_build_dir) +- out_depfile = rebase_path(depfile, root_build_dir) +- +-- # For the rustc sysroot we must include even the rlibs we don't pass to the +-- # C++ linker. +-+ # For the rustc sysroot we must include even the rlibs we don't pass to +-+ # the C++ linker. +- all_stdlibs_to_copy = stdlib_files + skip_stdlib_files +- args = [ +- "--rust-bin-dir", +-@@ -282,20 +269,6 @@ if (toolchain_has_rust) { +- rustc_revision, +- ] +- +-- if (!use_unverified_rust_toolchain) { +-- args += [ +-- "--stdlibs", +-- string_join(",", all_stdlibs_to_copy), +-- ] +-- +-- if (ignore_stdlib_files != []) { +-- args += [ +-- "--ignore-stdlibs", +-- string_join(",", ignore_stdlib_files), +-- ] +-- } +-- } +-- +- if (extra_sysroot_libs != []) { +- args += [ +- "--extra-libs", +-diff --git a/build/rust/std/find_std_rlibs.py b/build/rust/std/find_std_rlibs.py +-index 85ab477a9450c..386258f890c01 100755 +---- a/build/rust/std/find_std_rlibs.py +-+++ b/build/rust/std/find_std_rlibs.py +-@@ -33,10 +33,6 @@ def main(): +- parser.add_argument("--depfile-target", +- help="Target to key depfile around", +- required=True) +-- parser.add_argument("--stdlibs", +-- help="Expected list of standard library libraries") +-- parser.add_argument("--ignore-stdlibs", +-- help="List of sysroot libraries to ignore") +- parser.add_argument("--extra-libs", +- help="List of extra non-libstd sysroot libraries") +- parser.add_argument("--rustc-revision", +-@@ -44,24 +40,6 @@ def main(): +- " on the rustc version.") +- args = parser.parse_args() +- +-- # Expected rlibs by concise name (the crate name, plus a disambiguating suffix +-- # e.g. "-2" when necessary). +-- if args.stdlibs: +-- rlibs_expected = set() +-- for lib in args.stdlibs.split(','): +-- # The version is only included if there's more than one of `name`, and +-- # even then is only included for the 2nd onward. +-- (name, version) = EXPECTED_STDLIB_INPUT_REGEX.match(lib).group(1, 2) +-- if version is None: +-- rlibs_expected.add(name) +-- else: +-- rlibs_expected.add(f"{name}-{version}") +-- ignore_rlibs = set() +-- if args.ignore_stdlibs is not None: +-- ignore_rlibs = set(args.ignore_stdlibs.split(',')) +-- else: +-- rlibs_expected = None +-- +- extra_libs = set() +- if args.extra_libs: +- for lib in args.extra_libs.split(','): +-@@ -138,13 +116,6 @@ def copy_file(infile, outfile): +- +- output_filename = f"lib{concise_name}.rlib" +- +-- if rlibs_expected is not None: +-- if concise_name in ignore_rlibs: +-- continue +-- if concise_name not in rlibs_expected: +-- raise Exception("Found stdlib rlib that wasn't expected: %s" % f) +-- rlibs_expected.remove(concise_name) +-- +- infile = os.path.join(rustlib_dir, f) +- outfile = os.path.join(args.output, output_filename) +- copy_file(infile, outfile) +-@@ -155,9 +126,6 @@ def copy_file(infile, outfile): +- copy_file(infile, outfile) +- +- depfile.write("\n") +-- if rlibs_expected: +-- raise Exception("We failed to find all expected stdlib rlibs: %s" % +-- ','.join(rlibs_expected)) +- +- +- if __name__ == '__main__': +diff --git a/PKGBUILD b/PKGBUILD +index a642491..b6112d5 100644 +--- a/PKGBUILD ++++ b/PKGBUILD +@@ -28,7 +28,7 @@ + : "${COMPONENT:=4}" + + pkgname=brave +-pkgver=1.52.129 ++pkgver=1.57.49 + pkgrel=1 + pkgdesc='Web browser that blocks ads and trackers by default' + arch=(x86_64) +@@ -46,18 +46,18 @@ optdepends=('pipewire: WebRTC desktop sharing under Wayland' + 'org.freedesktop.secrets: password storage backend on GNOME / Xfce' + 'kwallet: support for storing passwords in KWallet on Plasma') + options=('!lto') # Chromium adds its own flags for ThinLTO +-_chromium_ver=114.0.5735.198 ++_chromium_ver=116.0.5845.96 + _launcher_ver=8 ++_gcc_patchset=2 ++_chromium_patchset=chromium-${_chromium_ver%%.*}-patchset-$_gcc_patchset + source=("brave-browser::git+https://github.com/brave/brave-browser.git#tag=v$pkgver" + "brave::git+https://github.com/brave/brave-core.git#tag=v$pkgver" + "chromium-mirror::git+https://github.com/chromium/chromium.git#tag=$_chromium_ver" + 'depot_tools::git+https://chromium.googlesource.com/chromium/tools/depot_tools.git' ++ "https://github.com/stha09/chromium-patches/releases/download/${_chromium_patchset}/${_chromium_patchset}.tar.xz" + "https://github.com/foutrelis/chromium-launcher/archive/refs/tags/v$_launcher_ver/chromium-launcher-$_launcher_ver.tar.gz" + chromium-launcher-electron-app.patch + chromium-launcher-vendor.patch +- system-rust-utils.patch +- 0001-Fix-Rust-linking-on-component-and-debug-Windows-builds.patch +- 0002-Remove-the-prebuilt-toolchain-from-the-Android-team.patch + brave-1.19-BUILD.gn.patch + brave-1.43-bitcoin-core_remove-serialize.h.patch + brave-1.43-debounce-debounce_navigation_throttle_fix.patch +@@ -67,27 +67,21 @@ source=("brave-browser::git+https://github.com/brave/brave-browser.git#tag=v$pkg + brave-1.52-bitints-libstdcxx-bypass.patch + brave-1.52-missing-includes.patch + brave-1.52-playlist-user-agent-only-constructor.patch) +-_arch_revision=fa08adba87b6222bdf9ba31aaa41579e634ec444 +-_patches=(add-some-typename-s-that-are-required-in-C-17.patch +- REVERT-disable-autoupgrading-debug-info.patch +- download-bubble-typename.patch +- webauthn-variant.patch +- random-fixes-for-gcc13.patch +- disable-GlobalMediaControlsCastStartStop.patch ++_arch_revision=1 ++_patches=(REVERT-disable-autoupgrading-debug-info.patch ++ random-build-fixes.patch + use-oauth2-client-switches-as-default.patch) + for _patch in "${_patches[@]}"; do +- source+=("https://gitlab.archlinux.org/archlinux/packaging/packages/chromium/-/raw/$_arch_revision/$_patch") ++ source+=("https://gitlab.archlinux.org/archlinux/packaging/packages/chromium/-/raw/$_chromium_ver-$_arch_revision/$_patch") + done + sha256sums=('SKIP' + 'SKIP' + 'SKIP' + 'SKIP' ++ '25ad7c1a5e0b7332f80ed15ccf07d7e871d8ffb4af64df7c8fef325a527859b0' + '213e50f48b67feb4441078d50b0fd431df34323be15be97c55302d3fdac4483a' + '9235485adc4acbfaf303605f4428a6995a7b0b3b5a95181b185afbcb9f1f6ae5' + '404bf09df39310a1e374c5e7eb9c7311239798adf4e8cd85b7ff04fc79647f88' +- 'dcaf12a8b2ba15cefafd6e3c053b2ec490b1b8e1c89a3309e41133c0cd183ed3' +- 'dfb5ca39abe7dd449729d3af3724fe27208d8cda76ecc4916cc57a4ad9c8e1b1' +- '01a809e8bf7eeed6e263bc7118d6e40395dca7ac8463dbe230303e13d17d673e' + '12a3d37ffca4c0fa25f89f02efdf79d24f6412ee29ec35e8a00f9086dba4e822' + '984bb0257ed6fe4af543c3fb803ed81bddc97ff367ccd93620404be60cb78eb3' + '30a6a9ca2a6dd965cb2d9f02639079130948bf45d483f0c629f2cf8394a1c22f' +@@ -97,18 +91,14 @@ sha256sums=('SKIP' + 'f781d6315e4147b775350d7a36481c3ce43b582eee5ee228768e42c30d9dd9ca' + '1654fa922d10a591d5c28159a6d22d1183bcbd3448f175d7f3e2e11879588ddd' + '7cf8569ff905666889842c36e82d51c08d482745cd2f71e48fa1296824f09839' +- '621ed210d75d0e846192c1571bb30db988721224a41572c27769c0288d361c11' + '1b782b0f6d4f645e4e0daa8a4852d63f0c972aa0473319216ff04613a0592a69' +- 'd464eed4be4e9bf6187b4c40a759c523b7befefa25ba34ad6401b2a07649ca2a' +- '590fabbb26270947cb477378b53a9dcd17855739076b4af9983e1e54dfcab6d7' +- 'ba4dd0a25a4fc3267ed19ccb39f28b28176ca3f97f53a4e9f5e9215280040ea0' +- '7f3b1b22d6a271431c1f9fc92b6eb49c6d80b8b3f868bdee07a6a1a16630a302' ++ 'e938c6ee7087eed8f0de83ffb0ca89e328575808fafa4fe3950aeb1bc58b9411' + 'e393174d7695d0bafed69e868c5fbfecf07aa6969f3b64596d0bae8b067e1711') + + # Possible replacements are listed in build/linux/unbundle/replace_gn_files.py + # Keys are the names in the above script; values are the dependencies in Arch + declare -gA _system_libs=( +- [brotli]=brotli ++ #[brotli]=brotli + [dav1d]=dav1d + [ffmpeg]=ffmpeg + [flac]=flac +@@ -159,10 +149,6 @@ prepare() { + + cd src/brave || exit + +- if [ "$COMPONENT" = "4" ]; then +- patch -Np1 -i "${srcdir}/system-rust-utils.patch" +- fi +- + jq ".config.projects.chrome.repository.url = \"file://${srcdir}/chromium-mirror@${_chromium_ver}\"" package.json > tmp.json + mv {tmp,package}.json + +@@ -227,23 +213,19 @@ prepare() { + patch -Np1 -i "${srcdir}/use-oauth2-client-switches-as-default.patch" + + # Upstream fixes +- patch -Np1 -i "${srcdir}/add-some-typename-s-that-are-required-in-C-17.patch" + + # Revert addition of compiler flag that needs newer clang + patch -Rp1 -i "${srcdir}/REVERT-disable-autoupgrading-debug-info.patch" + +- # Disable kGlobalMediaControlsCastStartStop by default +- # https://crbug.com/1314342 +- patch -Np1 -i "${srcdir}/disable-GlobalMediaControlsCastStartStop.patch" +- + # Build fixes +- patch -Np1 -i "${srcdir}/download-bubble-typename.patch" +- patch -Np1 -i "${srcdir}/webauthn-variant.patch" +- patch -Np1 -i "${srcdir}/random-fixes-for-gcc13.patch" ++ patch -Np1 -i "${srcdir}/random-build-fixes.patch" + +- # Rust fixes +- patch -Np1 -i "${srcdir}/0001-Fix-Rust-linking-on-component-and-debug-Windows-builds.patch" +- patch -Np1 -i "${srcdir}/0002-Remove-the-prebuilt-toolchain-from-the-Android-team.patch" ++ # Fixes for building with libstdc++ instead of libc++ ++ patch -Np1 -i "${srcdir}/patches/chromium-114-maldoca-include.patch" ++ patch -Np1 -i "${srcdir}/patches/chromium-114-ruy-include.patch" ++ patch -Np1 -i "${srcdir}/patches/chromium-114-vk_mem_alloc-include.patch" ++ patch -Np1 -i "${srcdir}/patches/chromium-116-object_paint_properties_sparse-include.patch" ++ patch -Np1 -i "${srcdir}/patches/chromium-116-profile_view_utils-include.patch" + + # Hacky patching + sed -e 's/\(enable_distro_version_check =\) true/\1 false/g' -i chrome/installer/linux/BUILD.gn +@@ -309,14 +291,6 @@ build() { + echo "rewards_grant_dev_endpoint = https://grant.rewards.brave.com" >> .npmrc + echo "rewards_grant_staging_endpoint = https://grant.rewards.brave.com" >> .npmrc + echo "rewards_grant_prod_endpoint = https://grant.rewards.brave.com" >> .npmrc +- echo "uphold_client_id = 6d8d9473ed20be627f71ed46e207f40c004c5b1a" >> .npmrc +- echo "uphold_client_secret = xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx" >> .npmrc +- echo "uphold_staging_client_id = 4c2b665ca060d912fec5c735c734859a06118cc8" >> .npmrc +- echo "uphold_staging_client_secret = xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx" >> .npmrc +- echo "gemini_api_url = https://api.gemini.com/v1" >> .npmrc +- echo "gemini_oauth_url = https://api.gemini.com/v1/oauth" >> .npmrc +- echo "gemini_wallet_client_id = 6d8d9473ed20be627f71ed46e207f40c004c5b1a" >> .npmrc +- echo "gemini_wallet_client_secret = xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx" >> .npmrc + echo "sardine_client_id = 7ca8433c-7e61-4e25-b76e-25aa2da68df1" >> .npmrc + echo "sardine_client_secret = 7ca8433c-7e61-4e25-b76e-25aa2da68df1" >> .npmrc + echo "brave_zero_ex_api_key = xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx" >> .npmrc +@@ -325,6 +299,25 @@ build() { + echo "p3a_constellation_upload_url = https://example.com" >> .npmrc + echo "p2a_json_upload_url = https://example.com" >> .npmrc + echo "star_randomness_host = https://example.com" >> .npmrc ++ echo "brave_ai_chat_endpoint = https://example.com" >> .npmrc ++ echo "bitflyer_production_client_id = xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx" >>.npmrc ++ echo "bitflyer_production_client_secret = xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx" >>.npmrc ++ echo "bitflyer_production_fee_address = https://example.com" >>.npmrc ++ echo "bitflyer_production_url = https://example.com" >>.npmrc ++ echo "gemini_production_api_url = https://api.gemini.com/v1" >> .npmrc ++ echo "gemini_production_client_id = 6d8d9473ed20be627f71ed46e207f40c004c5b1a" >> .npmrc ++ echo "gemini_production_client_secret = xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx" >> .npmrc ++ echo "gemini_production_fee_address = https://example.com" >>.npmrc ++ echo "gemini_production_oauth_url = https://api.gemini.com/v1/oauth" >> .npmrc ++ echo "uphold_production_api_url = https://example.com" >> .npmrc ++ echo "uphold_production_client_id = 6d8d9473ed20be627f71ed46e207f40c004c5b1a" >> .npmrc ++ echo "uphold_production_client_secret = xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx" >> .npmrc ++ echo "uphold_production_fee_address = https://example.com" >>.npmrc ++ echo "uphold_production_oauth_url = https://example.com" >> .npmrc ++ echo "zebpay_production_api_url = https://example.com" >>.npmrc ++ echo "zebpay_production_client_id = xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx" >>.npmrc ++ echo "zebpay_production_client_secret = xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx" >>.npmrc ++ echo "zebpay_production_oauth_url = https://example.com" >>.npmrc + + npm_args=() + if [ "$COMPONENT" = "4" ]; then +@@ -345,7 +338,6 @@ build() { + 'proprietary_codecs=true' + 'rtc_use_pipewire=true' + 'link_pulseaudio=true' +- 'use_gnome_keyring=false' + 'use_sysroot=false' + 'use_system_libffi=true' + 'use_custom_libcxx=false' +diff --git a/system-rust-utils.patch b/system-rust-utils.patch +deleted file mode 100644 +index 64c41c6..0000000 +--- a/system-rust-utils.patch ++++ /dev/null +@@ -1,46 +0,0 @@ +-diff --git a/script/cargo.py b/script/cargo.py +-index 0766c5f118..8ed8893272 100755 +---- a/script/cargo.py +-+++ b/script/cargo.py +-@@ -16,8 +16,8 @@ def run_cargo(command, args): +- env = os.environ.copy() +- +- rustup_home = args.rustup_home +-- env['RUSTUP_HOME'] = rustup_home +-- env['CARGO_HOME'] = rustup_home +-+ # env['RUSTUP_HOME'] = rustup_home +-+ # env['CARGO_HOME'] = rustup_home +- # Enable experimental features in non-nightly builds +- env['RUSTC_BOOTSTRAP'] = '1' +- +-diff --git a/script/cargo_cbindgen.py b/script/cargo_cbindgen.py +-index db28fd013e..78a9dd9481 100755 +---- a/script/cargo_cbindgen.py +-+++ b/script/cargo_cbindgen.py +-@@ -15,10 +15,10 @@ def run(args): +- env = os.environ.copy() +- +- rustup_home = args.rustup_home +-- env["RUSTUP_HOME"] = rustup_home +-+ # env["RUSTUP_HOME"] = rustup_home +- +- cargo_home = args.cargo_home +-- env["CARGO_HOME"] = cargo_home +-+ # env["CARGO_HOME"] = cargo_home +- +- rustup_bin = os.path.abspath(os.path.join(rustup_home, "bin")) +- cbindgen_bin = os.path.join( +-diff --git a/script/download_rust_deps.py b/script/download_rust_deps.py +-index 60ff491eb9..94521879c6 100755 +---- a/script/download_rust_deps.py +-+++ b/script/download_rust_deps.py +-@@ -203,7 +203,8 @@ def main(): +- "features": "vendored-openssl", +- }] +- for tool in tools: +-- cargo_install(tool, rustup_home) +-+ if shutil.which(tool["name"]) is None: +-+ cargo_install(tool, rustup_home) +- +- return 0 +- +-- +2.41.0 + diff --git a/brave/0002-Remove-the-prebuilt-toolchain-from-the-Android-team.patch b/brave/0002-Remove-the-prebuilt-toolchain-from-the-Android-team.patch deleted file mode 100644 index 036be1cc0..000000000 --- a/brave/0002-Remove-the-prebuilt-toolchain-from-the-Android-team.patch +++ /dev/null @@ -1,383 +0,0 @@ -From 635f82e7dd5802b338a5a404f92672b1ed878df1 Mon Sep 17 00:00:00 2001 -From: danakj -Date: Thu, 4 May 2023 16:33:48 +0000 -Subject: [PATCH] Remove the prebuilt toolchain from the Android team - -We build our own compiler and stdlib for Chrome unconditionally now, so -this is no longer used. - -These paths were broken while fixing the Windows build, so time for -them to go. - -Bug: 1292038 -Change-Id: I9d43875671245e5be08fa63aff06f13c0b2243d9 -Cq-Include-Trybots: luci.chromium.try:android-rust-arm32-rel,android-rust-arm64-dbg,android-rust-arm64-rel,linux-rust-x64-rel,linux-rust-x64-dbg,win-rust-x64-rel,win-rust-x64-dbg -Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/4500460 -Reviewed-by: Adrian Taylor -Commit-Queue: danakj -Reviewed-by: Ben Pastene -Cr-Commit-Position: refs/heads/main@{#1139597} ---- - DEPS | 13 ---- - build/config/rust.gni | 75 +++++++------------ - build/rust/std/BUILD.gn | 57 ++++---------- - build/rust/std/find_std_rlibs.py | 32 -------- - .../ci/android-rust-arm32-rel/properties.json | 3 +- - .../ci/android-rust-arm64-dbg/properties.json | 3 +- - .../ci/android-rust-arm64-rel/properties.json | 3 +- - .../android-rust-arm32-rel/properties.json | 3 +- - .../android-rust-arm64-dbg/properties.json | 3 +- - .../android-rust-arm64-rel/properties.json | 3 +- - .../chromium/ci/chromium.rust.star | 3 - - 11 files changed, 47 insertions(+), 151 deletions(-) - -diff --git a/DEPS b/DEPS -index 98d20c55e07a5..9606cafe4c800 100644 ---- a/DEPS -+++ b/DEPS -@@ -241,9 +241,6 @@ vars = { - # Fetch Rust toolchain. - 'checkout_rust': 'host_os == "linux"', - -- # Fetch the Android team's Rust toolchain. -- 'fetch_android_chromium_rust_toolchain': False, -- - # See //docs/testing/regression-test-selection.md - # for info on RTS - 'checkout_rts_model': False, -@@ -560,16 +557,6 @@ deps = { - ], - 'dep_type': 'cipd', - }, -- 'src/third_party/android_rust_toolchain/toolchain': { -- 'packages': [ -- { -- 'package': 'chromium/third_party/android_rust_toolchain/linux-amd64', -- 'version': 'version:2@1.64.0.cr2', -- }, -- ], -- 'dep_type': 'cipd', -- 'condition': 'fetch_android_chromium_rust_toolchain', -- }, - - # We don't know target_cpu at deps time. At least until there's a universal - # binary of httpd-php, pull both intel and arm versions in DEPS and then pick -diff --git a/build/config/rust.gni b/build/config/rust.gni -index c0d934ce193f2..544ca33a8e036 100644 ---- a/build/config/rust.gni -+++ b/build/config/rust.gni -@@ -35,19 +35,18 @@ declare_args() { - # all Rust features enabled. - enable_all_rust_features = false - -- # Use the Rust toolchain built in-tree. See //tools/rust. -- use_chromium_rust_toolchain = true -- -- # Chromium currently has a Rust toolchain for Android and Linux, but -- # if you wish to experiment on more platforms you can use this -- # argument to specify an alternative toolchain. -- # This should be an absolute path to a directory -- # containing a 'bin' directory and others. Commonly -+ # Chromium provides a Rust toolchain in //third_party/rust-toolchain when -+ # checkout_rust is True (which is being rolled out by default over time). -+ # -+ # To use a custom toolchain instead, specify an absolute path to the root of -+ # a Rust sysroot, which will have a 'bin' directory and others. Commonly - # /.rustup/toolchains/nightly-- - rust_sysroot_absolute = "" - -- # If you're using an external Rust toolchain, set this to a Rust -- # the output of rustc -V. -+ # If you're using a Rust toolchain as specified by rust_sysroot_absolute, -+ # set this to the output of `rustc -V`. Changing this string will cause all -+ # Rust targets to be rebuilt, which allows you to update your toolchain and -+ # not break incremental builds. - rustc_version = "" - - # If you're using a Rust toolchain as specified by rust_sysroot_absolute, -@@ -77,10 +76,9 @@ declare_args() { - host_toolchain_no_sanitizers = host_toolchain - } - -+# Use a separate declare_args so these variables' defaults can depend on the -+# ones above. - declare_args() { -- # Use a separate declare_args so these variables' defaults can depend on the -- # ones above. -- - # Individual Rust components. - - # Conversions between Rust types and C++ types. -@@ -105,36 +103,33 @@ declare_args() { - enable_rust_boringssl = enable_all_rust_features - } - --# Platform support for "official" toolchains (Android or Chromium) --android_toolchain_supports_platform = -- (!is_nacl && -- (is_android && (current_cpu == "arm" || current_cpu == "arm64" || -- current_cpu == "x64" || current_cpu == "x86"))) || -- (is_linux && current_cpu == "x64") -+# Use the Rust toolchain built in-tree. When false, we use the prebuilt Rust -+# stdlibs that come with the specified custom toolchain. -+use_chromium_rust_toolchain = rust_sysroot_absolute == "" -+ -+# Platform support for the Rust toolchain. - chromium_toolchain_supports_platform = !is_nacl - custom_toolchain_supports_platform = !is_nacl || rust_toolchain_supports_nacl - --toolchain_has_rust = -- enable_rust && -- ((use_chromium_rust_toolchain && chromium_toolchain_supports_platform) || -- (!use_chromium_rust_toolchain && android_toolchain_supports_platform) || -- (rust_sysroot_absolute != "" && custom_toolchain_supports_platform)) -+# Not all target triples (GN toolchains) are supported by the Rust compiler. -+# Define if we support the current GN toolchain. -+toolchain_has_rust = false - - # The rustc_revision is used to introduce a dependency on the toolchain version - # (so e.g. rust targets are rebuilt, and the standard library is re-copied when - # the toolchain changes). It is left empty for custom toolchains. - rustc_revision = "" --if (toolchain_has_rust) { -+ -+if (enable_rust) { - if (use_chromium_rust_toolchain) { -+ toolchain_has_rust = chromium_toolchain_supports_platform - update_rust_args = [ "--print-package-version" ] - rustc_revision = exec_script("//tools/rust/update_rust.py", - update_rust_args, - "trim string") -- } else if (rust_sysroot_absolute != "") { -- rustc_revision = rustc_version - } else { -- # Android toolchain version. -- rustc_revision = "rustc 1.64.0-dev (Android Rust Toolchain version 9099361)" -+ toolchain_has_rust = custom_toolchain_supports_platform -+ rustc_revision = rustc_version - } - } - -@@ -150,21 +145,10 @@ build_rust_crash = toolchain_has_rust && enable_rust_crash - # portability. In practice if an external toolchain was specified, it might - # be an absolute path, but we'll do our best. - if (enable_rust) { -- if (rust_sysroot_absolute != "") { -- rust_sysroot = get_path_info(rust_sysroot_absolute, "abspath") -- use_unverified_rust_toolchain = true -- } else if (use_chromium_rust_toolchain) { -+ if (use_chromium_rust_toolchain) { - rust_sysroot = "//third_party/rust-toolchain" -- use_unverified_rust_toolchain = false - } else { -- if (host_os != "linux") { -- assert(false, -- "Attempt to use Android Rust toolchain on an unsupported platform") -- } -- -- rust_sysroot = "//third_party/android_rust_toolchain/toolchain" -- use_unverified_rust_toolchain = false -- extra_sysroot_libs += [ "libunwind.a" ] -+ rust_sysroot = get_path_info(rust_sysroot_absolute, "abspath") - } - } - -@@ -266,13 +250,6 @@ if (current_cpu == "x86") { - - assert(!toolchain_has_rust || rust_target_arch != "") - --# Must use Chromium Rust toolchain to get precisely matching LLVM versions --# in order to enable LTO. Some say that LTO probably works if LLVM is "close --# enough", but we don't want to take that risk. --assert(!use_thin_lto || !enable_rust || use_chromium_rust_toolchain || -- use_unverified_rust_toolchain, -- "Must use Chromium Rust toolchain for LTO") -- - # Arguments for Rust invocation. - # This is common between gcc/clang, Mac and Windows toolchains so specify once, - # here. This is not the complete command-line: toolchains should add -o -diff --git a/build/rust/std/BUILD.gn b/build/rust/std/BUILD.gn -index 03b894327c0d0..60aea480a42a1 100644 ---- a/build/rust/std/BUILD.gn -+++ b/build/rust/std/BUILD.gn -@@ -70,12 +70,6 @@ if (toolchain_has_rust) { - "unwind", - ] - -- # rlibs explicitly ignored when copying prebuilt sysroot libraries. -- # find_std_rlibs.py rightfully errors out if an unexpected prebuilt lib is -- # encountered, since it usually indicates we missed something. This ignore -- # list is also passed to it. This has no effect on the local std build. -- ignore_stdlib_files = [] -- - # proc_macro is special: we only run proc macros on the host, so we only want - # it for our host toolchain. - if (current_toolchain == host_toolchain_no_sanitizers) { -@@ -83,10 +77,6 @@ if (toolchain_has_rust) { - # includes proc_macro in the prebuilts copied in find_stdlib. Otherwise it - # is not built or copied. - stdlib_files += [ "proc_macro" ] -- } else { -- # Explicitly ignore it from the prebuilts. Nothing needs to be done for the -- # local std build. -- ignore_stdlib_files += [ "proc_macro" ] - } - - # Different Rust toolchains may add or remove files relative to the above -@@ -198,9 +188,11 @@ if (toolchain_has_rust) { - } - - group("local_stdlib_libs") { -- assert( -- enable_rust, -- "Some C++ target is including Rust code even though enable_rust=false") -+ assert(toolchain_has_rust, -+ "Some C++ target is depending on Rust code even though " + -+ "toolchain_has_rust=false. Usually this would mean" + -+ "a NaCl target is depending on Rust, as there's no Rust " + -+ "toolchain targetting NaCl.") - all_dependent_configs = [ ":stdlib_dependent_libs" ] - deps = [] - foreach(libname, stdlib_files + skip_stdlib_files) { -@@ -212,9 +204,6 @@ if (toolchain_has_rust) { - # Builds the stdlib and points the rustc `--sysroot` to them. Used by - # targets for which linking is driven by Rust (bins and dylibs). - group("stdlib_for_rustc") { -- assert( -- enable_rust, -- "Some C++ target is including Rust code even though enable_rust=false") - all_dependent_configs = [ ":local_stdlib_sysroot" ] - public_deps = [ ":local_stdlib_libs" ] - } -@@ -228,27 +217,25 @@ if (toolchain_has_rust) { - ":remap_alloc", - ] - } -- -- not_needed([ "ignore_stdlib_files" ]) - } else { - action("find_stdlib") { -- # Collect prebuilt Rust libraries from toolchain package and copy to a known -- # location. -+ # Collect prebuilt Rust libraries from toolchain package and copy to a -+ # known location. - # - # The Rust toolchain contains prebuilt rlibs for the standard library and - # its dependencies. However, they have unstable names: an unpredictable - # metadata hash is appended to the known crate name. - # - # We must depend on these rlibs explicitly when rustc is not in charge of -- # linking. However, it is difficult to construct GN rules to do so when the -- # names can't be known statically. -+ # linking. However, it is difficult to construct GN rules to do so when -+ # the names can't be known statically. - # - # This action copies the prebuilt rlibs to a known location, removing the - # metadata part of the name. In the process it verifies we have all the -- # libraries we expect and none that we don't. A depfile is generated so this -- # step is re-run when any libraries change. The action script additionally -- # verifies rustc matches the expected version, which is unrelated but this -- # is a convenient place to do so. -+ # libraries we expect and none that we don't. A depfile is generated so -+ # this step is re-run when any libraries change. The action script -+ # additionally verifies rustc matches the expected version, which is -+ # unrelated but this is a convenient place to do so. - # - # The action refers to `stdlib_files`, `skip_stdlib_files`, and the - # associated //build/config/rust.gni vars `removed_rust_stdlib_libs` and -@@ -259,8 +246,8 @@ if (toolchain_has_rust) { - out_libdir = rebase_path(target_out_dir, root_build_dir) - out_depfile = rebase_path(depfile, root_build_dir) - -- # For the rustc sysroot we must include even the rlibs we don't pass to the -- # C++ linker. -+ # For the rustc sysroot we must include even the rlibs we don't pass to -+ # the C++ linker. - all_stdlibs_to_copy = stdlib_files + skip_stdlib_files - args = [ - "--rust-bin-dir", -@@ -282,20 +269,6 @@ if (toolchain_has_rust) { - rustc_revision, - ] - -- if (!use_unverified_rust_toolchain) { -- args += [ -- "--stdlibs", -- string_join(",", all_stdlibs_to_copy), -- ] -- -- if (ignore_stdlib_files != []) { -- args += [ -- "--ignore-stdlibs", -- string_join(",", ignore_stdlib_files), -- ] -- } -- } -- - if (extra_sysroot_libs != []) { - args += [ - "--extra-libs", -diff --git a/build/rust/std/find_std_rlibs.py b/build/rust/std/find_std_rlibs.py -index 85ab477a9450c..386258f890c01 100755 ---- a/build/rust/std/find_std_rlibs.py -+++ b/build/rust/std/find_std_rlibs.py -@@ -33,10 +33,6 @@ def main(): - parser.add_argument("--depfile-target", - help="Target to key depfile around", - required=True) -- parser.add_argument("--stdlibs", -- help="Expected list of standard library libraries") -- parser.add_argument("--ignore-stdlibs", -- help="List of sysroot libraries to ignore") - parser.add_argument("--extra-libs", - help="List of extra non-libstd sysroot libraries") - parser.add_argument("--rustc-revision", -@@ -44,24 +40,6 @@ def main(): - " on the rustc version.") - args = parser.parse_args() - -- # Expected rlibs by concise name (the crate name, plus a disambiguating suffix -- # e.g. "-2" when necessary). -- if args.stdlibs: -- rlibs_expected = set() -- for lib in args.stdlibs.split(','): -- # The version is only included if there's more than one of `name`, and -- # even then is only included for the 2nd onward. -- (name, version) = EXPECTED_STDLIB_INPUT_REGEX.match(lib).group(1, 2) -- if version is None: -- rlibs_expected.add(name) -- else: -- rlibs_expected.add(f"{name}-{version}") -- ignore_rlibs = set() -- if args.ignore_stdlibs is not None: -- ignore_rlibs = set(args.ignore_stdlibs.split(',')) -- else: -- rlibs_expected = None -- - extra_libs = set() - if args.extra_libs: - for lib in args.extra_libs.split(','): -@@ -138,13 +116,6 @@ def copy_file(infile, outfile): - - output_filename = f"lib{concise_name}.rlib" - -- if rlibs_expected is not None: -- if concise_name in ignore_rlibs: -- continue -- if concise_name not in rlibs_expected: -- raise Exception("Found stdlib rlib that wasn't expected: %s" % f) -- rlibs_expected.remove(concise_name) -- - infile = os.path.join(rustlib_dir, f) - outfile = os.path.join(args.output, output_filename) - copy_file(infile, outfile) -@@ -155,9 +126,6 @@ def copy_file(infile, outfile): - copy_file(infile, outfile) - - depfile.write("\n") -- if rlibs_expected: -- raise Exception("We failed to find all expected stdlib rlibs: %s" % -- ','.join(rlibs_expected)) - - - if __name__ == '__main__': diff --git a/brave/PKGBUILD b/brave/PKGBUILD index a64249146..f213ad179 100644 --- a/brave/PKGBUILD +++ b/brave/PKGBUILD @@ -28,7 +28,7 @@ : "${COMPONENT:=4}" pkgname=brave -pkgver=1.52.129 +pkgver=1.58.127 pkgrel=1 pkgdesc='Web browser that blocks ads and trackers by default' arch=(x86_64) @@ -46,18 +46,180 @@ optdepends=('pipewire: WebRTC desktop sharing under Wayland' 'org.freedesktop.secrets: password storage backend on GNOME / Xfce' 'kwallet: support for storing passwords in KWallet on Plasma') options=('!lto') # Chromium adds its own flags for ThinLTO -_chromium_ver=114.0.5735.198 +_chromium_ver=117.0.5938.88 _launcher_ver=8 source=("brave-browser::git+https://github.com/brave/brave-browser.git#tag=v$pkgver" "brave::git+https://github.com/brave/brave-core.git#tag=v$pkgver" - "chromium-mirror::git+https://github.com/chromium/chromium.git#tag=$_chromium_ver" - 'depot_tools::git+https://chromium.googlesource.com/chromium/tools/depot_tools.git' + makepkg-source-roller.py + # BEGIN managed sources + chromium-mirror_brave_vendor_python-patch::git+https://github.com/brave/python-patch#commit=d8880110be6554686bc08261766538c2926d4e82 + chromium-mirror_brave_vendor_bat-native-tweetnacl::git+https://github.com/brave-intl/bat-native-tweetnacl.git#commit=800f9d40b7409239ff192e0be634764e747c7a75 + chromium-mirror_brave_vendor_gn-project-generators::git+https://github.com/brave/gn-project-generators.git#commit=b76e14b162aa0ce40f11920ec94bfc12da29e5d0 + chromium-mirror_brave_vendor_web-discovery-project::git+https://github.com/brave/web-discovery-project#commit=3180519fd678a317f3616bbe9497a184321d582f + chromium-mirror_brave_third_party_bip39wally-core-native::git+https://github.com/brave-intl/bat-native-bip39wally-core.git#commit=0d3a8713a2b388d2156fe49a70ef3f7cdb44b190 + chromium-mirror_brave_third_party_ethash_src::git+https://github.com/chfast/ethash.git#commit=e4a15c3d76dc09392c7efd3e30d84ee3b871e9ce + chromium-mirror_brave_third_party_bitcoin-core_src::git+https://github.com/bitcoin/bitcoin.git#commit=8105bce5b384c72cf08b25b7c5343622754e7337 + chromium-mirror_brave_third_party_argon2_src::git+https://github.com/P-H-C/phc-winner-argon2.git#commit=62358ba2123abd17fccf2a108a301d4b52c01a7c + chromium-mirror_brave_third_party_rapidjson_src::git+https://github.com/Tencent/rapidjson.git#commit=06d58b9e848c650114556a23294d0b6440078c61 + chromium-mirror_brave_third_party_reclient_configs_src::git+https://github.com/EngFlow/reclient-configs.git#commit=61ddd9705962a6c6c921b42c933451d4810aa28e + chromium-mirror_brave_third_party_playlist_component_src::git+https://github.com/brave/playlist-component.git#commit=6b53c4b06624cbd420843981ac77ca4cbeafe37a + chromium-mirror_brave_third_party_rust_challenge_bypass_ristretto_v1_crate::git+https://github.com/brave-intl/challenge-bypass-ristretto.git#commit=a1da4641734adc8312215b38a8221962d2c8e045 + chromium-mirror_brave_third_party_rust_futures_retry_v0_5_crate::git+https://github.com/brave-intl/futures-retry.git#commit=2aaaafbc3d394661534d4dbd14159d164243c20e + chromium-mirror::git+https://github.com/chromium/chromium.git#tag=123.0.6312.86 + chromium-mirror_third_party_clang-format_script::git+https://chromium.googlesource.com/external/github.com/llvm/llvm-project/clang/tools/clang-format.git#commit=e5337933f2951cacd3aeacd238ce4578163ca0b9 + chromium-mirror_third_party_libc++_src::git+https://chromium.googlesource.com/external/github.com/llvm/llvm-project/libcxx.git#commit=834e97d73f13a166af65952fb681071eec87a2c4 + chromium-mirror_third_party_libc++abi_src::git+https://chromium.googlesource.com/external/github.com/llvm/llvm-project/libcxxabi.git#commit=a7b3d968a3a923886fea64b424bd770e69dc4ea4 + chromium-mirror_third_party_libunwind_src::git+https://chromium.googlesource.com/external/github.com/llvm/llvm-project/libunwind.git#commit=8bad7bd6ec30f94bce82f7cb5b58ecbd6ce02996 + chromium-mirror_chrome_test_data_perf_canvas_bench::git+https://chromium.googlesource.com/chromium/canvas_bench.git#commit=a7b40ea5ae0239517d78845a5fc9b12976bfc732 + chromium-mirror_chrome_test_data_perf_frame_rate_content::git+https://chromium.googlesource.com/chromium/frame_rate/content.git#commit=c10272c88463efeef6bb19c9ec07c42bc8fe22b9 + chromium-mirror_chrome_test_data_xr_webvr_info::git+https://chromium.googlesource.com/external/github.com/toji/webvr.info.git#commit=c58ae99b9ff9e2aa4c524633519570bf33536248 + chromium-mirror_media_cdm_api::git+https://chromium.googlesource.com/chromium/cdm.git#commit=fef0b5aa1bd31efb88dfab804bdbe614f3d54f28 + chromium-mirror_native_client::git+https://chromium.googlesource.com/native_client/src/native_client.git#commit=48409922fc3877f7ab1e50435571aa8b4cf3dda9 + chromium-mirror_net_third_party_quiche_src::git+https://quiche.googlesource.com/quiche.git#commit=efc574e1125251bc1c3195c0c183c843b4c0a1df + chromium-mirror_third_party_angle::git+https://chromium.googlesource.com/angle/angle.git#commit=bbf1e1ea6bcf61e5e8e403870fd88df4e5e3a892 + chromium-mirror_third_party_anonymous_tokens_src::git+https://chromium.googlesource.com/external/github.com/google/anonymous-tokens.git#commit=d024f05b39e21bb2a0b8205a7ce72b1b185b84c2 + chromium-mirror_third_party_content_analysis_sdk_src::git+https://chromium.googlesource.com/external/github.com/chromium/content_analysis_sdk.git#commit=9a408736204513e0e95dd2ab3c08de0d95963efc + chromium-mirror_third_party_dav1d_libdav1d::git+https://chromium.googlesource.com/external/github.com/videolan/dav1d.git#commit=7b15ca13752aac7f0a1c6a56e33fe64d1f7638d4 + chromium-mirror_third_party_dawn::git+https://dawn.googlesource.com/dawn.git#commit=c8cf7442e43c1088c839eba17117b1ac29bf4e28 + chromium-mirror_third_party_highway_src::git+https://chromium.googlesource.com/external/github.com/google/highway.git#commit=8f20644eca693cfb74aa795b0006b6779c370e7a + chromium-mirror_third_party_google_benchmark_src::git+https://chromium.googlesource.com/external/github.com/google/benchmark.git#commit=b177433f3ee2513b1075140c723d73ab8901790f + chromium-mirror_third_party_boringssl_src::git+https://boringssl.googlesource.com/boringssl.git#commit=23824fa0fed94f4660ffafb15aaea8b317f2c8a6 + chromium-mirror_third_party_breakpad_breakpad::git+https://chromium.googlesource.com/breakpad/breakpad.git#commit=6551ac3632eb7236642366f70a2eb865b87a3329 + chromium-mirror_third_party_cast_core_public_src::git+https://chromium.googlesource.com/cast_core/public.git#commit=71f51fd6fa45fac73848f65421081edd723297cd + chromium-mirror_third_party_catapult::git+https://chromium.googlesource.com/catapult.git#commit=9cb2dc6f1b9c56d67fffbb7cf7bb7bb4ee156825 + chromium-mirror_third_party_ced_src::git+https://chromium.googlesource.com/external/github.com/google/compact_enc_det.git#commit=ba412eaaacd3186085babcd901679a48863c7dd5 + chromium-mirror_third_party_chromium-variations::git+https://chromium.googlesource.com/chromium-variations.git#commit=70b4eaba995ff3e59135b4e842bb247b40c64809 + chromium-mirror_third_party_cld_3_src::git+https://chromium.googlesource.com/external/github.com/google/cld_3.git#commit=b48dc46512566f5a2d41118c8c1116c4f96dc661 + chromium-mirror_third_party_colorama_src::git+https://chromium.googlesource.com/external/colorama.git#commit=3de9f013df4b470069d03d250224062e8cf15c49 + chromium-mirror_third_party_cpu_features_src::git+https://chromium.googlesource.com/external/github.com/google/cpu_features.git#commit=936b9ab5515dead115606559502e3864958f7f6e + chromium-mirror_third_party_cpuinfo_src::git+https://chromium.googlesource.com/external/github.com/pytorch/cpuinfo.git#commit=9484a6c590f831a30c1eec1311568b1a967a89dc + chromium-mirror_third_party_crc32c_src::git+https://chromium.googlesource.com/external/github.com/google/crc32c.git#commit=fa5ade41ee480003d9c5af6f43567ba22e4e17e6 + chromium-mirror_third_party_cros_system_api::git+https://chromium.googlesource.com/chromiumos/platform2/system_api.git#commit=d2229e09bc30d6ceab275991e26a9f3b1d5a74c0 + chromium-mirror_third_party_crossbench::git+https://chromium.googlesource.com/crossbench.git#commit=acbea986f40578f43c88239c78c797f61842e642 + chromium-mirror_third_party_depot_tools::git+https://chromium.googlesource.com/chromium/tools/depot_tools.git#commit=280bb93210cf6759498f8227ed439bb7845fce07 + chromium-mirror_third_party_devtools-frontend_src::git+https://chromium.googlesource.com/devtools/devtools-frontend.git#commit=28024a30b41f110dcf0ba28026f9b9bc921f39a1 + chromium-mirror_third_party_dom_distiller_js_dist::git+https://chromium.googlesource.com/chromium/dom-distiller/dist.git#commit=199de96b345ada7c6e7e6ba3d2fa7a6911b8767d + chromium-mirror_third_party_eigen3_src::git+https://chromium.googlesource.com/external/gitlab.com/libeigen/eigen.git#commit=7fd7a3f946e5ac152d28dad388cff8bfa1026925 + chromium-mirror_third_party_farmhash_src::git+https://chromium.googlesource.com/external/github.com/google/farmhash.git#commit=816a4ae622e964763ca0862d9dbd19324a1eaf45 + chromium-mirror_third_party_ffmpeg::git+https://chromium.googlesource.com/chromium/third_party/ffmpeg.git#commit=7c1b0b524c639beeb25363b1d0809ebe5c6efe5e + chromium-mirror_third_party_flac::git+https://chromium.googlesource.com/chromium/deps/flac.git#commit=689da3a7ed50af7448c3f1961d1791c7c1d9c85c + chromium-mirror_third_party_flatbuffers_src::git+https://chromium.googlesource.com/external/github.com/google/flatbuffers.git#commit=bcb9ef187628fe07514e57756d05e6a6296f7dc5 + chromium-mirror_third_party_fontconfig_src::git+https://chromium.googlesource.com/external/fontconfig.git#commit=14d466b30a8ab4a9d789977ed94f2c30e7209267 + chromium-mirror_third_party_fp16_src::git+https://chromium.googlesource.com/external/github.com/Maratyszcza/FP16.git#commit=0a92994d729ff76a58f692d3028ca1b64b145d91 + chromium-mirror_third_party_gemmlowp_src::git+https://chromium.googlesource.com/external/github.com/google/gemmlowp.git#commit=13d57703abca3005d97b19df1f2db731607a7dc2 + chromium-mirror_third_party_grpc_src::git+https://chromium.googlesource.com/external/github.com/grpc/grpc.git#commit=822dab21d9995c5cf942476b35ca12a1aa9d2737 + chromium-mirror_third_party_freetype_src::git+https://chromium.googlesource.com/chromium/src/third_party/freetype2.git#commit=47574f7ea445c8bb751da0fa716424c9c29a6807 + chromium-mirror_third_party_freetype-testing_src::git+https://chromium.googlesource.com/external/github.com/freetype/freetype2-testing.git#commit=7a69b1a2b028476f840ab7d4a2ffdfe4eb2c389f + chromium-mirror_third_party_fxdiv_src::git+https://chromium.googlesource.com/external/github.com/Maratyszcza/FXdiv.git#commit=63058eff77e11aa15bf531df5dd34395ec3017c8 + chromium-mirror_third_party_harfbuzz-ng_src::git+https://chromium.googlesource.com/external/github.com/harfbuzz/harfbuzz.git#commit=155015f4bec434ecc2f94621665844218f05ce51 + chromium-mirror_third_party_emoji-segmenter_src::git+https://chromium.googlesource.com/external/github.com/google/emoji-segmenter.git#commit=9ba6d25d0d9313569665d4a9d2b34f0f39f9a50e + chromium-mirror_third_party_ots_src::git+https://chromium.googlesource.com/external/github.com/khaledhosny/ots.git#commit=46bea9879127d0ff1c6601b078e2ce98e83fcd33 + chromium-mirror_third_party_libgav1_src::git+https://chromium.googlesource.com/codecs/libgav1.git#commit=d2f84e499e046281c4ded2d24d9186e2c54c01d8 + chromium-mirror_third_party_googletest_src::git+https://chromium.googlesource.com/external/github.com/google/googletest.git#commit=af29db7ec28d6df1c7f0f745186884091e602e07 + chromium-mirror_third_party_hunspell_dictionaries::git+https://chromium.googlesource.com/chromium/deps/hunspell_dictionaries.git#commit=41cdffd71c9948f63c7ad36e1fb0ff519aa7a37e + chromium-mirror_third_party_icu::git+https://chromium.googlesource.com/chromium/deps/icu.git#commit=bad7ddbf921358177e56fd723c2f59f8041a370f + chromium-mirror_third_party_jsoncpp_source::git+https://chromium.googlesource.com/external/github.com/open-source-parsers/jsoncpp.git#commit=42e892d96e47b1f6e29844cc705e148ec4856448 + chromium-mirror_third_party_leveldatabase_src::git+https://chromium.googlesource.com/external/leveldb.git#commit=068d5ee1a3ac40dabd00d211d5013af44be55bea + chromium-mirror_third_party_libFuzzer_src::git+https://chromium.googlesource.com/external/github.com/llvm/llvm-project/compiler-rt/lib/fuzzer.git#commit=758bd21f103a501b362b1ca46fa8fcb692eaa303 + chromium-mirror_third_party_fuzztest_src::git+https://chromium.googlesource.com/external/github.com/google/fuzztest.git#commit=61d95200e7ece7d121cab26f0c39fbf392e6566e + chromium-mirror_third_party_libaddressinput_src::git+https://chromium.googlesource.com/external/libaddressinput.git#commit=e8712e415627f22d0b00ebee8db99547077f39bd + chromium-mirror_third_party_libaom_source_libaom::git+https://aomedia.googlesource.com/aom.git#commit=a2d599c9750e3027d3104770fe74ff5d5d012c13 + chromium-mirror_third_party_libavif_src::git+https://chromium.googlesource.com/external/github.com/AOMediaCodec/libavif.git#commit=e88a7535f890c710768cea89b68a1c092da32506 + chromium-mirror_third_party_libavifinfo_src::git+https://aomedia.googlesource.com/libavifinfo.git#commit=b496868f7c3fd17dfeeecc0364fe37e19edd548a + chromium-mirror_third_party_nearby_src::git+https://chromium.googlesource.com/external/github.com/google/nearby-connections.git#commit=6ad4bf75e2e917571b42201fa2b5f30f8ba534db + chromium-mirror_third_party_beto-core_src::git+https://beto-core.googlesource.com/beto-core.git#commit=4d202dab960a0b6a6e4757ab4393945aca5a09db + chromium-mirror_third_party_securemessage_src::git+https://chromium.googlesource.com/external/github.com/google/securemessage.git#commit=fa07beb12babc3b25e0c5b1f38c16aa8cb6b8f84 + chromium-mirror_third_party_speedometer_v3.0::git+https://chromium.googlesource.com/external/github.com/WebKit/Speedometer.git#commit=7b1b81ee1319cae44c029fd8336d5e574f51e4e4 + chromium-mirror_third_party_ukey2_src::git+https://chromium.googlesource.com/external/github.com/google/ukey2.git#commit=0275885d8e6038c39b8a8ca55e75d1d4d1727f47 + chromium-mirror_third_party_cros-components_src::git+https://chromium.googlesource.com/external/google3/cros_components.git#commit=caaac730221dc9e0a461e7eedcae4a35a46696bd + chromium-mirror_third_party_libdrm_src::git+https://chromium.googlesource.com/chromiumos/third_party/libdrm.git#commit=98e1db501173303e58ef6a1def94ab7a2d84afc1 + chromium-mirror_third_party_expat_src::git+https://chromium.googlesource.com/external/github.com/libexpat/libexpat.git#commit=441f98d02deafd9b090aea568282b28f66a50e36 + chromium-mirror_third_party_libipp_libipp::git+https://chromium.googlesource.com/chromiumos/platform2/libipp.git#commit=2209bb84a8e122dab7c02fe66cc61a7b42873d7f + chromium-mirror_third_party_libjpeg_turbo::git+https://chromium.googlesource.com/chromium/deps/libjpeg_turbo.git#commit=9b894306ec3b28cea46e84c32b56773a98c483da + chromium-mirror_third_party_liblouis_src::git+https://chromium.googlesource.com/external/liblouis-github.git#commit=9700847afb92cb35969bdfcbbfbbb74b9c7b3376 + chromium-mirror_third_party_libphonenumber_dist::git+https://chromium.googlesource.com/external/libphonenumber.git#commit=140dfeb81b753388e8a672900fb7a971e9a0d362 + chromium-mirror_third_party_libprotobuf-mutator_src::git+https://chromium.googlesource.com/external/github.com/google/libprotobuf-mutator.git#commit=a304ec48dcf15d942607032151f7e9ee504b5dcf + chromium-mirror_third_party_libsrtp::git+https://chromium.googlesource.com/chromium/deps/libsrtp.git#commit=5b7c744eb8310250ccc534f3f86a2015b3887a0a + chromium-mirror_third_party_libsync_src::git+https://chromium.googlesource.com/aosp/platform/system/core/libsync.git#commit=f4f4387b6bf2387efbcfd1453af4892e8982faf6 + chromium-mirror_third_party_libvpx_source_libvpx::git+https://chromium.googlesource.com/webm/libvpx.git#commit=a667f8d08f67a0d9ff4e779287333cf2bc1c504b + chromium-mirror_third_party_libwebm_source::git+https://chromium.googlesource.com/webm/libwebm.git#commit=e4fbea0c9751ae8aa86629b197a28d8276a2b0da + chromium-mirror_third_party_libwebp_src::git+https://chromium.googlesource.com/webm/libwebp.git#commit=ca332209cb5567c9b249c86788cb2dbf8847e760 + chromium-mirror_third_party_libyuv::git+https://chromium.googlesource.com/libyuv/libyuv.git#commit=a6a2ec654b1be1166b376476a7555c89eca0c275 + chromium-mirror_third_party_lss::git+https://chromium.googlesource.com/linux-syscall-support.git#commit=ce877209e11aa69dcfffbd53ef90ea1d07136521 + chromium-mirror_third_party_material_color_utilities_src::git+https://chromium.googlesource.com/external/github.com/material-foundation/material-color-utilities.git#commit=13434b50dcb64a482cc91191f8cf6151d90f5465 + chromium-mirror_third_party_minigbm_src::git+https://chromium.googlesource.com/chromiumos/platform/minigbm.git#commit=3018207f4d89395cc271278fb9a6558b660885f5 + chromium-mirror_third_party_nasm::git+https://chromium.googlesource.com/chromium/deps/nasm.git#commit=f477acb1049f5e043904b87b825c5915084a9a29 + chromium-mirror_third_party_neon_2_sse_src::git+https://chromium.googlesource.com/external/github.com/intel/ARM_NEON_2_x86_SSE.git#commit=a15b489e1222b2087007546b4912e21293ea86ff + chromium-mirror_third_party_openh264_src::git+https://chromium.googlesource.com/external/github.com/cisco/openh264.git#commit=09a4f3ec842a8932341b195c5b01e141c8a16eb7 + chromium-mirror_third_party_openscreen_src::git+https://chromium.googlesource.com/openscreen.git#commit=f24b43fe39fde657f63030679c39b3c51a441586 + chromium-mirror_third_party_openxr_src::git+https://chromium.googlesource.com/external/github.com/KhronosGroup/OpenXR-SDK.git#commit=95fe35ffb383710a6e0567e958ead9a3b66e930c + chromium-mirror_third_party_pdfium::git+https://pdfium.googlesource.com/pdfium.git#commit=812acaddb5b581c775d49cd25c9590603a054cd6 + chromium-mirror_third_party_perfetto::git+https://android.googlesource.com/platform/external/perfetto.git#commit=63b162fccc3b5d601b561e3218322fa3d8b2dcaf + chromium-mirror_third_party_pthreadpool_src::git+https://chromium.googlesource.com/external/github.com/Maratyszcza/pthreadpool.git#commit=4fe0e1e183925bf8cfa6aae24237e724a96479b8 + chromium-mirror_third_party_pyelftools::git+https://chromium.googlesource.com/chromiumos/third_party/pyelftools.git#commit=19b3e610c86fcadb837d252c794cb5e8008826ae + chromium-mirror_third_party_quic_trace_src::git+https://chromium.googlesource.com/external/github.com/google/quic-trace.git#commit=caa0a6eaba816ecb737f9a70782b7c80b8ac8dbc + chromium-mirror_third_party_pywebsocket3_src::git+https://chromium.googlesource.com/external/github.com/GoogleChromeLabs/pywebsocket3.git#commit=50602a14f1b6da17e0b619833a13addc6ea78bc2 + chromium-mirror_third_party_re2_src::git+https://chromium.googlesource.com/external/github.com/google/re2.git#commit=f9550c3f7207f946a45bbccd1814b12b136aae72 + chromium-mirror_third_party_ruy_src::git+https://chromium.googlesource.com/external/github.com/google/ruy.git#commit=587c2cf8b11d3c32fa26887063eda3171a3d353e + chromium-mirror_third_party_skia::git+https://skia.googlesource.com/skia.git#commit=3d4e45907f9b239a54957001d619d2d4a6ca06b4 + chromium-mirror_third_party_smhasher_src::git+https://chromium.googlesource.com/external/smhasher.git#commit=e87738e57558e0ec472b2fc3a643b838e5b6e88f + chromium-mirror_third_party_snappy_src::git+https://chromium.googlesource.com/external/github.com/google/snappy.git#commit=c9f9edf6d75bb065fa47468bf035e051a57bec7c + chromium-mirror_third_party_sqlite_src::git+https://chromium.googlesource.com/chromium/deps/sqlite.git#commit=0c0e07d7de6bac46cb28fbf6c576a4e13de15553 + chromium-mirror_third_party_swiftshader::git+https://swiftshader.googlesource.com/SwiftShader.git#commit=eb75201a4e0354a36d315dd01077092ec9aa2356 + chromium-mirror_third_party_text-fragments-polyfill_src::git+https://chromium.googlesource.com/external/github.com/GoogleChromeLabs/text-fragments-polyfill.git#commit=c036420683f672d685e27415de0a5f5e85bdc23f + chromium-mirror_third_party_tflite_src::git+https://chromium.googlesource.com/external/github.com/tensorflow/tensorflow.git#commit=e65a2c7a59555735b58cea92e1571e7ced1b6bbf + chromium-mirror_third_party_vulkan-deps::git+https://chromium.googlesource.com/vulkan-deps.git#commit=9c80a66222a9f2f4f02b80b383bb378bfc236559 + chromium-mirror_third_party_vulkan_memory_allocator::git+https://chromium.googlesource.com/external/github.com/GPUOpen-LibrariesAndSDKs/VulkanMemoryAllocator.git#commit=56300b29fbfcc693ee6609ddad3fdd5b7a449a21 + chromium-mirror_third_party_wayland_src::git+https://chromium.googlesource.com/external/anongit.freedesktop.org/git/wayland/wayland.git#commit=c35d1a3d1c0a1735afe5eb227cb826faa878ec19 + chromium-mirror_third_party_wayland-protocols_src::git+https://chromium.googlesource.com/external/anongit.freedesktop.org/git/wayland/wayland-protocols.git#commit=681c33c8547d6aefe24455ba2bffe1c5ae11fee5 + chromium-mirror_third_party_wayland-protocols_kde::git+https://chromium.googlesource.com/external/github.com/KDE/plasma-wayland-protocols.git#commit=0b07950714b3a36c9b9f71fc025fc7783e82926e + chromium-mirror_third_party_wayland-protocols_gtk::git+https://chromium.googlesource.com/external/github.com/GNOME/gtk.git#commit=40ebed3a03aef096addc0af09fec4ec529d882a0 + chromium-mirror_third_party_webdriver_pylib::git+https://chromium.googlesource.com/external/github.com/SeleniumHQ/selenium/py.git#commit=fc5e7e70c098bfb189a9a74746809ad3c5c34e04 + chromium-mirror_third_party_webgl_src::git+https://chromium.googlesource.com/external/khronosgroup/webgl.git#commit=f4bf599a8b575df685c31d9c4729a70a04e377ed + chromium-mirror_third_party_webgpu-cts_src::git+https://chromium.googlesource.com/external/github.com/gpuweb/cts.git#commit=8a9294d00391a8d3dbcdb3091308f9b3034b384e + chromium-mirror_third_party_webrtc::git+https://webrtc.googlesource.com/src.git#commit=41b1493ddb5d98e9125d5cb002fd57ce76ebd8a7 + chromium-mirror_third_party_wuffs_src::git+https://skia.googlesource.com/external/github.com/google/wuffs-mirror-release-c.git#commit=e3f919ccfe3ef542cfc983a82146070258fb57f8 + chromium-mirror_third_party_weston_src::git+https://chromium.googlesource.com/external/anongit.freedesktop.org/git/wayland/weston.git#commit=ccf29cb237c3ed09c5f370f35239c93d07abfdd7 + chromium-mirror_third_party_xdg-utils::git+https://chromium.googlesource.com/chromium/deps/xdg-utils.git#commit=cb54d9db2e535ee4ef13cc91b65a1e2741a94a44 + chromium-mirror_third_party_xnnpack_src::git+https://chromium.googlesource.com/external/github.com/google/XNNPACK.git#commit=d5d373fee053b4823f37611f88a51d6c8e23d42a + chromium-mirror_tools_page_cycler_acid3::git+https://chromium.googlesource.com/chromium/deps/acid3.git#commit=a926d0a32e02c4c03ae95bb798e6c780e0e184ba + chromium-mirror_third_party_zstd_src::git+https://chromium.googlesource.com/external/github.com/facebook/zstd.git#commit=621a263fb2e6c2175fbd489e5d77ee8038baa2b2 + chromium-mirror_v8::git+https://chromium.googlesource.com/v8/v8.git#commit=363f205baa0f3497af3a844603bcc7b95436bfd8 + chromium-mirror_third_party_angle_third_party_glmark2_src::git+https://chromium.googlesource.com/external/github.com/glmark2/glmark2.git#commit=ca8de51fedb70bace5351c6b002eb952c747e889 + chromium-mirror_third_party_angle_third_party_rapidjson_src::git+https://chromium.googlesource.com/external/github.com/Tencent/rapidjson.git#commit=781a4e667d84aeedbeb8184b7b62425ea66ec59f + chromium-mirror_third_party_angle_third_party_VK-GL-CTS_src::git+https://chromium.googlesource.com/external/github.com/KhronosGroup/VK-GL-CTS.git#commit=c402aa4fc1f1299f4fd80442e7dcba2e9b0fe46f + chromium-mirror_third_party_dawn_buildtools::git+https://chromium.googlesource.com/chromium/src/buildtools.git#commit=48ab3bd053bfe2fef4635d7cb1861f8923167b96 + chromium-mirror_third_party_dawn_build::git+https://chromium.googlesource.com/chromium/src/build.git#commit=c6118a585ff6b2ef9f9a3b180d57b3cbf79e1788 + chromium-mirror_third_party_dawn_tools_clang::git+https://chromium.googlesource.com/chromium/src/tools/clang.git#commit=de6b303a8915c2610e6ff30f5e7c89b2c8e4e2af + chromium-mirror_third_party_dawn_testing::git+https://chromium.googlesource.com/chromium/src/testing.git#commit=035a9b18047370df7403758b006e6c9696d6b84d + chromium-mirror_third_party_dawn_third_party_jinja2::git+https://chromium.googlesource.com/chromium/src/third_party/jinja2.git#commit=e2d024354e11cc6b041b0cff032d73f0c7e43a07 + chromium-mirror_third_party_dawn_third_party_markupsafe::git+https://chromium.googlesource.com/chromium/src/third_party/markupsafe.git#commit=0bad08bb207bbfc1d6f3bbc82b9242b0c50e5794 + chromium-mirror_third_party_dawn_third_party_glfw::git+https://chromium.googlesource.com/external/github.com/glfw/glfw.git#commit=62e175ef9fae75335575964c845a302447c012c7 + chromium-mirror_third_party_dawn_third_party_zlib::git+https://chromium.googlesource.com/chromium/src/third_party/zlib.git#commit=526382e41c9c5275dc329db4328b54e4f344a204 + chromium-mirror_third_party_dawn_third_party_abseil-cpp::git+https://chromium.googlesource.com/chromium/src/third_party/abseil-cpp.git#commit=1cd1f16ff8f7fb5402aeda870c82652edf8f663a + chromium-mirror_third_party_dawn_third_party_dxc::git+https://chromium.googlesource.com/external/github.com/microsoft/DirectXShaderCompiler.git#commit=701a2b1da0387ac6abf73bdbaf7864b9615db033 + chromium-mirror_third_party_dawn_third_party_dxheaders::git+https://chromium.googlesource.com/external/github.com/microsoft/DirectX-Headers.git#commit=980971e835876dc0cde415e8f9bc646e64667bf7 + chromium-mirror_third_party_dawn_third_party_khronos_OpenGL-Registry::git+https://chromium.googlesource.com/external/github.com/KhronosGroup/OpenGL-Registry.git#commit=5bae8738b23d06968e7c3a41308568120943ae77 + chromium-mirror_third_party_dawn_third_party_khronos_EGL-Registry::git+https://chromium.googlesource.com/external/github.com/KhronosGroup/EGL-Registry.git#commit=7dea2ed79187cd13f76183c4b9100159b9e3e071 + chromium-mirror_third_party_dawn_third_party_protobuf::git+https://chromium.googlesource.com/chromium/src/third_party/protobuf.git#commit=41759e11ec427e29e1a72b9401d2af3f6e02d839 + chromium-mirror_third_party_dawn_tools_protoc_wrapper::git+https://chromium.googlesource.com/chromium/src/tools/protoc_wrapper.git#commit=b5ea227bd88235ab3ccda964d5f3819c4e2d8032 + chromium-mirror_third_party_dawn_third_party_partition_alloc::git+https://chromium.googlesource.com/chromium/src/base/allocator/partition_allocator.git#commit=67fd2f86eef40b1357387e2b0fc1eaf3c67d6ed7 + chromium-mirror_third_party_openscreen_src_third_party_tinycbor_src::git+https://chromium.googlesource.com/external/github.com/intel/tinycbor.git#commit=d393c16f3eb30d0c47e6f9d92db62272f0ec4dc7 + chromium-mirror_third_party_vulkan-deps_glslang_src::git+https://chromium.googlesource.com/external/github.com/KhronosGroup/glslang.git#commit=fb23503f12fda797389a92b8cc3d715dabfbd0fa + chromium-mirror_third_party_vulkan-deps_spirv-cross_src::git+https://chromium.googlesource.com/external/github.com/KhronosGroup/SPIRV-Cross.git#commit=b8fcf307f1f347089e3c46eb4451d27f32ebc8d3 + chromium-mirror_third_party_vulkan-deps_spirv-headers_src::git+https://chromium.googlesource.com/external/github.com/KhronosGroup/SPIRV-Headers.git#commit=05cc486580771e4fa7ddc89f5c9ee1e97382689a + chromium-mirror_third_party_vulkan-deps_spirv-tools_src::git+https://chromium.googlesource.com/external/github.com/KhronosGroup/SPIRV-Tools.git#commit=dc6676445be97ab19d8191fee019af62e2aaf774 + chromium-mirror_third_party_vulkan-deps_vulkan-headers_src::git+https://chromium.googlesource.com/external/github.com/KhronosGroup/Vulkan-Headers.git#commit=31aa7f634b052d87ede4664053e85f3f4d1d50d3 + chromium-mirror_third_party_vulkan-deps_vulkan-loader_src::git+https://chromium.googlesource.com/external/github.com/KhronosGroup/Vulkan-Loader.git#commit=aecbb2079ca6fad91752640c6c0c2f25f896fd5e + chromium-mirror_third_party_vulkan-deps_vulkan-tools_src::git+https://chromium.googlesource.com/external/github.com/KhronosGroup/Vulkan-Tools.git#commit=069bd14c0548556e130fc9e205adc918b7a01891 + chromium-mirror_third_party_vulkan-deps_vulkan-utility-libraries_src::git+https://chromium.googlesource.com/external/github.com/KhronosGroup/Vulkan-Utility-Libraries.git#commit=1b8b60bf7f271a09eeda032d117d51a43ed506cd + chromium-mirror_third_party_vulkan-deps_vulkan-validation-layers_src::git+https://chromium.googlesource.com/external/github.com/KhronosGroup/Vulkan-ValidationLayers.git#commit=9e40a3c8cb1a2c522d10febae545fbd56663ac0a + # END managed sources + "https://gitlab.com/Matt.Jolly/chromium-patches/-/archive/$_chromium_ver/chromium-patches-$_chromium_ver.tar.gz" "https://github.com/foutrelis/chromium-launcher/archive/refs/tags/v$_launcher_ver/chromium-launcher-$_launcher_ver.tar.gz" chromium-launcher-electron-app.patch chromium-launcher-vendor.patch - system-rust-utils.patch - 0001-Fix-Rust-linking-on-component-and-debug-Windows-builds.patch - 0002-Remove-the-prebuilt-toolchain-from-the-Android-team.patch + sync-brave-flag.patch brave-1.19-BUILD.gn.patch brave-1.43-bitcoin-core_remove-serialize.h.patch brave-1.43-debounce-debounce_navigation_throttle_fix.patch @@ -67,29 +229,23 @@ source=("brave-browser::git+https://github.com/brave/brave-browser.git#tag=v$pkg brave-1.52-bitints-libstdcxx-bypass.patch brave-1.52-missing-includes.patch brave-1.52-playlist-user-agent-only-constructor.patch) -_arch_revision=fa08adba87b6222bdf9ba31aaa41579e634ec444 -_patches=(add-some-typename-s-that-are-required-in-C-17.patch - REVERT-disable-autoupgrading-debug-info.patch - download-bubble-typename.patch - webauthn-variant.patch - random-fixes-for-gcc13.patch - disable-GlobalMediaControlsCastStartStop.patch +_arch_revision=1 +_patches=(drop-flag-unsupported-by-clang17.patch + compiler-rt-adjust-paths.patch use-oauth2-client-switches-as-default.patch) for _patch in "${_patches[@]}"; do - source+=("https://gitlab.archlinux.org/archlinux/packaging/packages/chromium/-/raw/$_arch_revision/$_patch") + source+=("https://gitlab.archlinux.org/archlinux/packaging/packages/chromium/-/raw/$_chromium_ver-$_arch_revision/$_patch") done sha256sums=('SKIP' 'SKIP' 'SKIP' 'SKIP' + '2c294d60ae58a3fe5d28864e63eda320aad76e51eac73348b0154a226c3cb1f5' '213e50f48b67feb4441078d50b0fd431df34323be15be97c55302d3fdac4483a' '9235485adc4acbfaf303605f4428a6995a7b0b3b5a95181b185afbcb9f1f6ae5' '404bf09df39310a1e374c5e7eb9c7311239798adf4e8cd85b7ff04fc79647f88' - 'dcaf12a8b2ba15cefafd6e3c053b2ec490b1b8e1c89a3309e41133c0cd183ed3' - 'dfb5ca39abe7dd449729d3af3724fe27208d8cda76ecc4916cc57a4ad9c8e1b1' - '01a809e8bf7eeed6e263bc7118d6e40395dca7ac8463dbe230303e13d17d673e' '12a3d37ffca4c0fa25f89f02efdf79d24f6412ee29ec35e8a00f9086dba4e822' - '984bb0257ed6fe4af543c3fb803ed81bddc97ff367ccd93620404be60cb78eb3' + 'bf74d6f2a6a9a94fe97e53e4d4303925812aeeffc54a9c4b2f5d14744798bf0e' '30a6a9ca2a6dd965cb2d9f02639079130948bf45d483f0c629f2cf8394a1c22f' 'ea0cd714ccaa839baf7c71e9077264016aa19415600f16b77d5398fd49f5a70b' '3864fcb12aaec849fd0e5423c9c5dfb1fdd7805e298a52125776bb24abe71e3c' @@ -97,40 +253,39 @@ sha256sums=('SKIP' 'f781d6315e4147b775350d7a36481c3ce43b582eee5ee228768e42c30d9dd9ca' '1654fa922d10a591d5c28159a6d22d1183bcbd3448f175d7f3e2e11879588ddd' '7cf8569ff905666889842c36e82d51c08d482745cd2f71e48fa1296824f09839' - '621ed210d75d0e846192c1571bb30db988721224a41572c27769c0288d361c11' + '7b9708f0dbfd697be7043d3cfe52da991185aa0ee29a3b8263506cd3ae4d41a9' + '30841fbe0785f8df584eeaa86584fe75f89da26e71df80cf536887557ddef0b6' '1b782b0f6d4f645e4e0daa8a4852d63f0c972aa0473319216ff04613a0592a69' - 'd464eed4be4e9bf6187b4c40a759c523b7befefa25ba34ad6401b2a07649ca2a' - '590fabbb26270947cb477378b53a9dcd17855739076b4af9983e1e54dfcab6d7' - 'ba4dd0a25a4fc3267ed19ccb39f28b28176ca3f97f53a4e9f5e9215280040ea0' - '7f3b1b22d6a271431c1f9fc92b6eb49c6d80b8b3f868bdee07a6a1a16630a302' + '55e6097d347be40cffebf3ce13ba84ea92d940f60865f1bd7c9af1ef2a2ef8e1' 'e393174d7695d0bafed69e868c5fbfecf07aa6969f3b64596d0bae8b067e1711') # Possible replacements are listed in build/linux/unbundle/replace_gn_files.py # Keys are the names in the above script; values are the dependencies in Arch declare -gA _system_libs=( - [brotli]=brotli - [dav1d]=dav1d - [ffmpeg]=ffmpeg - [flac]=flac - [fontconfig]=fontconfig - [freetype]=freetype2 - [harfbuzz-ng]=harfbuzz - [icu]=icu - [jsoncpp]=jsoncpp - #[libaom]=aom # https://aomedia.googlesource.com/aom/+/706ee36dcc82 - #[libavif]=libavif # https://github.com/AOMediaCodec/libavif/commit/4d2776a3 - [libdrm]= - [libjpeg]=libjpeg - [libpng]=libpng - #[libvpx]=libvpx - [libwebp]=libwebp - [libxml]=libxml2 - [libxslt]=libxslt - [opus]=opus - [re2]=re2 - [snappy]=snappy - [woff2]=woff2 - [zlib]=minizip + # [brotli]=brotli + [dav1d]="dav1d libdav1d.so" + # [ffmpeg]="ffmpeg libavcodec.so libavcodec.so libavformat.so libavutil.so" # YouTube playback stopped working in Chromium 120 + [flac]="flac libFLAC.so" + [fontconfig]="fontconfig libfontconfig.so" + [freetype]="freetype2 libfreetype.so" + [harfbuzz-ng]="harfbuzz libharfbuzz.so libharfbuzz-subset.so" + [icu]="icu libicui18n.so libicuuc.so" + # [jsoncpp]="jsoncpp libjsoncpp.so" # needs libstdc++ + # [libaom]=aom + # [libavif]=libavif # libavif.so libavutil.so # needs https://github.com/AOMediaCodec/libavif/commit/5410b23f76 + [libdrm]=libdrm # libdrm.so + [libjpeg]="libjpeg libjpeg.so" + [libpng]="libpng libpng16.so" + # [libvpx]=libvpx + [libwebp]="libwebp libwebpdemux.so libwebpmux.so libwebp.so" + [libxml]="libxml2 libxml2.so" + [libxslt]="libxslt libxslt.so" + [opus]="opus libopus.so" + # [re2]="re2 libre2.so" # needs libstdc++ + # [snappy]=snappy # libsnappy.so # needs libstdc++ + # [woff2]="woff2 libwoff2dec.so" # needs libstdc++ + [zlib]=minizip # libminizip.so + [zstd]="zstd libzstd.so" ) _unwanted_bundled_libs=( "$(printf "%s\n" ${!_system_libs[@]} | sed 's/^libjpeg$/&_turbo/')" @@ -138,30 +293,33 @@ _unwanted_bundled_libs=( depends+=(${_system_libs[@]}) prepare() { + rm -rf patches + ln -s chromium-patches-$_chromium_ver patches + + cp -r chromium-mirror_third_party_depot_tools depot_tools + cd chromium-launcher-$_launcher_ver patch -Np1 -i ../chromium-launcher-electron-app.patch patch -Np1 -i ../chromium-launcher-vendor.patch + cd .. - cd ../depot_tools - echo > python3_bin_reldir.txt - ln -sf /usr/bin/python3 python3 + export PATH+=":$PWD/depot_tools" DEPOT_TOOLS_UPDATE=0 + export VPYTHON_BYPASS='manually managed python not supported by chrome operations' - cd ../brave-browser + echo "Putting together brave sources" + # Generate gclient gn args file and prepare-brave-source-tree.sh + python makepkg-source-roller.py generate brave/DEPS $pkgname + rbash prepare-brave-source-tree.sh "$CARCH" - export DEPOT_TOOLS_UPDATE=0 - export PATH="${PATH}:${srcdir:?}/depot_tools" - - echo "Prepare the environment..." + cd brave-browser npm install - cp -r ../brave src - cp -r ../depot_tools src/brave/vendor + mv ../brave src + mv ../depot_tools src/brave/vendor cd src/brave || exit - if [ "$COMPONENT" = "4" ]; then - patch -Np1 -i "${srcdir}/system-rust-utils.patch" - fi + patch -Np1 -i "${srcdir}/sync-brave-flag.patch" jq ".config.projects.chrome.repository.url = \"file://${srcdir}/chromium-mirror@${_chromium_ver}\"" package.json > tmp.json mv {tmp,package}.json @@ -171,11 +329,7 @@ prepare() { cd ../.. echo "Running \"npm run\"" - if [ -d src/out/Release ]; then - npm run sync -- --force --nohooks - else - npm run init -- --nohooks - fi + npm run init -- --sync_brave=false --sync_chromium=false --nohooks echo "Running hooks..." # python "${srcdir}/depot_tools/gclient.py" runhooks @@ -187,28 +341,33 @@ prepare() { -s src/third_party/skia --header src/skia/ext/skia_commit_hash.h src/build/util/lastchange.py -s src/third_party/dawn \ --revision src/gpu/webgpu/DAWN_VERSION + src/tools/update_pgo_profiles.py --target=linux update \ + --gs-url-base=chromium-optimization-profiles/pgo_profiles # Create sysmlink to system clang-format - ln -sf /usr/bin/clang-format src/buildtools/linux64 + ln -sfn /usr/bin/clang-format src/buildtools/linux64 # Create sysmlink to system Node.js mkdir -p src/third_party/node/linux/node-linux-x64/bin - ln -sf /usr/bin/node src/third_party/node/linux/node-linux-x64/bin + ln -sfn /usr/bin/node src/third_party/node/linux/node-linux-x64/bin src/third_party/depot_tools/download_from_google_storage.py \ --no_resume --extract --no_auth --bucket chromium-nodejs \ -s src/third_party/node/node_modules.tar.gz.sha1 - python src/tools/download_optimization_profile.py \ - --newest_state=src/chrome/android/profiles/newest.txt \ - --local_state=src/chrome/android/profiles/local.txt \ - --output_name=src/chrome/android/profiles/afdo.prof \ - --gs_url_base=chromeos-prebuilt/afdo-job/llvm mkdir -p src/third_party/jdk/current/bin - ln -sf /usr/bin/java src/third_party/jdk/current/bin + ln -sfn /usr/bin/java src/third_party/jdk/current/bin # Brave specific hooks cd src/brave # python script/bootstrap.py + # python third_party/reclient_configs/src/configure_reclient.py + # --src_dir=.. + # --exec_root=../.. + # --custom_py=third_party/reclient_configs/brave_custom/brave_custom.py npm install --no-save --yes python script/web_discovery_project.py --install python script/generate_licenses.py + python ../build/util/lastchange.py \ + --output ../build/util/LASTCHANGE \ + --source-dir . \ + --filter '^[0-9]\{{1,\}}\.[0-9]\{{1,\}}\.[0-9]\{{1,\}}$' cd ../.. echo "Apply Chromium patches..." @@ -227,23 +386,15 @@ prepare() { patch -Np1 -i "${srcdir}/use-oauth2-client-switches-as-default.patch" # Upstream fixes - patch -Np1 -i "${srcdir}/add-some-typename-s-that-are-required-in-C-17.patch" - - # Revert addition of compiler flag that needs newer clang - patch -Rp1 -i "${srcdir}/REVERT-disable-autoupgrading-debug-info.patch" - # Disable kGlobalMediaControlsCastStartStop by default - # https://crbug.com/1314342 - patch -Np1 -i "${srcdir}/disable-GlobalMediaControlsCastStartStop.patch" + # Drop compiler flag that needs newer clang + patch -Np1 -i "${srcdir}/drop-flag-unsupported-by-clang17.patch" - # Build fixes - patch -Np1 -i "${srcdir}/download-bubble-typename.patch" - patch -Np1 -i "${srcdir}/webauthn-variant.patch" - patch -Np1 -i "${srcdir}/random-fixes-for-gcc13.patch" + # Allow libclang_rt.builtins from compiler-rt >= 16 to be used + patch -Np1 -i "${srcdir}/compiler-rt-adjust-paths.patch" - # Rust fixes - patch -Np1 -i "${srcdir}/0001-Fix-Rust-linking-on-component-and-debug-Windows-builds.patch" - patch -Np1 -i "${srcdir}/0002-Remove-the-prebuilt-toolchain-from-the-Android-team.patch" + # Fixes for building with libstdc++ instead of libc++ + patch -Np1 -i "${srcdir}/chromium-patches-*/chromium-117-material-color-include.patch" # Hacky patching sed -e 's/\(enable_distro_version_check =\) true/\1 false/g' -i chrome/installer/linux/BUILD.gn @@ -254,6 +405,7 @@ prepare() { tools/generate_shim_headers/generate_shim_headers.py echo "Add patches for Brave custom build" + rm -f brave/chromium_src/brave/third_party/bitcoin-core/src/src/serialize.h for _patch in "$srcdir/brave"*.patch; do patch -Np1 -i "$_patch" done @@ -309,14 +461,6 @@ build() { echo "rewards_grant_dev_endpoint = https://grant.rewards.brave.com" >> .npmrc echo "rewards_grant_staging_endpoint = https://grant.rewards.brave.com" >> .npmrc echo "rewards_grant_prod_endpoint = https://grant.rewards.brave.com" >> .npmrc - echo "uphold_client_id = 6d8d9473ed20be627f71ed46e207f40c004c5b1a" >> .npmrc - echo "uphold_client_secret = xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx" >> .npmrc - echo "uphold_staging_client_id = 4c2b665ca060d912fec5c735c734859a06118cc8" >> .npmrc - echo "uphold_staging_client_secret = xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx" >> .npmrc - echo "gemini_api_url = https://api.gemini.com/v1" >> .npmrc - echo "gemini_oauth_url = https://api.gemini.com/v1/oauth" >> .npmrc - echo "gemini_wallet_client_id = 6d8d9473ed20be627f71ed46e207f40c004c5b1a" >> .npmrc - echo "gemini_wallet_client_secret = xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx" >> .npmrc echo "sardine_client_id = 7ca8433c-7e61-4e25-b76e-25aa2da68df1" >> .npmrc echo "sardine_client_secret = 7ca8433c-7e61-4e25-b76e-25aa2da68df1" >> .npmrc echo "brave_zero_ex_api_key = xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx" >> .npmrc @@ -325,6 +469,25 @@ build() { echo "p3a_constellation_upload_url = https://example.com" >> .npmrc echo "p2a_json_upload_url = https://example.com" >> .npmrc echo "star_randomness_host = https://example.com" >> .npmrc + echo "brave_ai_chat_endpoint = https://example.com" >> .npmrc + echo "bitflyer_production_client_id = xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx" >>.npmrc + echo "bitflyer_production_client_secret = xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx" >>.npmrc + echo "bitflyer_production_fee_address = https://example.com" >>.npmrc + echo "bitflyer_production_url = https://example.com" >>.npmrc + echo "gemini_production_api_url = https://api.gemini.com/v1" >> .npmrc + echo "gemini_production_client_id = 6d8d9473ed20be627f71ed46e207f40c004c5b1a" >> .npmrc + echo "gemini_production_client_secret = xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx" >> .npmrc + echo "gemini_production_fee_address = https://example.com" >>.npmrc + echo "gemini_production_oauth_url = https://api.gemini.com/v1/oauth" >> .npmrc + echo "uphold_production_api_url = https://example.com" >> .npmrc + echo "uphold_production_client_id = 6d8d9473ed20be627f71ed46e207f40c004c5b1a" >> .npmrc + echo "uphold_production_client_secret = xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx" >> .npmrc + echo "uphold_production_fee_address = https://example.com" >>.npmrc + echo "uphold_production_oauth_url = https://example.com" >> .npmrc + echo "zebpay_production_api_url = https://example.com" >>.npmrc + echo "zebpay_production_client_id = xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx" >>.npmrc + echo "zebpay_production_client_secret = xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx" >>.npmrc + echo "zebpay_production_oauth_url = https://example.com" >>.npmrc npm_args=() if [ "$COMPONENT" = "4" ]; then @@ -334,10 +497,10 @@ build() { 'host_toolchain="//build/toolchain/linux/unbundle:default"' 'clang_base_path="/usr"' 'clang_use_chrome_plugins=false' - 'rust_sysroot_absolute="/usr"' - 'rustup_home="/usr"' + 'rust_sysroot_absolute="/home/yakoyoku/.rustup/toolchains/stable-x86_64-unknown-linux-gnu"' 'symbol_level=0' # sufficient for backtraces on x86(_64) 'chrome_pgo_phase=0' # needs newer clang to read the bundled PGO profile + 'is_cfi=true' 'treat_warnings_as_errors=false' 'disable_fieldtrial_testing_config=true' 'blink_enable_generated_code_formatting=false' @@ -345,10 +508,9 @@ build() { 'proprietary_codecs=true' 'rtc_use_pipewire=true' 'link_pulseaudio=true' - 'use_gnome_keyring=false' 'use_sysroot=false' 'use_system_libffi=true' - 'use_custom_libcxx=false' + 'use_custom_libcxx=true' # https://github.com/llvm/llvm-project/issues/61705 'enable_hangout_services_extension=true' 'enable_widevine=true' 'enable_nacl=false' @@ -361,7 +523,7 @@ build() { # This specific tool requires to be built outside of an official build printf "%s\n" "${_flags[@]}" "rustc_version=\"$_rustc_version\"" >> src/brave/tools/redirect_cc/args.gni - _flags+=('is_official_build=true') # implies is_cfi=true on x86_64 + # _flags+=('is_official_build=true') # implies is_cfi=true on x86_64 # Facilitate deterministic builds (taken from build/config/compiler/BUILD.gn) CFLAGS+=' -Wno-builtin-macro-redefined' @@ -420,6 +582,7 @@ build() { ;; esac + export RUSTC_BOOTSTRAP=1 npm run build ${_build_type} -- "${npm_args[@]}" npm run build ${_build_type} -- --target chrome_sandbox "${npm_args[@]}" npm run build ${_build_type} -- --target chromedriver.unstripped "${npm_args[@]}" diff --git a/brave/PKGBUILD.orig b/brave/PKGBUILD.orig new file mode 100644 index 000000000..b6112d5d9 --- /dev/null +++ b/brave/PKGBUILD.orig @@ -0,0 +1,500 @@ +# Maintainer: Caleb Maclennana +# Contributor: Caesar Woo +# Contributor: Martin Rodriguez Reboredo +# Contributor: Monarc +# Contributor: Joan Figueras +# Contributor: Jacek Szafarkiewicz +# Contributor: Maxim Baz <$pkgname at maximbaz dot com> + +## General Brave build info +## https://github.com/brave/brave-browser/blob/master/README.md#clone-and-initialize-the-repo + +## The following variables can be customized at build time. Use env or export to change at your wish +## +## Example use: `USE_SCCACHE=1 COMPONENT=1 makepkg -sc` +## +## USE_SCCACHE variable +## sccache for faster builds - https://github.com/brave/brave-browser/wiki/sccache-for-faster-builds +## Valid numbers between: 0 and 1 +## Default is: 0 => not use sccache +: "${USE_SCCACHE:=0}" +## +## COMPONENT variable +## 0 -> build normal (with debug symbols) +## 1 -> release (default) +## 2 -> static +## 3 -> debug +## 4 -> release with custom cflags and system libs +: "${COMPONENT:=4}" + +pkgname=brave +pkgver=1.57.49 +pkgrel=1 +pkgdesc='Web browser that blocks ads and trackers by default' +arch=(x86_64) +url='https://www.brave.com/download' +license=(BSD MPL custom:chromium) +depends=('gtk3' 'nss' 'alsa-lib' 'xdg-utils' 'libxss' 'libcups' 'libgcrypt' + 'ttf-liberation' 'systemd' 'dbus' 'libpulse' 'pciutils' 'libva' + 'libffi' 'desktop-file-utils' 'hicolor-icon-theme') +makedepends=('python' 'gn' 'ninja' 'clang' 'lld' 'gperf' 'nodejs' 'pipewire' + 'qt5-base' 'java-runtime-headless' 'git' 'cargo-audit' 'cbindgen' + 'cxxbridge' 'jq' 'llvm' 'npm') +optdepends=('pipewire: WebRTC desktop sharing under Wayland' + 'kdialog: support for native dialogs in Plasma' + 'qt5-base: enable Qt5 with --enable-features=AllowQt' + 'org.freedesktop.secrets: password storage backend on GNOME / Xfce' + 'kwallet: support for storing passwords in KWallet on Plasma') +options=('!lto') # Chromium adds its own flags for ThinLTO +_chromium_ver=116.0.5845.96 +_launcher_ver=8 +_gcc_patchset=2 +_chromium_patchset=chromium-${_chromium_ver%%.*}-patchset-$_gcc_patchset +source=("brave-browser::git+https://github.com/brave/brave-browser.git#tag=v$pkgver" + "brave::git+https://github.com/brave/brave-core.git#tag=v$pkgver" + "chromium-mirror::git+https://github.com/chromium/chromium.git#tag=$_chromium_ver" + 'depot_tools::git+https://chromium.googlesource.com/chromium/tools/depot_tools.git' + "https://github.com/stha09/chromium-patches/releases/download/${_chromium_patchset}/${_chromium_patchset}.tar.xz" + "https://github.com/foutrelis/chromium-launcher/archive/refs/tags/v$_launcher_ver/chromium-launcher-$_launcher_ver.tar.gz" + chromium-launcher-electron-app.patch + chromium-launcher-vendor.patch + brave-1.19-BUILD.gn.patch + brave-1.43-bitcoin-core_remove-serialize.h.patch + brave-1.43-debounce-debounce_navigation_throttle_fix.patch + brave-1.43-ntp_background_images-std-size_t.patch + brave-1.48-partitioned_host_state_map-cstring.patch + brave-1.52-bat-native-ads-fix-cmath.patch + brave-1.52-bitints-libstdcxx-bypass.patch + brave-1.52-missing-includes.patch + brave-1.52-playlist-user-agent-only-constructor.patch) +_arch_revision=1 +_patches=(REVERT-disable-autoupgrading-debug-info.patch + random-build-fixes.patch + use-oauth2-client-switches-as-default.patch) +for _patch in "${_patches[@]}"; do + source+=("https://gitlab.archlinux.org/archlinux/packaging/packages/chromium/-/raw/$_chromium_ver-$_arch_revision/$_patch") +done +sha256sums=('SKIP' + 'SKIP' + 'SKIP' + 'SKIP' + '25ad7c1a5e0b7332f80ed15ccf07d7e871d8ffb4af64df7c8fef325a527859b0' + '213e50f48b67feb4441078d50b0fd431df34323be15be97c55302d3fdac4483a' + '9235485adc4acbfaf303605f4428a6995a7b0b3b5a95181b185afbcb9f1f6ae5' + '404bf09df39310a1e374c5e7eb9c7311239798adf4e8cd85b7ff04fc79647f88' + '12a3d37ffca4c0fa25f89f02efdf79d24f6412ee29ec35e8a00f9086dba4e822' + '984bb0257ed6fe4af543c3fb803ed81bddc97ff367ccd93620404be60cb78eb3' + '30a6a9ca2a6dd965cb2d9f02639079130948bf45d483f0c629f2cf8394a1c22f' + 'ea0cd714ccaa839baf7c71e9077264016aa19415600f16b77d5398fd49f5a70b' + '3864fcb12aaec849fd0e5423c9c5dfb1fdd7805e298a52125776bb24abe71e3c' + '9a0c3d05aaa20812da8ee1fcb10c55a3df92f0c8248c3d2cbe4906d94dd48e49' + 'f781d6315e4147b775350d7a36481c3ce43b582eee5ee228768e42c30d9dd9ca' + '1654fa922d10a591d5c28159a6d22d1183bcbd3448f175d7f3e2e11879588ddd' + '7cf8569ff905666889842c36e82d51c08d482745cd2f71e48fa1296824f09839' + '1b782b0f6d4f645e4e0daa8a4852d63f0c972aa0473319216ff04613a0592a69' + 'e938c6ee7087eed8f0de83ffb0ca89e328575808fafa4fe3950aeb1bc58b9411' + 'e393174d7695d0bafed69e868c5fbfecf07aa6969f3b64596d0bae8b067e1711') + +# Possible replacements are listed in build/linux/unbundle/replace_gn_files.py +# Keys are the names in the above script; values are the dependencies in Arch +declare -gA _system_libs=( + #[brotli]=brotli + [dav1d]=dav1d + [ffmpeg]=ffmpeg + [flac]=flac + [fontconfig]=fontconfig + [freetype]=freetype2 + [harfbuzz-ng]=harfbuzz + [icu]=icu + [jsoncpp]=jsoncpp + #[libaom]=aom # https://aomedia.googlesource.com/aom/+/706ee36dcc82 + #[libavif]=libavif # https://github.com/AOMediaCodec/libavif/commit/4d2776a3 + [libdrm]= + [libjpeg]=libjpeg + [libpng]=libpng + #[libvpx]=libvpx + [libwebp]=libwebp + [libxml]=libxml2 + [libxslt]=libxslt + [opus]=opus + [re2]=re2 + [snappy]=snappy + [woff2]=woff2 + [zlib]=minizip +) +_unwanted_bundled_libs=( + "$(printf "%s\n" ${!_system_libs[@]} | sed 's/^libjpeg$/&_turbo/')" +) +depends+=(${_system_libs[@]}) + +prepare() { + cd chromium-launcher-$_launcher_ver + patch -Np1 -i ../chromium-launcher-electron-app.patch + patch -Np1 -i ../chromium-launcher-vendor.patch + + cd ../depot_tools + echo > python3_bin_reldir.txt + ln -sf /usr/bin/python3 python3 + + cd ../brave-browser + + export DEPOT_TOOLS_UPDATE=0 + export PATH="${PATH}:${srcdir:?}/depot_tools" + + echo "Prepare the environment..." + npm install + + cp -r ../brave src + cp -r ../depot_tools src/brave/vendor + + cd src/brave || exit + + jq ".config.projects.chrome.repository.url = \"file://${srcdir}/chromium-mirror@${_chromium_ver}\"" package.json > tmp.json + mv {tmp,package}.json + + npm install + + cd ../.. + + echo "Running \"npm run\"" + if [ -d src/out/Release ]; then + npm run sync -- --force --nohooks + else + npm run init -- --nohooks + fi + + echo "Running hooks..." + # python "${srcdir}/depot_tools/gclient.py" runhooks + src/build/landmines.py + src/build/util/lastchange.py -o src/build/util/LASTCHANGE + src/build/util/lastchange.py -m GPU_LISTS_VERSION \ + --revision-id-only --header src/gpu/config/gpu_lists_version.h + src/build/util/lastchange.py -m SKIA_COMMIT_HASH \ + -s src/third_party/skia --header src/skia/ext/skia_commit_hash.h + src/build/util/lastchange.py -s src/third_party/dawn \ + --revision src/gpu/webgpu/DAWN_VERSION + # Create sysmlink to system clang-format + ln -sf /usr/bin/clang-format src/buildtools/linux64 + # Create sysmlink to system Node.js + mkdir -p src/third_party/node/linux/node-linux-x64/bin + ln -sf /usr/bin/node src/third_party/node/linux/node-linux-x64/bin + src/third_party/depot_tools/download_from_google_storage.py \ + --no_resume --extract --no_auth --bucket chromium-nodejs \ + -s src/third_party/node/node_modules.tar.gz.sha1 + python src/tools/download_optimization_profile.py \ + --newest_state=src/chrome/android/profiles/newest.txt \ + --local_state=src/chrome/android/profiles/local.txt \ + --output_name=src/chrome/android/profiles/afdo.prof \ + --gs_url_base=chromeos-prebuilt/afdo-job/llvm + mkdir -p src/third_party/jdk/current/bin + ln -sf /usr/bin/java src/third_party/jdk/current/bin + + # Brave specific hooks + cd src/brave + # python script/bootstrap.py + npm install --no-save --yes + python script/web_discovery_project.py --install + python script/generate_licenses.py + cd ../.. + + echo "Apply Chromium patches..." + cd src + + # https://crbug.com/893950 + sed -i -e 's/\/malloc/' -e 's/\/free/' \ + third_party/blink/renderer/core/xml/*.cc \ + third_party/blink/renderer/core/xml/parser/xml_document_parser.cc \ + third_party/libxml/chromium/*.cc \ + third_party/maldoca/src/maldoca/ole/oss_utils.h + + # Use the --oauth2-client-id= and --oauth2-client-secret= switches for + # setting GOOGLE_DEFAULT_CLIENT_ID and GOOGLE_DEFAULT_CLIENT_SECRET at + # runtime -- this allows signing into Chromium without baked-in values + patch -Np1 -i "${srcdir}/use-oauth2-client-switches-as-default.patch" + + # Upstream fixes + + # Revert addition of compiler flag that needs newer clang + patch -Rp1 -i "${srcdir}/REVERT-disable-autoupgrading-debug-info.patch" + + # Build fixes + patch -Np1 -i "${srcdir}/random-build-fixes.patch" + + # Fixes for building with libstdc++ instead of libc++ + patch -Np1 -i "${srcdir}/patches/chromium-114-maldoca-include.patch" + patch -Np1 -i "${srcdir}/patches/chromium-114-ruy-include.patch" + patch -Np1 -i "${srcdir}/patches/chromium-114-vk_mem_alloc-include.patch" + patch -Np1 -i "${srcdir}/patches/chromium-116-object_paint_properties_sparse-include.patch" + patch -Np1 -i "${srcdir}/patches/chromium-116-profile_view_utils-include.patch" + + # Hacky patching + sed -e 's/\(enable_distro_version_check =\) true/\1 false/g' -i chrome/installer/linux/BUILD.gn + + # Allow building against system libraries in official builds + if [ "$COMPONENT" = "4" ]; then + sed -i 's/OFFICIAL_BUILD/GOOGLE_CHROME_BUILD/' \ + tools/generate_shim_headers/generate_shim_headers.py + + echo "Add patches for Brave custom build" + for _patch in "$srcdir/brave"*.patch; do + patch -Np1 -i "$_patch" + done + + # Remove bundled libraries for which we will use the system copies; this + # *should* do what the remove_bundled_libraries.py script does, with the + # added benefit of not having to list all the remaining libraries and + # preserving their git directories + local _lib + for _lib in ${_unwanted_bundled_libs[@]}; do + find "third_party/$_lib" -type f \ + \! -path "third_party/$_lib/chromium/*" \ + \! -path "third_party/$_lib/google/*" \ + \! -path "third_party/harfbuzz-ng/utils/hb_scoped.h" \ + \! -regex '.*\.\(git.*\|gn\|gni\|isolate\)' \ + -delete + done + + ./build/linux/unbundle/replace_gn_files.py \ + --system-libraries "${!_system_libs[@]}" + fi +} + +build() { + make CHROMIUM_APP=Brave CHROMIUM_NAME=brave -C chromium-launcher-$_launcher_ver + + cd "brave-browser" + + if check_buildoption ccache y; then + # Avoid falling back to preprocessor mode when sources contain time macros + export CCACHE_SLOPPINESS=time_macros + fi + + export PATH="${PATH}:${srcdir:?}/brave-browser/src/brave/vendor/depot_tools" + + export CC=clang + export CXX=clang++ + export AR=llvm-ar + export NM=llvm-nm + + if [ "$USE_SCCACHE" -eq "1" ]; then + echo "sccache = /usr/bin/sccache" >> .npmrc + fi + + # TODO: Upstream re-distribute permissions, see https://community.brave.com/t/does-brave-allow-the-distribution-of-self-compiled-or-distro-compiled-binaries + echo "brave_services_key = qjVKcxtUybh8WpKNoQ7EbgbkJTMu7omjDHKk=VrPApb8PwJyPE9eqchxedTsMEWg" > .npmrc + echo "brave_variations_server_url = https://variations.brave.com/seed" >> .npmrc + echo "brave_stats_updater_url = https://laptop-updates.brave.com" >> .npmrc + echo "brave_stats_api_key = fe033168-0ff8-4af6-9a7f-95e2cbfc9f4f" >> .npmrc + echo "brave_sync_endpoint = https://sync-v2.brave.com/v2" >> .npmrc + echo "updater_dev_endpoint = https://go-updater-dev.bravesoftware.com/extensions" >> .npmrc + echo "updater_prod_endpoint = https://go-updater.brave.com/extensions" >> .npmrc + echo "rewards_grant_dev_endpoint = https://grant.rewards.brave.com" >> .npmrc + echo "rewards_grant_staging_endpoint = https://grant.rewards.brave.com" >> .npmrc + echo "rewards_grant_prod_endpoint = https://grant.rewards.brave.com" >> .npmrc + echo "sardine_client_id = 7ca8433c-7e61-4e25-b76e-25aa2da68df1" >> .npmrc + echo "sardine_client_secret = 7ca8433c-7e61-4e25-b76e-25aa2da68df1" >> .npmrc + echo "brave_zero_ex_api_key = xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx" >> .npmrc + echo "p3a_json_upload_url = https://example.com" >> .npmrc + echo "p3a_creative_upload_url = https://example.com" >> .npmrc + echo "p3a_constellation_upload_url = https://example.com" >> .npmrc + echo "p2a_json_upload_url = https://example.com" >> .npmrc + echo "star_randomness_host = https://example.com" >> .npmrc + echo "brave_ai_chat_endpoint = https://example.com" >> .npmrc + echo "bitflyer_production_client_id = xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx" >>.npmrc + echo "bitflyer_production_client_secret = xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx" >>.npmrc + echo "bitflyer_production_fee_address = https://example.com" >>.npmrc + echo "bitflyer_production_url = https://example.com" >>.npmrc + echo "gemini_production_api_url = https://api.gemini.com/v1" >> .npmrc + echo "gemini_production_client_id = 6d8d9473ed20be627f71ed46e207f40c004c5b1a" >> .npmrc + echo "gemini_production_client_secret = xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx" >> .npmrc + echo "gemini_production_fee_address = https://example.com" >>.npmrc + echo "gemini_production_oauth_url = https://api.gemini.com/v1/oauth" >> .npmrc + echo "uphold_production_api_url = https://example.com" >> .npmrc + echo "uphold_production_client_id = 6d8d9473ed20be627f71ed46e207f40c004c5b1a" >> .npmrc + echo "uphold_production_client_secret = xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx" >> .npmrc + echo "uphold_production_fee_address = https://example.com" >>.npmrc + echo "uphold_production_oauth_url = https://example.com" >> .npmrc + echo "zebpay_production_api_url = https://example.com" >>.npmrc + echo "zebpay_production_client_id = xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx" >>.npmrc + echo "zebpay_production_client_secret = xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx" >>.npmrc + echo "zebpay_production_oauth_url = https://example.com" >>.npmrc + + npm_args=() + if [ "$COMPONENT" = "4" ]; then + local _rustc_version="$(rustc -V)" + local _flags=( + 'custom_toolchain="//build/toolchain/linux/unbundle:default"' + 'host_toolchain="//build/toolchain/linux/unbundle:default"' + 'clang_base_path="/usr"' + 'clang_use_chrome_plugins=false' + 'rust_sysroot_absolute="/usr"' + 'rustup_home="/usr"' + 'symbol_level=0' # sufficient for backtraces on x86(_64) + 'chrome_pgo_phase=0' # needs newer clang to read the bundled PGO profile + 'treat_warnings_as_errors=false' + 'disable_fieldtrial_testing_config=true' + 'blink_enable_generated_code_formatting=false' + 'ffmpeg_branding="Chrome"' + 'proprietary_codecs=true' + 'rtc_use_pipewire=true' + 'link_pulseaudio=true' + 'use_sysroot=false' + 'use_system_libffi=true' + 'use_custom_libcxx=false' + 'enable_hangout_services_extension=true' + 'enable_widevine=true' + 'enable_nacl=false' + ) + + if [[ -n ${_system_libs[icu]+set} ]]; then + _flags+=('icu_use_data_file=false') + fi + + # This specific tool requires to be built outside of an official build + printf "%s\n" "${_flags[@]}" "rustc_version=\"$_rustc_version\"" >> src/brave/tools/redirect_cc/args.gni + + _flags+=('is_official_build=true') # implies is_cfi=true on x86_64 + + # Facilitate deterministic builds (taken from build/config/compiler/BUILD.gn) + CFLAGS+=' -Wno-builtin-macro-redefined' + CXXFLAGS+=' -Wno-builtin-macro-redefined' + CPPFLAGS+=' -D__DATE__= -D__TIME__= -D__TIMESTAMP__=' + + # Do not warn about unknown warning options + CFLAGS+=' -Wno-unknown-warning-option' + CXXFLAGS+=' -Wno-unknown-warning-option' + + npm_args+=( + "--gn=rustc_version:\"$_rustc_version\"" + $(printf "%s\n" "${_flags[@]}" | sed -e 's/=/:/' -e 's/^/--gn=/') + ) + fi + + # Let Chromium set its own symbol level + CFLAGS=${CFLAGS/-g } + CXXFLAGS=${CXXFLAGS/-g } + + # https://github.com/ungoogled-software/ungoogled-chromium-archlinux/issues/123 + CFLAGS=${CFLAGS/-fexceptions} + CFLAGS=${CFLAGS/-fcf-protection} + CXXFLAGS=${CXXFLAGS/-fexceptions} + CXXFLAGS=${CXXFLAGS/-fcf-protection} + + # This appears to cause random segfaults when combined with ThinLTO + # https://bugs.archlinux.org/task/73518 + CFLAGS=${CFLAGS/-fstack-clash-protection} + CXXFLAGS=${CXXFLAGS/-fstack-clash-protection} + + # https://crbug.com/957519#c122 + CXXFLAGS=${CXXFLAGS/-Wp,-D_GLIBCXX_ASSERTIONS} + + ## See explanation on top to select your build + local _build_type + case $COMPONENT in + 0) + echo "Normal build (with debug)" + ;; + 2) + echo "Static build" + _build_type=Static + ;; + 3) + echo "Debug build" + _build_type=Debug + ;; + 4) + echo "Release custom build" + _build_type=Release + ;; + 1|*) + echo "Release build" + _build_type=Release + ;; + esac + + npm run build ${_build_type} -- "${npm_args[@]}" + npm run build ${_build_type} -- --target chrome_sandbox "${npm_args[@]}" + npm run build ${_build_type} -- --target chromedriver.unstripped "${npm_args[@]}" +} + +package() { + cd chromium-launcher-$_launcher_ver + make PREFIX=/usr DESTDIR="$pkgdir" CHROMIUM_NAME=brave install + + install -Dm644 LICENSE \ + "$pkgdir/usr/share/licenses/$pkgname/LICENSE.launcher" + + install -dm755 "$pkgdir/usr/lib/$pkgname/"{,locales,resources} + + # Copy necessary release files + cd ../brave-browser/src + + install -Dm755 out/Release/$pkgname "$pkgdir/usr/lib/$pkgname/$pkgname" + install -Dm755 out/Release/chromedriver.unstripped "$pkgdir/usr/bin/bravedriver" + install -Dm4755 out/Release/chrome_sandbox "$pkgdir/usr/lib/$pkgname/chrome-sandbox" + ln -s $pkgname "$pkgdir/usr/bin/$pkgname-browser" + ln -s $pkgname "$pkgdir/usr/lib/$pkgname/$pkgname-browser" + + install -Dm644 chrome/installer/linux/common/desktop.template \ + "$pkgdir/usr/share/applications/$pkgname-browser.desktop" + sed -i \ + -e 's/@@MENUNAME@@/Brave/g' \ + -e 's/@@PACKAGE@@/brave/g' \ + -e 's/@@USR_BIN_SYMLINK_NAME@@/brave/g' \ + "$pkgdir/usr/share/applications/$pkgname-browser.desktop" + + install -Dm644 chrome/installer/linux/common/chromium-browser/chromium-browser.appdata.xml \ + "$pkgdir/usr/share/metainfo/$pkgname-browser.appdata.xml" + sed -ni \ + -e 's/chromium-browser\.desktop/brave-browser.desktop/' \ + -e '//d' \ + -e '/

/N;/

\n.*\(We invite\|Chromium supports Vorbis\)/,/<\/p>/d' \ + -e '/^ python3_bin_reldir.txt +- ln -sf /usr/bin/python3 python3 ++ export PATH+=":$PWD/depot_tools" DEPOT_TOOLS_UPDATE=0 ++ export VPYTHON_BYPASS='manually managed python not supported by chrome operations' + +- cd ../brave-browser ++ echo "Putting together brave sources" ++ # Generate gclient gn args file and prepare-brave-source-tree.sh ++ python makepkg-source-roller.py generate brave/DEPS $pkgname ++ rbash prepare-brave-source-tree.sh "$CARCH" + +- export DEPOT_TOOLS_UPDATE=0 +- export PATH="${PATH}:${srcdir:?}/depot_tools" +- +- echo "Prepare the environment..." ++ cd brave-browser + npm install + +- cp -r ../brave src +- cp -r ../depot_tools src/brave/vendor ++ mv ../brave src ++ mv ../depot_tools src/brave/vendor + + cd src/brave || exit + +- if [ "$COMPONENT" = "4" ]; then +- patch -Np1 -i "${srcdir}/system-rust-utils.patch" +- fi ++ patch -Np1 -i "${srcdir}/sync-brave-flag.patch" + + jq ".config.projects.chrome.repository.url = \"file://${srcdir}/chromium-mirror@${_chromium_ver}\"" package.json > tmp.json + mv {tmp,package}.json +@@ -228,23 +389,21 @@ prepare() { + patch -Np1 -i "${srcdir}/use-oauth2-client-switches-as-default.patch" + + # Upstream fixes +- patch -Np1 -i "${srcdir}/add-some-typename-s-that-are-required-in-C-17.patch" ++ patch -Np1 -i "${srcdir}/add-memory-for-std-unique_ptr-in-third_party-ip.patch" ++ patch -Np1 -i "${srcdir}/roll-src-third_party-libavif-src-b33d9ebfc.676aded35.patch" + + # Revert addition of compiler flag that needs newer clang + patch -Rp1 -i "${srcdir}/REVERT-disable-autoupgrading-debug-info.patch" + +- # Disable kGlobalMediaControlsCastStartStop by default +- # https://crbug.com/1314342 +- patch -Np1 -i "${srcdir}/disable-GlobalMediaControlsCastStartStop.patch" +- + # Build fixes +- patch -Np1 -i "${srcdir}/download-bubble-typename.patch" +- patch -Np1 -i "${srcdir}/webauthn-variant.patch" +- patch -Np1 -i "${srcdir}/random-fixes-for-gcc13.patch" ++ patch -Np0 -i "${srcdir}/material-color-utilities-cmath.patch" ++ ++ # Fixes for building with libstdc++ instead of libc++ ++ patch -Np1 -i "${srcdir}/patches/chromium-114-maldoca-include.patch" ++ patch -Np1 -i "${srcdir}/patches/chromium-114-ruy-include.patch" ++ patch -Np1 -i "${srcdir}/patches/chromium-114-vk_mem_alloc-include.patch" + +- # Rust fixes +- patch -Np1 -i "${srcdir}/0001-Fix-Rust-linking-on-component-and-debug-Windows-builds.patch" +- patch -Np1 -i "${srcdir}/0002-Remove-the-prebuilt-toolchain-from-the-Android-team.patch" ++ patch -Np1 -i "${srcdir}/patches/chromium-117-system-zstd.patch" + + # Hacky patching + sed -e 's/\(enable_distro_version_check =\) true/\1 false/g' -i chrome/installer/linux/BUILD.gn +@@ -311,14 +471,6 @@ build() { + echo "rewards_grant_dev_endpoint = https://grant.rewards.brave.com" >> .npmrc + echo "rewards_grant_staging_endpoint = https://grant.rewards.brave.com" >> .npmrc + echo "rewards_grant_prod_endpoint = https://grant.rewards.brave.com" >> .npmrc +- echo "uphold_client_id = 6d8d9473ed20be627f71ed46e207f40c004c5b1a" >> .npmrc +- echo "uphold_client_secret = xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx" >> .npmrc +- echo "uphold_staging_client_id = 4c2b665ca060d912fec5c735c734859a06118cc8" >> .npmrc +- echo "uphold_staging_client_secret = xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx" >> .npmrc +- echo "gemini_api_url = https://api.gemini.com/v1" >> .npmrc +- echo "gemini_oauth_url = https://api.gemini.com/v1/oauth" >> .npmrc +- echo "gemini_wallet_client_id = 6d8d9473ed20be627f71ed46e207f40c004c5b1a" >> .npmrc +- echo "gemini_wallet_client_secret = xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx" >> .npmrc + echo "sardine_client_id = 7ca8433c-7e61-4e25-b76e-25aa2da68df1" >> .npmrc + echo "sardine_client_secret = 7ca8433c-7e61-4e25-b76e-25aa2da68df1" >> .npmrc + echo "brave_zero_ex_api_key = xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx" >> .npmrc +@@ -327,6 +479,25 @@ build() { + echo "p3a_constellation_upload_url = https://example.com" >> .npmrc + echo "p2a_json_upload_url = https://example.com" >> .npmrc + echo "star_randomness_host = https://example.com" >> .npmrc ++ echo "brave_ai_chat_endpoint = https://example.com" >> .npmrc ++ echo "bitflyer_production_client_id = xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx" >>.npmrc ++ echo "bitflyer_production_client_secret = xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx" >>.npmrc ++ echo "bitflyer_production_fee_address = https://example.com" >>.npmrc ++ echo "bitflyer_production_url = https://example.com" >>.npmrc ++ echo "gemini_production_api_url = https://api.gemini.com/v1" >> .npmrc ++ echo "gemini_production_client_id = 6d8d9473ed20be627f71ed46e207f40c004c5b1a" >> .npmrc ++ echo "gemini_production_client_secret = xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx" >> .npmrc ++ echo "gemini_production_fee_address = https://example.com" >>.npmrc ++ echo "gemini_production_oauth_url = https://api.gemini.com/v1/oauth" >> .npmrc ++ echo "uphold_production_api_url = https://example.com" >> .npmrc ++ echo "uphold_production_client_id = 6d8d9473ed20be627f71ed46e207f40c004c5b1a" >> .npmrc ++ echo "uphold_production_client_secret = xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx" >> .npmrc ++ echo "uphold_production_fee_address = https://example.com" >>.npmrc ++ echo "uphold_production_oauth_url = https://example.com" >> .npmrc ++ echo "zebpay_production_api_url = https://example.com" >>.npmrc ++ echo "zebpay_production_client_id = xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx" >>.npmrc ++ echo "zebpay_production_client_secret = xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx" >>.npmrc ++ echo "zebpay_production_oauth_url = https://example.com" >>.npmrc + + npm_args=() + if [ "$COMPONENT" = "4" ]; then +@@ -346,7 +516,6 @@ build() { + 'proprietary_codecs=true' + 'rtc_use_pipewire=true' + 'link_pulseaudio=true' +- 'use_gnome_keyring=false' + 'use_sysroot=false' + 'use_system_libffi=true' + 'use_custom_libcxx=false' diff --git a/brave/brave-1.43-bitcoin-core_remove-serialize.h.patch b/brave/brave-1.43-bitcoin-core_remove-serialize.h.patch index 48d1ee4f6..52fda89da 100644 --- a/brave/brave-1.43-bitcoin-core_remove-serialize.h.patch +++ b/brave/brave-1.43-bitcoin-core_remove-serialize.h.patch @@ -1,37 +1,3 @@ -diff --git a/brave/chromium_src/brave/third_party/bitcoin-core/src/src/serialize.h b/brave/chromium_src/brave/third_party/bitcoin-core/src/src/serialize.h -deleted file mode 100644 -index 268f01f024..0000000000 ---- a/brave/chromium_src/brave/third_party/bitcoin-core/src/src/serialize.h -+++ /dev/null -@@ -1,28 +0,0 @@ --/* Copyright (c) 2021 The Brave Authors. All rights reserved. -- * This Source Code Form is subject to the terms of the Mozilla Public -- * License, v. 2.0. If a copy of the MPL was not distributed with this file, -- * You can obtain one at http://mozilla.org/MPL/2.0/. */ -- --#ifndef BRAVE_CHROMIUM_SRC_BRAVE_THIRD_PARTY_BITCOIN_CORE_SRC_SRC_SERIALIZE_H_ --#define BRAVE_CHROMIUM_SRC_BRAVE_THIRD_PARTY_BITCOIN_CORE_SRC_SRC_SERIALIZE_H_ -- --#include --#include -- --#include "base/check.h" -- --namespace std { --namespace brave { --using string = ::std::string; --} --} // namespace std -- --#define throw CHECK(false) << --#define ios_base brave --#define failure string --#include "src/brave/third_party/bitcoin-core/src/src/serialize.h" // IWYU pragma: export --#undef throw --#undef ios_base --#undef string -- --#endif // BRAVE_CHROMIUM_SRC_BRAVE_THIRD_PARTY_BITCOIN_CORE_SRC_SRC_SERIALIZE_H_ diff --git a/brave/third_party/bitcoin-core/src/src/serialize.h b/brave/third_party/bitcoin-core/src/src/serialize.h index d9ca984f9..f23f8c412 100644 --- a/brave/third_party/bitcoin-core/src/src/serialize.h diff --git a/brave/brave-patches-brave-1.28-patches-1.zip b/brave/brave-patches-brave-1.28-patches-1.zip new file mode 100644 index 000000000..4dba89b1e Binary files /dev/null and b/brave/brave-patches-brave-1.28-patches-1.zip differ diff --git a/brave/chromium-106-patchset-1.tar.xz b/brave/chromium-106-patchset-1.tar.xz new file mode 100644 index 000000000..50fd9bf39 Binary files /dev/null and b/brave/chromium-106-patchset-1.tar.xz differ diff --git a/brave/chromium-launcher-8.tar.gz b/brave/chromium-launcher-8.tar.gz new file mode 100644 index 000000000..491e6d7ad Binary files /dev/null and b/brave/chromium-launcher-8.tar.gz differ diff --git a/brave/makepkg-source-roller.py b/brave/makepkg-source-roller.py new file mode 100644 index 000000000..04c22d9fc --- /dev/null +++ b/brave/makepkg-source-roller.py @@ -0,0 +1,408 @@ +from collections import OrderedDict +from importlib.util import spec_from_loader, module_from_spec +from importlib.machinery import SourceFileLoader +from tempfile import NamedTemporaryFile +from heapq import heappush +import sys +import requests +import base64 +import json +import re +import os + + +def eprint(*args, **kwargs): + print(*args, file=sys.stderr, **kwargs) + + +def fetch_deps(url, rev): + # Get the DEPS file from the given URL and revision + if "googlesource.com" in url: + response = requests.get(f"{url}/+/{rev}/DEPS?format=text") + response.raise_for_status() + return base64.b64decode(response.text).decode("utf-8") + elif url.startswith("https://github.com/"): + if url.endswith(".git"): + url = url[: -len(".git")] + response = requests.get(f"{url}/raw/{rev}/DEPS") + response.raise_for_status() + return response.text + else: + raise Exception(f"Unimplemented for URL {url}") + + +class Str: + def __init__(self, s): + self.inner = s + + def __str__(self): + return self.inner + + +ignored_dep_prefix = [ + # MacOS specific + "src/third_party/squirrel.mac", + # Unnecessary parts + "src/docs/website", +] + + +def parse_deps(path, prefix="", is_src=False, vars=None, reverse_map=None): + """ + path: Path to the DEPS file + prefix: Prefix to add when using recursedeps + is_src: Whether the current DEPS file is the one from "src" repo + vars: Override variables when generating gclient gn args file + reverse_map: Map from url to path. Used for de-duplication + """ + spec = spec_from_loader("deps", SourceFileLoader("deps", path)) + deps_module = module_from_spec(spec) + + def var_substitute(var_name): + return deps_module.vars[var_name] + + deps_module.Var = var_substitute + deps_module.Str = Str + + spec.loader.exec_module(deps_module) + + for k in ( + "checkout_win", + "checkout_mac", + "checkout_ios", + "checkout_chromeos", + "checkout_fuchsia", + "checkout_android", + "checkout_cxx_debugging_extension_deps", + ): + deps_module.vars[k] = False + deps_module.vars["checkout_linux"] = True + deps_module.vars["build_with_chromium"] = True + deps_module.vars["host_os"] = "linux" + use_relative_paths = ( + hasattr(deps_module, "use_relative_paths") and deps_module.use_relative_paths + ) + + def url_and_revision(raw_url): + url = raw_url.format(**deps_module.vars) + url, rev = url.rsplit("@", 1) + if '.googlesource.com/' in url and not url.endswith(".git"): + # Unify url format by adding .git suffix (for de-duplication) + url += ".git" + return (url, rev) + + def format_path(dep_name): + return dep_name if not use_relative_paths else f"{prefix}/{dep_name}" + + real_deps = OrderedDict() + cipd_deps = {} + reverse_map = reverse_map or {} + + def add_dep(dep_name, raw_url): + path = format_path(dep_name) + for ignored_prefix in ignored_dep_prefix: + if path.startswith(ignored_prefix): + eprint(f"Ignoring {path}") + return + url, rev = url_and_revision(raw_url) + real_deps[path] = (url, rev) + # Add to reverse map for de-duplication, use a heap to make sure the shortest path is chosen + heappush(reverse_map.setdefault(url, []), (len(path), path)) + + for dep_name, dep_value in deps_module.deps.items(): + if isinstance(dep_value, dict): + if "dep_type" in dep_value: + if dep_value["dep_type"] == "cipd": + cipd_deps[format_path(dep_name)] = dep_value["packages"] + else: + raise Exception(f"Unknown DEP {dep_name} = {dep_value}") + else: + if "condition" in dep_value and not eval( + dep_value["condition"], vars, deps_module.vars + ): + eprint( + f"Skipping {format_path(dep_name)} because of unmet condition {dep_value['condition']}" + ) + continue + add_dep(dep_name, dep_value["url"]) + elif isinstance(dep_value, str): + add_dep(dep_name, dep_value) + else: + raise Exception(f"Unknown DEP {dep_name} = {dep_value}") + + gclient_gn_args = {} + vars = vars or {} + + if is_src and hasattr(deps_module, "gclient_gn_args"): + for arg in deps_module.gclient_gn_args: + # brave vars overwrites chromium vars + gclient_gn_args[arg] = (deps_module.vars | vars).get(arg) + + if hasattr(deps_module, "recursedeps"): + for dep in deps_module.recursedeps: + if dep not in real_deps: + eprint(f"Skipping recursive DEP {dep} as it's not found in deps dict") + continue + eprint(f"Fetching recursedep {dep}") + deps_text = fetch_deps(*real_deps[dep]) + with NamedTemporaryFile(mode="w", delete=True) as f: + f.write(deps_text) + f.flush() + dep_deps, dep_gclient_gn_args, dep_cipd_deps, _ = parse_deps( + f.name, + format_path(dep), + dep == "src", + deps_module.vars | vars, + reverse_map, + ) + real_deps.update(dep_deps) + gclient_gn_args.update(dep_gclient_gn_args) + cipd_deps.update(dep_cipd_deps) + return real_deps, gclient_gn_args, cipd_deps, reverse_map + + +repos_with_changed_url = { + "https://chromium.googlesource.com/chromium/llvm-project/compiler-rt/lib/fuzzer.git", + "https://chromium.googlesource.com/external/github.com/protocolbuffers/protobuf.git", +} + + +def get_source_path(path, url, pkgname, reverse_map): + """returns the source path and whether it's deduplicated or not""" + deduplicated = False + if len(reverse_map[url]) > 1: + # Deduplicate, choose the shortest path + shortest = reverse_map[url][0][1] + if path != shortest: + eprint(f"Deduplicate: {path} -> {shortest}") + deduplicated = True + path = shortest + flattened = path.replace("/", "_") + result = re.sub("^src", "chromium-mirror", flattened) + if url in repos_with_changed_url: + # To make makepkg happy when using SRCDEST + result += f"_{pkgname}" + return result, deduplicated + + +def generate_fragment(rev): + if "." in rev: + # Treat revisions that contain dot as tags + return f"tag={rev}" + else: + return f"commit={rev}" + + +preferred_url_map = { + # Replace with github mirror + "https://chromium.googlesource.com/chromium/src.git": "https://github.com/chromium/chromium.git", +} + + +def get_preferred_url(url): + preferred_url = preferred_url_map.get(url) + return preferred_url or url + + +def generate_source_list(deps, indent, extra_sources, pkgname, reverse_map): + for path, (url, rev) in deps.items(): + source_path, deduplicated = get_source_path(path, url, pkgname, reverse_map) + if deduplicated: + # Skip the duplicated source + continue + yield f"{indent}{source_path}::git+{get_preferred_url(url)}#{generate_fragment(rev)}" + for s in extra_sources: + yield f"{indent}{s}" + + +def generate_managed_scripts(deps, extra_cmds, pkgname, reverse_map): + script = """#!/usr/bin/env rbash +set -e +# Generated file. Do not modify by hand. +# Usage: script +place_subproject_into_tree () { + # place_subproject_into_tree flattened_path path should_copy + local parent_dir="$(dirname "$2")" + if [[ -n "$parent_dir" ]]; then + mkdir -p "$parent_dir" + fi + # Remove the target dir + rm -rf "$2" + if [[ "$3" == "true" ]]; then + cp -r "$1" "$2" + else + mv -v "$1" "$2" + fi +} + +CARCH="$1" +case "$CARCH" in + x86_64) + _go_arch=amd64;; + *) + _go_arch="$CARCH";; +esac + +""" + for path, (url, rev) in deps.items(): + source_path, deduplicated = get_source_path(path, url, pkgname, reverse_map) + if deduplicated: + shortest = reverse_map[url][0][1] + script += f"place_subproject_into_tree {shortest} {path} true\n" + script += f"git -C {path} checkout --detach {rev}\n" + else: + script += f"place_subproject_into_tree {source_path} {path} false\n" + # Additional Commands + script += "\n".join(extra_cmds) + filename = "prepare-brave-source-tree.sh" + with open(filename, "w") as f: + f.write(script) + return filename + + +def update_pkgbuild(real_deps, reverse_map, extra_sources): + with open("PKGBUILD", "r") as f: + pkgbuild = f.read() + res = re.search( + "([ \t]*)# BEGIN managed sources\n((.|\n)*)([ \t]*)# END managed sources", + pkgbuild, + re.MULTILINE, + ) + if res is None: + raise Exception("managed sources not found") + indent = res.group(1) + span = res.span(2) + pkgbuild = ( + pkgbuild[: span[0]] + + "\n".join( + generate_source_list(real_deps, indent, extra_sources, pkgname, reverse_map) + ) + + "\n" + + indent + + pkgbuild[span[1] :] + ) + + with open("PKGBUILD", "w") as f: + f.write(pkgbuild) + + +def pyobj_to_gn_arg(k, v): + if isinstance(v, Str): + return f'{k} = "{v.inner}"' + elif isinstance(v, str): + return f'{k} = "{v}"' + elif isinstance(v, bool): + return f"{k} = {'true' if v else 'false'}" + else: + raise Exception(f"Cannot convert {k}={v} ({type(v)})to gn arg") + + +def generate_gclient_args(args): + """ + Writes gclient_args.gni + Returns command to copy it + """ + with open("gclient_args.gni", "w") as f: + f.writelines(pyobj_to_gn_arg(k, v) + "\n" for k, v in args.items()) + + return "cp gclient_args.gni src/build/config/gclient_args.gni" + + +def cipd_path_substitute(cipd_path): + # Assume PKGBUILD provides _go_arch variable + return cipd_path.replace("${{platform}}", "linux-${_go_arch}").replace( + "${{arch}}", "${_go_arch}" + ) + + +def generate_cipd_cmds(cipd_deps, enabled_deps): + for dep, is_optional in enabled_deps: + packages = cipd_deps.get(dep) + if packages is None: + if is_optional: + continue + else: + raise f"cipd dependency {dep} not found" + for package in packages: + yield f"cipd install {cipd_path_substitute(package['package'])} {package['version']} -root {dep}" + + +if __name__ == "__main__": + if len(sys.argv) != 4: + eprint(f"Usage: {sys.argv[0]} ACTION PATH_OR_ELECTRON_VERSION PKGNAME") + sys.exit(1) + action = sys.argv[1] + deps_path = sys.argv[2] + pkgname = sys.argv[3] + assert action in ("print", "update", "generate") + if not os.path.exists(deps_path): + # Get it from web + response = requests.get( + f"https://github.com/brave/brave-core/raw/{deps_path}/DEPS" + ) + response.raise_for_status() + deps_text = response.text + with NamedTemporaryFile(mode="w", delete=True) as f: + f.write(deps_text) + f.flush() + git_deps, gargs, cipd_deps, reverse_map = parse_deps(f.name, "src/brave") + response = requests.get( + f"https://github.com/brave/brave-core/raw/{deps_path}/package.json" + ) + response.raise_for_status() + package_json = response.json() + chromium_url = "https://github.com/chromium/chromium.git" + chromium_version = package_json["config"]["projects"]["chrome"]["tag"] + git_deps["src"] = (chromium_url, chromium_version) + heappush(reverse_map.setdefault(chromium_url, []), (len("src"), "src")) + response = requests.get( + f"https://github.com/chromium/chromium/raw/{chromium_version}/DEPS" + ) + deps_text = response.text + with NamedTemporaryFile(mode="w", delete=True) as f: + f.write(deps_text) + f.flush() + more_git_deps, more_gargs, more_cipd_deps, reverse_map = parse_deps(f.name, reverse_map=reverse_map) + git_deps |= more_git_deps + gargs |= more_gargs + cipd_deps |= more_cipd_deps + else: + git_deps, gargs, cipd_deps, reverse_map = parse_deps(deps_path, "src/brave") + deps_dir = os.path.dirname(deps_path) + chromium_url = "https://github.com/chromium/chromium.git" + with open(deps_dir + "/package.json") as f: + package_json = json.load(f) + chromium_version = package_json["config"]["projects"]["chrome"]["tag"] + git_deps["src"] = (chromium_url, chromium_version) + heappush(reverse_map.setdefault(chromium_url, []), (len("src"), "src")) + deps_path = os.path.join(os.path.dirname(deps_dir), "chromium-mirror", "DEPS") + more_git_deps, more_gargs, more_cipd_deps, reverse_map = parse_deps(deps_path, reverse_map=reverse_map) + git_deps |= more_git_deps + gargs |= more_gargs + cipd_deps |= more_cipd_deps + if action == "print": + for name, value in git_deps.items(): + print(f"git: {name} = {value}") + for name, value in cipd_deps.items(): + print(f"cipd: {name} = {value}") + elif action == "update": + update_pkgbuild(git_deps, reverse_map, []) + elif action == "generate": + garg_cmd = generate_gclient_args(gargs) + # cipd dependencies are usually binary blobs. Only add the necessary parts. + cipd_cmds = generate_cipd_cmds( + cipd_deps, + [ + # (dependency path, is_optional) + ( + "src/third_party/screen-ai/linux", + True, + ), # only for new electron versions (probably >= 29) + # The esbuild version 0.14.13 is not compatible with the system one + ("src/third_party/devtools-frontend/src/third_party/esbuild", False), + ], + ) + managed_script = generate_managed_scripts( + git_deps, [garg_cmd] + list(cipd_cmds), pkgname, reverse_map + ) + print("Done") diff --git a/brave/system-rust-utils.patch b/brave/system-rust-utils.patch deleted file mode 100644 index 64c41c626..000000000 --- a/brave/system-rust-utils.patch +++ /dev/null @@ -1,46 +0,0 @@ -diff --git a/script/cargo.py b/script/cargo.py -index 0766c5f118..8ed8893272 100755 ---- a/script/cargo.py -+++ b/script/cargo.py -@@ -16,8 +16,8 @@ def run_cargo(command, args): - env = os.environ.copy() - - rustup_home = args.rustup_home -- env['RUSTUP_HOME'] = rustup_home -- env['CARGO_HOME'] = rustup_home -+ # env['RUSTUP_HOME'] = rustup_home -+ # env['CARGO_HOME'] = rustup_home - # Enable experimental features in non-nightly builds - env['RUSTC_BOOTSTRAP'] = '1' - -diff --git a/script/cargo_cbindgen.py b/script/cargo_cbindgen.py -index db28fd013e..78a9dd9481 100755 ---- a/script/cargo_cbindgen.py -+++ b/script/cargo_cbindgen.py -@@ -15,10 +15,10 @@ def run(args): - env = os.environ.copy() - - rustup_home = args.rustup_home -- env["RUSTUP_HOME"] = rustup_home -+ # env["RUSTUP_HOME"] = rustup_home - - cargo_home = args.cargo_home -- env["CARGO_HOME"] = cargo_home -+ # env["CARGO_HOME"] = cargo_home - - rustup_bin = os.path.abspath(os.path.join(rustup_home, "bin")) - cbindgen_bin = os.path.join( -diff --git a/script/download_rust_deps.py b/script/download_rust_deps.py -index 60ff491eb9..94521879c6 100755 ---- a/script/download_rust_deps.py -+++ b/script/download_rust_deps.py -@@ -203,7 +203,8 @@ def main(): - "features": "vendored-openssl", - }] - for tool in tools: -- cargo_install(tool, rustup_home) -+ if shutil.which(tool["name"]) is None: -+ cargo_install(tool, rustup_home) - - return 0 -