From e48050e78bb129c62bedec58c098c37e8cbf8a11 Mon Sep 17 00:00:00 2001 From: Antoine Martin Date: Sat, 13 Sep 2025 09:38:17 -0400 Subject: [PATCH 1/2] backports/electron: upgrade to 37.5.0 --- ...l_allocator-to-provide-Rust-allocato.patch | 730 ------------------ ...default-allocator-directly-from-Rust.patch | 319 -------- ...7b43542838f0a4a6cfdb17fbeadf45002042.patch | 102 --- .../electron/0004-Drop-remap_alloc-dep.patch | 44 -- ...ild-rust-allocator-after-a-Rust-tool.patch | 354 --------- backports/electron/APKBUILD | 36 +- backports/electron/compiler.patch | 61 +- .../electron_do-not-strip-binaries.patch | 1 - backports/electron/pipewire-1.4.patch | 23 - ...> rust_no_alloc_shim_is_unstable_v2.patch} | 0 10 files changed, 62 insertions(+), 1608 deletions(-) delete mode 100644 backports/electron/0001-Reland-Use-global_allocator-to-provide-Rust-allocato.patch delete mode 100644 backports/electron/0002-Call-Rust-default-allocator-directly-from-Rust.patch delete mode 100644 backports/electron/0003-Roll-rust-only-f7b43542838f0a4a6cfdb17fbeadf45002042.patch delete mode 100644 backports/electron/0004-Drop-remap_alloc-dep.patch delete mode 100644 backports/electron/0005-rust-Clean-up-build-rust-allocator-after-a-Rust-tool.patch delete mode 100644 backports/electron/pipewire-1.4.patch rename backports/electron/{0006-Define-__rust_no_alloc_shim_is_unstable_v2.patch => rust_no_alloc_shim_is_unstable_v2.patch} (100%) diff --git a/backports/electron/0001-Reland-Use-global_allocator-to-provide-Rust-allocato.patch b/backports/electron/0001-Reland-Use-global_allocator-to-provide-Rust-allocato.patch deleted file mode 100644 index 580323c..0000000 --- a/backports/electron/0001-Reland-Use-global_allocator-to-provide-Rust-allocato.patch +++ /dev/null @@ -1,730 +0,0 @@ -From c854a92a215d0cf39c704bbadd3611e552073d5f Mon Sep 17 00:00:00 2001 -From: Collin Baker -Date: Fri, 4 Apr 2025 14:08:18 -0700 -Subject: [PATCH] Reland "Use #[global_allocator] to provide Rust allocator - implementation" -MIME-Version: 1.0 -Content-Type: text/plain; charset=UTF-8 -Content-Transfer-Encoding: 8bit - -This is a reland of commit cfa3beef52625e03ba6ce2b2ac98e1b89dde5cdb - -Original was reverted due to a cronet gn2bp failure. The script -filtered out GN rules in //build/rust/std, but this caused an exception -when //build/rust/std:allocator was referenced later. - -Moving the rules to //build/rust/allocator sidesteps the issue. - -Original change's description: -> Use #[global_allocator] to provide Rust allocator implementation -> -> The allocator shim hack we have been using no longer works with -> upstream Rust. Replace it with a less-unsupported method: provide a -> https://github.com/rust-lang/rust/issues/123015, which still requires -> us to provide a few symbol definitions. -> -> Bug: 408221149, 407024458 -> Change-Id: If1808ca24b12dc80ead35a25521313a3d2e148d5 -> -> Cq-Include-Trybots: luci.chromium.try:android-rust-arm32-rel,android-rust-arm64-dbg,android-rust-arm64-rel,linux-rust-x64-dbg,linux-rust-x64-rel,mac-rust-x64-dbg,win-rust-x64-dbg,win-rust-x64-rel -> Change-Id: If1808ca24b12dc80ead35a25521313a3d2e148d5 -> Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/6427855 -> Reviewed-by: Alan Zhao -> Reviewed-by: Lei Zhang -> Reviewed-by: Łukasz Anforowicz -> Commit-Queue: Collin Baker -> Auto-Submit: Collin Baker -> Cr-Commit-Position: refs/heads/main@{#1442472} - -Bug: 408221149, 407024458 -Cq-Include-Trybots: luci.chromium.try:android-rust-arm32-rel,android-rust-arm64-dbg,android-rust-arm64-rel,linux-rust-x64-dbg,linux-rust-x64-rel,mac-rust-x64-dbg,win-rust-x64-dbg,win-rust-x64-rel -Change-Id: I36fef217297bfe64ae81519be24b8c653f6fdfa1 -Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/6432410 -Reviewed-by: Mohannad Farrag -Reviewed-by: Łukasz Anforowicz -Auto-Submit: Collin Baker -Commit-Queue: Łukasz Anforowicz -Cr-Commit-Position: refs/heads/main@{#1442922} ---- - build/rust/allocator/BUILD.gn | 90 ++++++++++++++++ - build/rust/{std => allocator}/alias.cc | 4 +- - build/rust/{std => allocator}/alias.h | 6 +- - .../allocator_impls.cc} | 100 ++++++++---------- - build/rust/allocator/allocator_impls.h | 25 +++++ - .../allocator/allocator_shim_definitions.cc | 30 ++++++ - .../{std => allocator}/compiler_specific.h | 6 +- - .../rust/{std => allocator}/immediate_crash.h | 6 +- - build/rust/allocator/lib.rs | 48 +++++++++ - build/rust/cargo_crate.gni | 9 ++ - build/rust/rust_macro.gni | 3 + - build/rust/rust_target.gni | 4 + - build/rust/std/BUILD.gn | 41 ------- - components/cronet/android/dependencies.txt | 1 + - third_party/breakpad/BUILD.gn | 10 +- - 15 files changed, 272 insertions(+), 111 deletions(-) - create mode 100644 build/rust/allocator/BUILD.gn - rename build/rust/{std => allocator}/alias.cc (87%) - rename build/rust/{std => allocator}/alias.h (91%) - rename build/rust/{std/remap_alloc.cc => allocator/allocator_impls.cc} (67%) - create mode 100644 build/rust/allocator/allocator_impls.h - create mode 100644 build/rust/allocator/allocator_shim_definitions.cc - rename build/rust/{std => allocator}/compiler_specific.h (87%) - rename build/rust/{std => allocator}/immediate_crash.h (97%) - create mode 100644 build/rust/allocator/lib.rs - -diff --git a/build/rust/allocator/BUILD.gn b/build/rust/allocator/BUILD.gn -new file mode 100644 -index 0000000000000..06aa47f097c9c ---- /dev/null -+++ b/build/rust/allocator/BUILD.gn -@@ -0,0 +1,90 @@ -+# Copyright 2025 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/buildflag_header.gni") -+import("//build/config/rust.gni") -+import("//build/rust/rust_static_library.gni") -+ -+rust_allocator_uses_partition_alloc = false -+if (build_with_chromium) { -+ import("//base/allocator/partition_allocator/partition_alloc.gni") -+ rust_allocator_uses_partition_alloc = use_partition_alloc_as_malloc -+} -+ -+buildflag_header("buildflags") { -+ header = "buildflags.h" -+ flags = [ -+ "RUST_ALLOCATOR_USES_PARTITION_ALLOC=$rust_allocator_uses_partition_alloc", -+ ] -+ visibility = [ ":*" ] -+} -+ -+if (toolchain_has_rust) { -+ # All targets which depend on Rust code but are not linked by rustc must -+ # depend on this. Usually, this dependency will come from the rust_target() GN -+ # template. However, cargo_crate() does *not* include this dependency so any -+ # C++ targets which directly depend on a cargo_crate() must depend on this. -+ rust_static_library("allocator") { -+ sources = [ "lib.rs" ] -+ crate_root = "lib.rs" -+ cxx_bindings = [ "lib.rs" ] -+ -+ deps = [ -+ ":allocator_impls", -+ ":allocator_shim_definitions", -+ ] -+ -+ no_chromium_prelude = true -+ no_allocator_crate = true -+ allow_unsafe = true -+ } -+ -+ static_library("allocator_impls") { -+ public_deps = [] -+ if (rust_allocator_uses_partition_alloc) { -+ public_deps += [ "//base/allocator/partition_allocator:partition_alloc" ] -+ } -+ -+ sources = [ -+ "allocator_impls.cc", -+ "allocator_impls.h", -+ ] -+ -+ deps = [ -+ ":allocator_cpp_shared", -+ ":buildflags", -+ -+ # TODO(crbug.com/408221149): remove the C++ -> Rust dependency for the -+ # default allocator. -+ "//build/rust/std", -+ ] -+ -+ visibility = [ ":*" ] -+ } -+ -+ source_set("allocator_shim_definitions") { -+ sources = [ "allocator_shim_definitions.cc" ] -+ -+ deps = [ ":allocator_cpp_shared" ] -+ -+ visibility = [ ":*" ] -+ } -+ -+ source_set("allocator_cpp_shared") { -+ sources = [ -+ # `alias.*`, `compiler_specific.h`, and `immediate_crash.*` have been -+ # copied from `//base`. -+ # TODO(crbug.com/40279749): Avoid duplication / reuse code. -+ "alias.cc", -+ "alias.h", -+ "compiler_specific.h", -+ "immediate_crash.h", -+ ] -+ -+ visibility = [ -+ ":allocator_impls", -+ ":allocator_shim_definitions", -+ ] -+ } -+} -diff --git a/build/rust/std/alias.cc b/build/rust/allocator/alias.cc -similarity index 87% -rename from build/rust/std/alias.cc -rename to build/rust/allocator/alias.cc -index 42febac3ed1fc..ca20986f8ed49 100644 ---- a/build/rust/std/alias.cc -+++ b/build/rust/allocator/alias.cc -@@ -7,9 +7,9 @@ - // - // TODO(crbug.com/40279749): Avoid code duplication / reuse code. - --#include "build/rust/std/alias.h" -+#include "build/rust/allocator/alias.h" - --#include "build/rust/std/compiler_specific.h" -+#include "build/rust/allocator/compiler_specific.h" - - namespace build_rust_std { - namespace debug { -diff --git a/build/rust/std/alias.h b/build/rust/allocator/alias.h -similarity index 91% -rename from build/rust/std/alias.h -rename to build/rust/allocator/alias.h -index 0eaba6766148f..80995ecfb045e 100644 ---- a/build/rust/std/alias.h -+++ b/build/rust/allocator/alias.h -@@ -8,8 +8,8 @@ - // - // TODO(crbug.com/40279749): Avoid code duplication / reuse code. - --#ifndef BUILD_RUST_STD_ALIAS_H_ --#define BUILD_RUST_STD_ALIAS_H_ -+#ifndef BUILD_RUST_ALLOCATOR_ALIAS_H_ -+#define BUILD_RUST_ALLOCATOR_ALIAS_H_ - - #include - -@@ -34,4 +34,4 @@ void Alias(const void* var); - const int line_number = __LINE__; \ - build_rust_std::debug::Alias(&line_number) - --#endif // BUILD_RUST_STD_ALIAS_H_ -+#endif // BUILD_RUST_ALLOCATOR_ALIAS_H_ -diff --git a/build/rust/std/remap_alloc.cc b/build/rust/allocator/allocator_impls.cc -similarity index 67% -rename from build/rust/std/remap_alloc.cc -rename to build/rust/allocator/allocator_impls.cc -index a443b11ec513d..1fde98f23cd12 100644 ---- a/build/rust/std/remap_alloc.cc -+++ b/build/rust/allocator/allocator_impls.cc -@@ -2,6 +2,8 @@ - // Use of this source code is governed by a BSD-style license that can be - // found in the LICENSE file. - -+#include "build/rust/allocator/allocator_impls.h" -+ - #ifdef UNSAFE_BUFFERS_BUILD - // TODO(crbug.com/390223051): Remove C-library calls to fix the errors. - #pragma allow_unsafe_libc_calls -@@ -11,9 +13,9 @@ - #include - - #include "build/build_config.h" --#include "build/rust/std/alias.h" --#include "build/rust/std/buildflags.h" --#include "build/rust/std/immediate_crash.h" -+#include "build/rust/allocator/alias.h" -+#include "build/rust/allocator/buildflags.h" -+#include "build/rust/allocator/immediate_crash.h" - - #if BUILDFLAG(RUST_ALLOCATOR_USES_PARTITION_ALLOC) - #include "partition_alloc/partition_alloc_constants.h" // nogncheck -@@ -22,6 +24,11 @@ - #include - #endif - -+// NOTE: this documentation is outdated. -+// -+// TODO(crbug.com/408221149): update this documentation, or replace it with docs -+// in the Rust allocator implementation. -+// - // When linking a final binary, rustc has to pick between either: - // * The default Rust allocator - // * Any #[global_allocator] defined in *any rlib in its dependency tree* -@@ -87,19 +94,6 @@ - // enabling it breaks Win32 APIs like CreateProcess: - // https://issues.chromium.org/u/1/issues/368070343#comment29 - --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 -- - #if !BUILDFLAG(RUST_ALLOCATOR_USES_PARTITION_ALLOC) && BUILDFLAG(IS_WIN) && \ - defined(ADDRESS_SANITIZER) - #define USE_WIN_ALIGNED_MALLOC 1 -@@ -107,17 +101,19 @@ extern "C" { - #define USE_WIN_ALIGNED_MALLOC 0 - #endif - --// This must exist as the stdlib depends on it to prove that we know the --// alloc shims below are unstable. In the future we may be required to replace --// them with a #[global_allocator] crate (see file comment above for more). --// --// Marked as weak as when Rust drives linking it includes this symbol itself, --// and we don't want a collision due to C++ being in the same link target, where --// C++ causes us to explicitly link in the stdlib and this symbol here. --[[maybe_unused]] --__attribute__((weak)) unsigned char __rust_no_alloc_shim_is_unstable; -+// The default allocator functions provided by the Rust standard library. -+extern "C" void* __rdl_alloc(size_t size, size_t align); -+extern "C" void __rdl_dealloc(void* p, size_t size, size_t align); -+extern "C" void* __rdl_realloc(void* p, -+ size_t old_size, -+ size_t align, -+ size_t new_size); -+ -+extern "C" void* __rdl_alloc_zeroed(size_t size, size_t align); -+ -+namespace rust_allocator_internal { - --REMAP_ALLOC_ATTRIBUTES void* __rust_alloc(size_t size, size_t align) { -+unsigned char* alloc(size_t size, size_t align) { - #if BUILDFLAG(RUST_ALLOCATOR_USES_PARTITION_ALLOC) - // PartitionAlloc will crash if given an alignment larger than this. - if (align > partition_alloc::internal::kMaxSupportedAlignment) { -@@ -125,19 +121,19 @@ REMAP_ALLOC_ATTRIBUTES void* __rust_alloc(size_t size, size_t align) { - } - - if (align <= alignof(std::max_align_t)) { -- return allocator_shim::UncheckedAlloc(size); -+ return static_cast(allocator_shim::UncheckedAlloc(size)); - } else { -- return allocator_shim::UncheckedAlignedAlloc(size, align); -+ return static_cast( -+ allocator_shim::UncheckedAlignedAlloc(size, align)); - } - #elif USE_WIN_ALIGNED_MALLOC -- return _aligned_malloc(size, align); -+ return static_cast(_aligned_malloc(size, align)); - #else -- extern void* __rdl_alloc(size_t size, size_t align); -- return __rdl_alloc(size, align); -+ return static_cast(__rdl_alloc(size, align)); - #endif - } - --REMAP_ALLOC_ATTRIBUTES void __rust_dealloc(void* p, size_t size, size_t align) { -+void dealloc(unsigned char* p, size_t size, size_t align) { - #if BUILDFLAG(RUST_ALLOCATOR_USES_PARTITION_ALLOC) - if (align <= alignof(std::max_align_t)) { - allocator_shim::UncheckedFree(p); -@@ -147,54 +143,44 @@ REMAP_ALLOC_ATTRIBUTES void __rust_dealloc(void* p, size_t size, size_t align) { - #elif USE_WIN_ALIGNED_MALLOC - return _aligned_free(p); - #else -- extern void __rdl_dealloc(void* p, size_t size, size_t align); - __rdl_dealloc(p, size, align); - #endif - } - --REMAP_ALLOC_ATTRIBUTES void* __rust_realloc(void* p, -- size_t old_size, -- size_t align, -- size_t new_size) { -+unsigned char* realloc(unsigned char* p, -+ size_t old_size, -+ size_t align, -+ size_t new_size) { - #if BUILDFLAG(RUST_ALLOCATOR_USES_PARTITION_ALLOC) - if (align <= alignof(std::max_align_t)) { -- return allocator_shim::UncheckedRealloc(p, new_size); -+ return static_cast( -+ allocator_shim::UncheckedRealloc(p, new_size)); - } else { -- return allocator_shim::UncheckedAlignedRealloc(p, new_size, align); -+ return static_cast( -+ allocator_shim::UncheckedAlignedRealloc(p, new_size, align)); - } - #elif USE_WIN_ALIGNED_MALLOC -- return _aligned_realloc(p, new_size, align); -+ return static_cast(_aligned_realloc(p, new_size, align)); - #else -- extern void* __rdl_realloc(void* p, size_t old_size, size_t align, -- size_t new_size); -- return __rdl_realloc(p, old_size, align, new_size); -+ return static_cast( -+ __rdl_realloc(p, old_size, align, new_size)); - #endif - } - --REMAP_ALLOC_ATTRIBUTES void* __rust_alloc_zeroed(size_t size, size_t align) { -+unsigned char* alloc_zeroed(size_t size, size_t align) { - #if BUILDFLAG(RUST_ALLOCATOR_USES_PARTITION_ALLOC) || USE_WIN_ALIGNED_MALLOC - // TODO(danakj): When RUST_ALLOCATOR_USES_PARTITION_ALLOC is true, it's - // possible that a partition_alloc::UncheckedAllocZeroed() call would perform - // better than partition_alloc::UncheckedAlloc() + memset. But there is no - // such API today. See b/342251590. -- void* p = __rust_alloc(size, align); -+ unsigned char* p = alloc(size, align); - if (p) { - memset(p, 0, size); - } - return p; - #else -- extern void* __rdl_alloc_zeroed(size_t size, size_t align); -- return __rdl_alloc_zeroed(size, align); -+ return static_cast(__rdl_alloc_zeroed(size, align)); - #endif - } - --REMAP_ALLOC_ATTRIBUTES void __rust_alloc_error_handler(size_t size, -- size_t align) { -- NO_CODE_FOLDING(); -- IMMEDIATE_CRASH(); --} -- --REMAP_ALLOC_ATTRIBUTES extern const unsigned char -- __rust_alloc_error_handler_should_panic = 0; -- --} // extern "C" -+} // namespace rust_allocator_internal -diff --git a/build/rust/allocator/allocator_impls.h b/build/rust/allocator/allocator_impls.h -new file mode 100644 -index 0000000000000..afb335412faf9 ---- /dev/null -+++ b/build/rust/allocator/allocator_impls.h -@@ -0,0 +1,25 @@ -+// Copyright 2025 The Chromium Authors -+// Use of this source code is governed by a BSD-style license that can be -+// found in the LICENSE file. -+ -+#ifndef BUILD_RUST_ALLOCATOR_ALLOCATOR_IMPLS_H_ -+#define BUILD_RUST_ALLOCATOR_ALLOCATOR_IMPLS_H_ -+ -+#include -+ -+#include "build/build_config.h" -+#include "build/rust/allocator/buildflags.h" -+ -+namespace rust_allocator_internal { -+ -+unsigned char* alloc(size_t size, size_t align); -+void dealloc(unsigned char* p, size_t size, size_t align); -+unsigned char* realloc(unsigned char* p, -+ size_t old_size, -+ size_t align, -+ size_t new_size); -+unsigned char* alloc_zeroed(size_t size, size_t align); -+ -+} // namespace rust_allocator_internal -+ -+#endif // BUILD_RUST_ALLOCATOR_ALLOCATOR_IMPLS_H_ -diff --git a/build/rust/allocator/allocator_shim_definitions.cc b/build/rust/allocator/allocator_shim_definitions.cc -new file mode 100644 -index 0000000000000..a4d1bd77b7016 ---- /dev/null -+++ b/build/rust/allocator/allocator_shim_definitions.cc -@@ -0,0 +1,30 @@ -+// Copyright 2025 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 "build/rust/allocator/alias.h" -+#include "build/rust/allocator/immediate_crash.h" -+ -+extern "C" { -+ -+// As part of rustc's contract for using `#[global_allocator]` without -+// rustc-generated shims we must define this symbol, since we are opting in to -+// unstable functionality. See https://github.com/rust-lang/rust/issues/123015 -+// -+// Mark it weak since rustc will generate it when it drives linking. -+[[maybe_unused]] -+__attribute__((weak)) unsigned char __rust_no_alloc_shim_is_unstable; -+ -+__attribute__((weak)) void __rust_alloc_error_handler(size_t size, -+ size_t align) { -+ NO_CODE_FOLDING(); -+ IMMEDIATE_CRASH(); -+} -+ -+__attribute__(( -+ weak)) extern const unsigned char __rust_alloc_error_handler_should_panic = -+ 0; -+ -+} // extern "C" -diff --git a/build/rust/std/compiler_specific.h b/build/rust/allocator/compiler_specific.h -similarity index 87% -rename from build/rust/std/compiler_specific.h -rename to build/rust/allocator/compiler_specific.h -index ea79a7a8dc284..f9079679a3e9a 100644 ---- a/build/rust/std/compiler_specific.h -+++ b/build/rust/allocator/compiler_specific.h -@@ -7,8 +7,8 @@ - // - // TODO(crbug.com/40279749): Avoid code duplication / reuse code. - --#ifndef BUILD_RUST_STD_COMPILER_SPECIFIC_H_ --#define BUILD_RUST_STD_COMPILER_SPECIFIC_H_ -+#ifndef BUILD_RUST_ALLOCATOR_COMPILER_SPECIFIC_H_ -+#define BUILD_RUST_ALLOCATOR_COMPILER_SPECIFIC_H_ - - #include "build/build_config.h" - -@@ -35,4 +35,4 @@ - #define NOINLINE - #endif - --#endif // BUILD_RUST_STD_COMPILER_SPECIFIC_H_ -+#endif // BUILD_RUST_ALLOCATOR_COMPILER_SPECIFIC_H_ -diff --git a/build/rust/std/immediate_crash.h b/build/rust/allocator/immediate_crash.h -similarity index 97% -rename from build/rust/std/immediate_crash.h -rename to build/rust/allocator/immediate_crash.h -index e4fd5a09d9379..9cbf9fd65f3e0 100644 ---- a/build/rust/std/immediate_crash.h -+++ b/build/rust/allocator/immediate_crash.h -@@ -5,8 +5,8 @@ - // This file has been copied from //base/immediate_crash.h. - // TODO(crbug.com/40279749): Avoid code duplication / reuse code. - --#ifndef BUILD_RUST_STD_IMMEDIATE_CRASH_H_ --#define BUILD_RUST_STD_IMMEDIATE_CRASH_H_ -+#ifndef BUILD_RUST_ALLOCATOR_IMMEDIATE_CRASH_H_ -+#define BUILD_RUST_ALLOCATOR_IMMEDIATE_CRASH_H_ - - #include "build/build_config.h" - -@@ -168,4 +168,4 @@ - - #endif // defined(__clang__) || defined(COMPILER_GCC) - --#endif // BUILD_RUST_STD_IMMEDIATE_CRASH_H_ -+#endif // BUILD_RUST_ALLOCATOR_IMMEDIATE_CRASH_H_ -diff --git a/build/rust/allocator/lib.rs b/build/rust/allocator/lib.rs -new file mode 100644 -index 0000000000000..7f4a0fc245694 ---- /dev/null -+++ b/build/rust/allocator/lib.rs -@@ -0,0 +1,48 @@ -+// Copyright 2025 The Chromium Authors -+// Use of this source code is governed by a BSD-style license that can be -+// found in the LICENSE file. -+ -+//! Define the allocator that Rust code in Chrome should use. -+//! -+//! Any final artifact that depends on this crate, even transitively, will use -+//! the allocator defined here. Currently this is a thin wrapper around -+//! allocator_impls.cc's functions; see the documentation there. -+ -+use std::alloc::{GlobalAlloc, Layout}; -+ -+struct Allocator; -+ -+unsafe impl GlobalAlloc for Allocator { -+ unsafe fn alloc(&self, layout: Layout) -> *mut u8 { -+ unsafe { ffi::alloc(layout.size(), layout.align()) } -+ } -+ -+ unsafe fn dealloc(&self, ptr: *mut u8, layout: Layout) { -+ unsafe { -+ ffi::dealloc(ptr, layout.size(), layout.align()); -+ } -+ } -+ -+ unsafe fn alloc_zeroed(&self, layout: Layout) -> *mut u8 { -+ unsafe { ffi::alloc_zeroed(layout.size(), layout.align()) } -+ } -+ -+ unsafe fn realloc(&self, ptr: *mut u8, layout: Layout, new_size: usize) -> *mut u8 { -+ unsafe { ffi::realloc(ptr, layout.size(), layout.align(), new_size) } -+ } -+} -+ -+#[global_allocator] -+static GLOBAL: Allocator = Allocator; -+ -+#[cxx::bridge(namespace = "rust_allocator_internal")] -+mod ffi { -+ extern "C++" { -+ include!("build/rust/allocator/allocator_impls.h"); -+ -+ unsafe fn alloc(size: usize, align: usize) -> *mut u8; -+ unsafe fn dealloc(p: *mut u8, size: usize, align: usize); -+ unsafe fn realloc(p: *mut u8, old_size: usize, align: usize, new_size: usize) -> *mut u8; -+ unsafe fn alloc_zeroed(size: usize, align: usize) -> *mut u8; -+ } -+} -diff --git a/build/rust/cargo_crate.gni b/build/rust/cargo_crate.gni -index 6d11c538bf4d5..d9912722b4ecd 100644 ---- a/build/rust/cargo_crate.gni -+++ b/build/rust/cargo_crate.gni -@@ -259,6 +259,12 @@ template("cargo_crate") { - # Don't import the `chromium` crate into third-party code. - no_chromium_prelude = true - -+ # Don't depend on the chrome-specific #[global_allocator] crate from -+ # third-party code. This avoids some dependency cycle issues. The allocator -+ # crate will still be used if it exists anywhere in the dependency graph for -+ # a given linked artifact. -+ no_allocator_crate = true -+ - rustc_metadata = _rustc_metadata - - # TODO(crbug.com/40259764): don't default to true. This requires changes to -@@ -483,6 +489,9 @@ template("cargo_crate") { - # Don't import the `chromium` crate into third-party code. - no_chromium_prelude = true - -+ # Build scripts do not need to link to chrome's allocator. -+ no_allocator_crate = true -+ - # 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 -diff --git a/build/rust/rust_macro.gni b/build/rust/rust_macro.gni -index bcbb30ed44111..41d857632ccdc 100644 ---- a/build/rust/rust_macro.gni -+++ b/build/rust/rust_macro.gni -@@ -16,6 +16,9 @@ template("rust_macro") { - forward_variables_from(invoker, TESTONLY_AND_VISIBILITY) - proc_macro_configs = invoker.configs - target_type = "rust_proc_macro" -+ -+ # Macros are loaded by rustc and shouldn't use chrome's allocation routines. -+ no_allocator_crate = true - } - } - -diff --git a/build/rust/rust_target.gni b/build/rust/rust_target.gni -index 1a2f96337d436..1003a7b678352 100644 ---- a/build/rust/rust_target.gni -+++ b/build/rust/rust_target.gni -@@ -339,6 +339,10 @@ template("rust_target") { - _rust_deps += [ "//build/rust/std" ] - } - -+ if (!defined(invoker.no_allocator_crate) || !invoker.no_allocator_crate) { -+ _rust_deps += [ "//build/rust/allocator" ] -+ } -+ - if (_build_unit_tests) { - _unit_test_target = "${_target_name}_unittests" - if (defined(invoker.unit_test_target)) { -diff --git a/build/rust/std/BUILD.gn b/build/rust/std/BUILD.gn -index 6b996aa1fe386..25db126076b2f 100644 ---- a/build/rust/std/BUILD.gn -+++ b/build/rust/std/BUILD.gn -@@ -15,51 +15,12 @@ - # allocator functions to PartitionAlloc when `use_partition_alloc_as_malloc` is - # true, so that Rust and C++ use the same allocator backend. - --import("//build/buildflag_header.gni") - import("//build/config/compiler/compiler.gni") - import("//build/config/coverage/coverage.gni") - import("//build/config/rust.gni") - import("//build/config/sanitizers/sanitizers.gni") - --rust_allocator_uses_partition_alloc = false --if (build_with_chromium) { -- import("//base/allocator/partition_allocator/partition_alloc.gni") -- rust_allocator_uses_partition_alloc = use_partition_alloc_as_malloc --} -- --buildflag_header("buildflags") { -- header = "buildflags.h" -- flags = [ -- "RUST_ALLOCATOR_USES_PARTITION_ALLOC=$rust_allocator_uses_partition_alloc", -- ] -- visibility = [ ":*" ] --} -- - if (toolchain_has_rust) { -- # If clang performs the link step, we need to provide the allocator symbols -- # that are normally injected by rustc during linking. -- # -- # We also "happen to" use this to redirect allocations to PartitionAlloc, -- # though that would be better done through a #[global_allocator] crate (see -- # above). -- source_set("remap_alloc") { -- public_deps = [] -- if (rust_allocator_uses_partition_alloc) { -- public_deps += [ "//base/allocator/partition_allocator:partition_alloc" ] -- } -- deps = [ ":buildflags" ] -- sources = [ -- # `alias.*`, `compiler_specific.h`, and `immediate_crash.*` have been -- # copied from `//base`. -- # TODO(crbug.com/40279749): Avoid duplication / reuse code. -- "alias.cc", -- "alias.h", -- "compiler_specific.h", -- "immediate_crash.h", -- "remap_alloc.cc", -- ] -- } -- - # List of Rust stdlib rlibs which are present in the official Rust toolchain - # we are using from the Android team. This is usually a version or two behind - # nightly. Generally this matches the toolchain we build ourselves, but if -@@ -269,8 +230,6 @@ if (toolchain_has_rust) { - foreach(libname, stdlib_files + skip_stdlib_files) { - deps += [ "rules:$libname" ] - } -- -- public_deps = [ ":remap_alloc" ] - } - } else { - action("find_stdlib") { -diff --git a/components/cronet/android/dependencies.txt b/components/cronet/android/dependencies.txt -index bf56bc45ed41f..c0e41ef7c6766 100644 ---- a/components/cronet/android/dependencies.txt -+++ b/components/cronet/android/dependencies.txt -@@ -14,6 +14,7 @@ - //build/config - //build/config/compiler - //build/rust -+//build/rust/allocator - //build/rust/chromium_prelude - //build/rust/std - //build/rust/std/rules -diff --git a/third_party/breakpad/BUILD.gn b/third_party/breakpad/BUILD.gn -index 007fdff16e92e..00da4fa484998 100644 ---- a/third_party/breakpad/BUILD.gn -+++ b/third_party/breakpad/BUILD.gn -@@ -495,7 +495,10 @@ if (is_mac) { - defines = [ "HAVE_MACH_O_NLIST_H" ] - - # Rust demangle support. -- deps = [ "//third_party/rust/rustc_demangle_capi/v0_1:lib" ] -+ deps = [ -+ "//build/rust/allocator", -+ "//third_party/rust/rustc_demangle_capi/v0_1:lib", -+ ] - defines += [ "HAVE_RUSTC_DEMANGLE" ] - include_dirs += [ "//third_party/rust/chromium_crates_io/vendor/rustc-demangle-capi-0.1.0/include" ] - sources += [ "//third_party/rust/chromium_crates_io/vendor/rustc-demangle-capi-0.1.0/include/rustc_demangle.h" ] -@@ -743,7 +746,10 @@ if (is_linux || is_chromeos || is_android) { - include_dirs = [ "breakpad/src" ] - - # Rust demangle support. -- deps = [ "//third_party/rust/rustc_demangle_capi/v0_1:lib" ] -+ deps = [ -+ "//build/rust/allocator", -+ "//third_party/rust/rustc_demangle_capi/v0_1:lib", -+ ] - defines += [ "HAVE_RUSTC_DEMANGLE" ] - include_dirs += [ "//third_party/rust/chromium_crates_io/vendor/rustc-demangle-capi-0.1.0/include" ] - sources += [ "//third_party/rust/chromium_crates_io/vendor/rustc-demangle-capi-0.1.0/include/rustc_demangle.h" ] diff --git a/backports/electron/0002-Call-Rust-default-allocator-directly-from-Rust.patch b/backports/electron/0002-Call-Rust-default-allocator-directly-from-Rust.patch deleted file mode 100644 index 12b3aaa..0000000 --- a/backports/electron/0002-Call-Rust-default-allocator-directly-from-Rust.patch +++ /dev/null @@ -1,319 +0,0 @@ -From 5032162442c5f2f3093cd7646f3a06f826d7f7a8 Mon Sep 17 00:00:00 2001 -From: Collin Baker -Date: Mon, 7 Apr 2025 12:48:17 -0700 -Subject: [PATCH] Call Rust default allocator directly from Rust -MIME-Version: 1.0 -Content-Type: text/plain; charset=UTF-8 -Content-Transfer-Encoding: 8bit - -The Chromium `#[global_allocator] crate forwarded calls to the C++ -implementation, which in turn called into the Rust standard library -implementations in some build configurations. - -This Rust -> C++ -> Rust round trip is unnecessary, and the references -to these symbols is blocking a toolchain update: upstream, these -symbol names are now mangled. - -Instead, use Rust conditional compilation to choose between the -Chromium and the libstd-provided allocators. - -Additionally, the remaining internal symbols defined in C++ are moved -to Rust. - -Bug: 408221149, 407024458 -Change-Id: I78f8c90d51a36a73099aa7d333091d7b8aded3c0 - -Cq-Include-Trybots: luci.chromium.try:android-rust-arm32-rel,android-rust-arm64-dbg,android-rust-arm64-rel,linux-rust-x64-dbg,linux-rust-x64-rel,mac-rust-x64-dbg,win-rust-x64-dbg,win-rust-x64-rel -Change-Id: I78f8c90d51a36a73099aa7d333091d7b8aded3c0 -Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/6434355 -Reviewed-by: Łukasz Anforowicz -Commit-Queue: Collin Baker -Cr-Commit-Position: refs/heads/main@{#1443703} ---- - build/rust/allocator/BUILD.gn | 54 +++++++------------ - build/rust/allocator/allocator_impls.cc | 28 +++++----- - build/rust/allocator/allocator_impls.h | 2 + - .../allocator/allocator_shim_definitions.cc | 30 ----------- - build/rust/allocator/lib.rs | 38 +++++++++++++ - 5 files changed, 73 insertions(+), 79 deletions(-) - delete mode 100644 build/rust/allocator/allocator_shim_definitions.cc - -diff --git a/build/rust/allocator/BUILD.gn b/build/rust/allocator/BUILD.gn -index 06aa47f097c9c..f09314afc8158 100644 ---- a/build/rust/allocator/BUILD.gn -+++ b/build/rust/allocator/BUILD.gn -@@ -12,6 +12,9 @@ if (build_with_chromium) { - rust_allocator_uses_partition_alloc = use_partition_alloc_as_malloc - } - -+use_cpp_allocator_impls = -+ rust_allocator_uses_partition_alloc || (is_win && is_asan) -+ - buildflag_header("buildflags") { - header = "buildflags.h" - flags = [ -@@ -30,61 +33,44 @@ if (toolchain_has_rust) { - crate_root = "lib.rs" - cxx_bindings = [ "lib.rs" ] - -- deps = [ -- ":allocator_impls", -- ":allocator_shim_definitions", -- ] -+ deps = [ ":allocator_impls" ] - - no_chromium_prelude = true - no_allocator_crate = true - allow_unsafe = true -+ -+ if (use_cpp_allocator_impls) { -+ rustflags = [ -+ "--cfg", -+ "use_cpp_allocator_impls", -+ ] -+ } -+ -+ configs -= [ "//build/config/compiler:disallow_unstable_features" ] - } - -+ # TODO(crbug.com/408221149): don't build this when `use_cpp_allocator_impls` -+ # is false. - static_library("allocator_impls") { - public_deps = [] - if (rust_allocator_uses_partition_alloc) { - public_deps += [ "//base/allocator/partition_allocator:partition_alloc" ] - } - -- sources = [ -- "allocator_impls.cc", -- "allocator_impls.h", -- ] -- -- deps = [ -- ":allocator_cpp_shared", -- ":buildflags", -- -- # TODO(crbug.com/408221149): remove the C++ -> Rust dependency for the -- # default allocator. -- "//build/rust/std", -- ] -- -- visibility = [ ":*" ] -- } -- -- source_set("allocator_shim_definitions") { -- sources = [ "allocator_shim_definitions.cc" ] -- -- deps = [ ":allocator_cpp_shared" ] -- -- visibility = [ ":*" ] -- } -- -- source_set("allocator_cpp_shared") { - sources = [ - # `alias.*`, `compiler_specific.h`, and `immediate_crash.*` have been - # copied from `//base`. - # TODO(crbug.com/40279749): Avoid duplication / reuse code. - "alias.cc", - "alias.h", -+ "allocator_impls.cc", -+ "allocator_impls.h", - "compiler_specific.h", - "immediate_crash.h", - ] - -- visibility = [ -- ":allocator_impls", -- ":allocator_shim_definitions", -- ] -+ deps = [ ":buildflags" ] -+ -+ visibility = [ ":*" ] - } - } -diff --git a/build/rust/allocator/allocator_impls.cc b/build/rust/allocator/allocator_impls.cc -index 1fde98f23cd12..bf3c2a301adf5 100644 ---- a/build/rust/allocator/allocator_impls.cc -+++ b/build/rust/allocator/allocator_impls.cc -@@ -101,16 +101,6 @@ - #define USE_WIN_ALIGNED_MALLOC 0 - #endif - --// The default allocator functions provided by the Rust standard library. --extern "C" void* __rdl_alloc(size_t size, size_t align); --extern "C" void __rdl_dealloc(void* p, size_t size, size_t align); --extern "C" void* __rdl_realloc(void* p, -- size_t old_size, -- size_t align, -- size_t new_size); -- --extern "C" void* __rdl_alloc_zeroed(size_t size, size_t align); -- - namespace rust_allocator_internal { - - unsigned char* alloc(size_t size, size_t align) { -@@ -129,7 +119,8 @@ unsigned char* alloc(size_t size, size_t align) { - #elif USE_WIN_ALIGNED_MALLOC - return static_cast(_aligned_malloc(size, align)); - #else -- return static_cast(__rdl_alloc(size, align)); -+ // TODO(crbug.com/408221149): don't build this file in this case. -+ IMMEDIATE_CRASH(); - #endif - } - -@@ -143,7 +134,8 @@ void dealloc(unsigned char* p, size_t size, size_t align) { - #elif USE_WIN_ALIGNED_MALLOC - return _aligned_free(p); - #else -- __rdl_dealloc(p, size, align); -+ // TODO(crbug.com/408221149): don't build this file in this case. -+ IMMEDIATE_CRASH(); - #endif - } - -@@ -162,8 +154,8 @@ unsigned char* realloc(unsigned char* p, - #elif USE_WIN_ALIGNED_MALLOC - return static_cast(_aligned_realloc(p, new_size, align)); - #else -- return static_cast( -- __rdl_realloc(p, old_size, align, new_size)); -+ // TODO(crbug.com/408221149): don't build this file in this case. -+ IMMEDIATE_CRASH(); - #endif - } - -@@ -179,8 +171,14 @@ unsigned char* alloc_zeroed(size_t size, size_t align) { - } - return p; - #else -- return static_cast(__rdl_alloc_zeroed(size, align)); -+ // TODO(crbug.com/408221149): don't build this file in this case. -+ IMMEDIATE_CRASH(); - #endif - } - -+void crash_immediately() { -+ NO_CODE_FOLDING(); -+ IMMEDIATE_CRASH(); -+} -+ - } // namespace rust_allocator_internal -diff --git a/build/rust/allocator/allocator_impls.h b/build/rust/allocator/allocator_impls.h -index afb335412faf9..e90ab7cd422c1 100644 ---- a/build/rust/allocator/allocator_impls.h -+++ b/build/rust/allocator/allocator_impls.h -@@ -20,6 +20,8 @@ unsigned char* realloc(unsigned char* p, - size_t new_size); - unsigned char* alloc_zeroed(size_t size, size_t align); - -+void crash_immediately(); -+ - } // namespace rust_allocator_internal - - #endif // BUILD_RUST_ALLOCATOR_ALLOCATOR_IMPLS_H_ -diff --git a/build/rust/allocator/allocator_shim_definitions.cc b/build/rust/allocator/allocator_shim_definitions.cc -deleted file mode 100644 -index a4d1bd77b7016..0000000000000 ---- a/build/rust/allocator/allocator_shim_definitions.cc -+++ /dev/null -@@ -1,30 +0,0 @@ --// Copyright 2025 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 "build/rust/allocator/alias.h" --#include "build/rust/allocator/immediate_crash.h" -- --extern "C" { -- --// As part of rustc's contract for using `#[global_allocator]` without --// rustc-generated shims we must define this symbol, since we are opting in to --// unstable functionality. See https://github.com/rust-lang/rust/issues/123015 --// --// Mark it weak since rustc will generate it when it drives linking. --[[maybe_unused]] --__attribute__((weak)) unsigned char __rust_no_alloc_shim_is_unstable; -- --__attribute__((weak)) void __rust_alloc_error_handler(size_t size, -- size_t align) { -- NO_CODE_FOLDING(); -- IMMEDIATE_CRASH(); --} -- --__attribute__(( -- weak)) extern const unsigned char __rust_alloc_error_handler_should_panic = -- 0; -- --} // extern "C" -diff --git a/build/rust/allocator/lib.rs b/build/rust/allocator/lib.rs -index 7f4a0fc245694..b8b67d9c6c649 100644 ---- a/build/rust/allocator/lib.rs -+++ b/build/rust/allocator/lib.rs -@@ -8,10 +8,20 @@ - //! the allocator defined here. Currently this is a thin wrapper around - //! allocator_impls.cc's functions; see the documentation there. - -+// Required to apply weak linkage to symbols. -+#![feature(linkage)] -+// Required to apply `#[rustc_std_internal_symbol]` to our alloc error handler -+// so the name is correctly mangled as rustc expects. -+#![cfg_attr(mangle_alloc_error_handler, allow(internal_features))] -+#![cfg_attr(mangle_alloc_error_handler, feature(rustc_attrs))] -+ -+#[cfg(use_cpp_allocator_impls)] - use std::alloc::{GlobalAlloc, Layout}; - -+#[cfg(use_cpp_allocator_impls)] - struct Allocator; - -+#[cfg(use_cpp_allocator_impls)] - unsafe impl GlobalAlloc for Allocator { - unsafe fn alloc(&self, layout: Layout) -> *mut u8 { - unsafe { ffi::alloc(layout.size(), layout.align()) } -@@ -32,9 +42,36 @@ unsafe impl GlobalAlloc for Allocator { - } - } - -+#[cfg(use_cpp_allocator_impls)] - #[global_allocator] - static GLOBAL: Allocator = Allocator; - -+#[cfg(not(use_cpp_allocator_impls))] -+#[global_allocator] -+static GLOBAL: std::alloc::System = std::alloc::System; -+ -+// As part of rustc's contract for using `#[global_allocator]` without -+// rustc-generated shims we must define this symbol, since we are opting in to -+// unstable functionality. See https://github.com/rust-lang/rust/issues/123015 -+#[no_mangle] -+#[linkage = "weak"] -+static __rust_no_alloc_shim_is_unstable: u8 = 0; -+ -+#[no_mangle] -+#[linkage = "weak"] -+static __rust_alloc_error_handler_should_panic: u8 = 0; -+ -+// Mangle the symbol name as rustc expects. -+#[cfg_attr(mangle_alloc_error_handler, rustc_std_internal_symbol)] -+#[cfg_attr(not(mangle_alloc_error_handler), no_mangle)] -+#[linkage = "weak"] -+fn __rust_alloc_error_handler(_size: usize, _align: usize) { -+ unsafe { ffi::crash_immediately() } -+} -+ -+// TODO(crbug.com/408221149): conditionally include the FFI glue based on -+// `use_cpp_allocator_impls` -+#[allow(dead_code)] - #[cxx::bridge(namespace = "rust_allocator_internal")] - mod ffi { - extern "C++" { -@@ -44,5 +81,6 @@ mod ffi { - unsafe fn dealloc(p: *mut u8, size: usize, align: usize); - unsafe fn realloc(p: *mut u8, old_size: usize, align: usize, new_size: usize) -> *mut u8; - unsafe fn alloc_zeroed(size: usize, align: usize) -> *mut u8; -+ unsafe fn crash_immediately(); - } - } diff --git a/backports/electron/0003-Roll-rust-only-f7b43542838f0a4a6cfdb17fbeadf45002042.patch b/backports/electron/0003-Roll-rust-only-f7b43542838f0a4a6cfdb17fbeadf45002042.patch deleted file mode 100644 index 1cfa07f..0000000 --- a/backports/electron/0003-Roll-rust-only-f7b43542838f0a4a6cfdb17fbeadf45002042.patch +++ /dev/null @@ -1,102 +0,0 @@ -reduced -lnl - -From e201e2d467b0daad6cdbbfcd5b0e34760e4099c1 Mon Sep 17 00:00:00 2001 -From: Alan Zhao -Date: Mon, 7 Apr 2025 18:15:01 -0700 -Subject: [PATCH] Roll rust *only* f7b43542838f0a4a6cfdb17fbeadf45002042a77-1 : - 3f690c2257b7080cd3a8cce64e082fc972148990-1 - -https://chromium.googlesource.com/external/github.com/rust-lang/rust/+log/f7b43542838f..3f690c2257b7 - -Ran: ./tools/clang/scripts/upload_revision.py 5b36835df010c5813808d34e45428c624fb52ff1 - -Additionally, add fixes to the rust allocator to address https://crbug.com/407024458. - -Bug: 404285928,407024458 -Disable-Rts: True -Cq-Include-Trybots: chromium/try:chromeos-amd64-generic-cfi-thin-lto-rel -Cq-Include-Trybots: chromium/try:dawn-win10-x86-deps-rel -Cq-Include-Trybots: chromium/try:linux-chromeos-dbg -Cq-Include-Trybots: chromium/try:linux_chromium_cfi_rel_ng -Cq-Include-Trybots: chromium/try:linux_chromium_chromeos_msan_rel_ng -Cq-Include-Trybots: chromium/try:linux_chromium_msan_rel_ng -Cq-Include-Trybots: chromium/try:mac11-arm64-rel,mac_chromium_asan_rel_ng -Cq-Include-Trybots: chromium/try:ios-catalyst,win-asan,android-official -Cq-Include-Trybots: chromium/try:fuchsia-arm64-cast-receiver-rel -Cq-Include-Trybots: chromium/try:mac-official,linux-official -Cq-Include-Trybots: chromium/try:win-official,win32-official -Cq-Include-Trybots: chromium/try:win-swangle-try-x86 -Cq-Include-Trybots: chromium/try:android-cronet-riscv64-dbg -Cq-Include-Trybots: chromium/try:android-cronet-riscv64-rel -Cq-Include-Trybots: chrome/try:iphone-device -Cq-Include-Trybots: chrome/try:linux-chromeos-chrome -Cq-Include-Trybots: chrome/try:win-chrome,win64-chrome,linux-chrome,mac-chrome -Cq-Include-Trybots: chrome/try:linux-pgo,mac-pgo,win32-pgo,win64-pgo -Cq-Include-Trybots: luci.chromium.try:linux-cast-x64-rel -Cq-Include-Trybots: chromium/try:android-rust-arm32-rel -Cq-Include-Trybots: chromium/try:android-rust-arm64-dbg -Cq-Include-Trybots: chromium/try:android-rust-arm64-rel -Cq-Include-Trybots: chromium/try:linux-rust-x64-dbg -Cq-Include-Trybots: chromium/try:linux-rust-x64-rel -Cq-Include-Trybots: chromium/try:mac-rust-x64-dbg -Cq-Include-Trybots: chromium/try:win-rust-x64-dbg -Cq-Include-Trybots: chromium/try:win-rust-x64-rel -Change-Id: Iec99681a89deaf3f2c79c76f9c4d1c2b2b7d6fe1 -Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/6439711 -Reviewed-by: Collin Baker -Commit-Queue: Alan Zhao -Cr-Commit-Position: refs/heads/main@{#1443873} ---- - build/rust/allocator/BUILD.gn | 6 +- - build/rust/allocator/lib.rs | 6 +- - build/rust/std/rules/BUILD.gn | 476 +++++++++++++++++----------------- - tools/rust/update_rust.py | 2 +- - 4 files changed, 251 insertions(+), 239 deletions(-) - -diff --git a/build/rust/allocator/BUILD.gn b/build/rust/allocator/BUILD.gn -index f09314afc8158..ca581630c76c9 100644 ---- a/build/rust/allocator/BUILD.gn -+++ b/build/rust/allocator/BUILD.gn -@@ -32,6 +32,10 @@ if (toolchain_has_rust) { - sources = [ "lib.rs" ] - crate_root = "lib.rs" - cxx_bindings = [ "lib.rs" ] -+ rustflags = [ -+ "--cfg", -+ "mangle_alloc_error_handler", -+ ] - - deps = [ ":allocator_impls" ] - -@@ -40,7 +44,7 @@ if (toolchain_has_rust) { - allow_unsafe = true - - if (use_cpp_allocator_impls) { -- rustflags = [ -+ rustflags += [ - "--cfg", - "use_cpp_allocator_impls", - ] -diff --git a/build/rust/allocator/lib.rs b/build/rust/allocator/lib.rs -index b8b67d9c6c649..4e2dad3d542a8 100644 ---- a/build/rust/allocator/lib.rs -+++ b/build/rust/allocator/lib.rs -@@ -57,13 +57,17 @@ static GLOBAL: std::alloc::System = std::alloc::System; - #[linkage = "weak"] - static __rust_no_alloc_shim_is_unstable: u8 = 0; - --#[no_mangle] -+// Mangle the symbol name as rustc expects. -+#[cfg_attr(mangle_alloc_error_handler, rustc_std_internal_symbol)] -+#[cfg_attr(not(mangle_alloc_error_handler), no_mangle)] -+#[allow(non_upper_case_globals)] - #[linkage = "weak"] - static __rust_alloc_error_handler_should_panic: u8 = 0; - - // Mangle the symbol name as rustc expects. - #[cfg_attr(mangle_alloc_error_handler, rustc_std_internal_symbol)] - #[cfg_attr(not(mangle_alloc_error_handler), no_mangle)] -+#[allow(non_upper_case_globals)] - #[linkage = "weak"] - fn __rust_alloc_error_handler(_size: usize, _align: usize) { - unsafe { ffi::crash_immediately() } diff --git a/backports/electron/0004-Drop-remap_alloc-dep.patch b/backports/electron/0004-Drop-remap_alloc-dep.patch deleted file mode 100644 index c6762a4..0000000 --- a/backports/electron/0004-Drop-remap_alloc-dep.patch +++ /dev/null @@ -1,44 +0,0 @@ -From 4a0377f0b847af505915b0e0a6c4178d4e7c3244 Mon Sep 17 00:00:00 2001 -From: Matt Jolly -Date: Mon, 14 Apr 2025 20:16:46 -0700 -Subject: [PATCH] Drop `remap_alloc` dep -MIME-Version: 1.0 -Content-Type: text/plain; charset=UTF-8 -Content-Transfer-Encoding: 8bit - -commit e3a1797dbab3eaa1c808d53215b32c8759d27ac7 dropped the source set -that this refers to, in favour of a more modern, crate-based solution. - -This seems to have been overlooked, possibly as it only appears to -be called if using the unbundle toolchain. - -Bug: 408221149 -Signed-off-by: Matt Jolly -Change-Id: I1703d8e1e456161aa2b736169eec407235847099 -Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/6456604 -Reviewed-by: Andrew Grieve -Reviewed-by: Lei Zhang -Commit-Queue: Łukasz Anforowicz -Reviewed-by: Łukasz Anforowicz -Cr-Commit-Position: refs/heads/main@{#1446912} ---- - build/rust/std/BUILD.gn | 6 ------ - 1 file changed, 6 deletions(-) - -diff --git a/build/rust/std/BUILD.gn b/build/rust/std/BUILD.gn -index 25db126076b2f..bb2c9884520b3 100644 ---- a/build/rust/std/BUILD.gn -+++ b/build/rust/std/BUILD.gn -@@ -355,12 +355,6 @@ if (toolchain_has_rust) { - ":stdlib_public_dependent_libs", - ] - deps = [ ":prebuilt_rustc_copy_to_sysroot" ] -- -- # The host builds tools toolchain supports Rust only and does not use -- # the allocator remapping to point it to PartitionAlloc. -- if (!toolchain_for_rust_host_build_tools) { -- deps += [ ":remap_alloc" ] -- } - } - } - } diff --git a/backports/electron/0005-rust-Clean-up-build-rust-allocator-after-a-Rust-tool.patch b/backports/electron/0005-rust-Clean-up-build-rust-allocator-after-a-Rust-tool.patch deleted file mode 100644 index 5ba4d83..0000000 --- a/backports/electron/0005-rust-Clean-up-build-rust-allocator-after-a-Rust-tool.patch +++ /dev/null @@ -1,354 +0,0 @@ -From e65cb388e5da56d1236607e0db9cadf89e50eded Mon Sep 17 00:00:00 2001 -From: Lukasz Anforowicz -Date: Tue, 15 Apr 2025 11:10:19 -0700 -Subject: [PATCH] [rust] Clean up `//build/rust/allocator` after a Rust - toolchain roll. -MIME-Version: 1.0 -Content-Type: text/plain; charset=UTF-8 -Content-Transfer-Encoding: 8bit - -This CL makes minor tweaks and changes under `//build/rust/allocator`: - -* Thanks to the Rust toolchain roll, we no longer need to keep two - implementations, picking between them using the - `mangle_alloc_error_handler` configuration knob. -* The `#[cfg(use_cpp_allocator_impls)]` vs - `#[cfg(not(use_cpp_allocator_impls))]` choices have been deduplicated - by putting the related/conditional stuff under `mod cpp_allocator` and - `rust_allocator`. -* Closes a minor gap missed in https://crrev.com/c/6432410: - - Moving `DEPS` file to the new source location - -Bug: 408221149 -Change-Id: Id541797e03da113a5271b02a5f60eb2be08254a9 -Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/6454872 -Reviewed-by: Alan Zhao -Commit-Queue: Łukasz Anforowicz -Cr-Commit-Position: refs/heads/main@{#1447241} ---- - build/rust/allocator/BUILD.gn | 11 +- - build/rust/{std => allocator}/DEPS | 2 +- - build/rust/allocator/allocator_impls.cc | 65 ++---------- - build/rust/allocator/allocator_impls.h | 2 + - build/rust/allocator/lib.rs | 132 +++++++++++++++--------- - 5 files changed, 97 insertions(+), 115 deletions(-) - rename build/rust/{std => allocator}/DEPS (76%) - -diff --git a/build/rust/allocator/BUILD.gn b/build/rust/allocator/BUILD.gn -index ca581630c76c9..434a61e11bdbb 100644 ---- a/build/rust/allocator/BUILD.gn -+++ b/build/rust/allocator/BUILD.gn -@@ -32,10 +32,6 @@ if (toolchain_has_rust) { - sources = [ "lib.rs" ] - crate_root = "lib.rs" - cxx_bindings = [ "lib.rs" ] -- rustflags = [ -- "--cfg", -- "mangle_alloc_error_handler", -- ] - - deps = [ ":allocator_impls" ] - -@@ -43,13 +39,12 @@ if (toolchain_has_rust) { - no_allocator_crate = true - allow_unsafe = true - -+ rustflags = [] - if (use_cpp_allocator_impls) { -- rustflags += [ -- "--cfg", -- "use_cpp_allocator_impls", -- ] -+ rustflags += [ "--cfg=use_cpp_allocator_impls" ] - } - -+ # TODO(https://crbug.com/410596442): Stop using unstable features here. - configs -= [ "//build/config/compiler:disallow_unstable_features" ] - } - -diff --git a/build/rust/std/DEPS b/build/rust/allocator/DEPS -similarity index 76% -rename from build/rust/std/DEPS -rename to build/rust/allocator/DEPS -index eb524c0a06acd..923a2e07c80f4 100644 ---- a/build/rust/std/DEPS -+++ b/build/rust/allocator/DEPS -@@ -3,7 +3,7 @@ include_rules = [ - ] - - specific_include_rules = { -- "remap_alloc.cc" : [ -+ "allocator_impls.cc" : [ - "+partition_alloc" - ] - } -diff --git a/build/rust/allocator/allocator_impls.cc b/build/rust/allocator/allocator_impls.cc -index bf3c2a301adf5..8887752f3dfad 100644 ---- a/build/rust/allocator/allocator_impls.cc -+++ b/build/rust/allocator/allocator_impls.cc -@@ -24,62 +24,6 @@ - #include - #endif - --// NOTE: this documentation is outdated. --// --// TODO(crbug.com/408221149): update this documentation, or replace it with docs --// in the Rust allocator implementation. --// --// When linking a final binary, rustc has to pick between either: --// * The default Rust allocator --// * Any #[global_allocator] defined in *any rlib in its dependency tree* --// (https://doc.rust-lang.org/edition-guide/rust-2018/platform-and-target-support/global-allocators.html) --// --// In this latter case, this fact will be recorded in some of the metadata --// within the .rlib file. (An .rlib file is just a .a file, but does have --// additional metadata for use by rustc. This is, as far as I know, the only --// such metadata we would ideally care about.) --// --// In all the linked rlibs, --// * If 0 crates define a #[global_allocator], rustc uses its default allocator --// * If 1 crate defines a #[global_allocator], rustc uses that --// * If >1 crates define a #[global_allocator], rustc bombs out. --// --// Because rustc does these checks, it doesn't just have the __rust_alloc --// symbols defined anywhere (neither in the stdlib nor in any of these --// crates which have a #[global_allocator] defined.) --// --// Instead: --// Rust's final linking stage invokes dynamic LLVM codegen to create symbols --// for the basic heap allocation operations. It literally creates a --// __rust_alloc symbol at link time. Unless any crate has specified a --// #[global_allocator], it simply calls from __rust_alloc into --// __rdl_alloc, which is the default Rust allocator. The same applies to a --// few other symbols. --// --// We're not (always) using rustc for final linking. For cases where we're not --// Rustc as the final linker, we'll define those symbols here instead. This --// allows us to redirect allocation to PartitionAlloc if clang is doing the --// link. --// --// We use unchecked allocation paths in PartitionAlloc rather than going through --// its shims in `malloc()` etc so that we can support fallible allocation paths --// such as Vec::try_reserve without crashing on allocation failure. --// --// In future, we should build a crate with a #[global_allocator] and --// redirect these symbols back to Rust in order to use to that crate instead. --// This would allow Rust-linked executables to: --// 1. Use PartitionAlloc on Windows. The stdlib uses Windows heap functions --// directly that PartitionAlloc can not intercept. --// 2. Have `Vec::try_reserve` to fail at runtime on Linux instead of crashing in --// malloc() where PartitionAlloc replaces that function. --// --// They're weak symbols, because this file will sometimes end up in targets --// which are linked by rustc, and thus we would otherwise get duplicate --// definitions. The following definitions will therefore only end up being --// used in targets which are linked by our C++ toolchain. --// --// # On Windows ASAN --// - // In ASAN builds, PartitionAlloc-Everywhere is disabled, meaning malloc() and - // friends in C++ do not go to PartitionAlloc. So we also don't point the Rust - // allocation functions at PartitionAlloc. Generally, this means we just direct -@@ -93,7 +37,6 @@ - // Note that there is a runtime option to make ASAN hook HeapAlloc() but - // enabling it breaks Win32 APIs like CreateProcess: - // https://issues.chromium.org/u/1/issues/368070343#comment29 -- - #if !BUILDFLAG(RUST_ALLOCATOR_USES_PARTITION_ALLOC) && BUILDFLAG(IS_WIN) && \ - defined(ADDRESS_SANITIZER) - #define USE_WIN_ALIGNED_MALLOC 1 -@@ -110,6 +53,10 @@ unsigned char* alloc(size_t size, size_t align) { - return nullptr; - } - -+ // We use unchecked allocation paths in PartitionAlloc rather than going -+ // through its shims in `malloc()` etc so that we can support fallible -+ // allocation paths such as Vec::try_reserve without crashing on allocation -+ // failure. - if (align <= alignof(std::max_align_t)) { - return static_cast(allocator_shim::UncheckedAlloc(size)); - } else { -@@ -144,6 +91,10 @@ unsigned char* realloc(unsigned char* p, - size_t align, - size_t new_size) { - #if BUILDFLAG(RUST_ALLOCATOR_USES_PARTITION_ALLOC) -+ // We use unchecked allocation paths in PartitionAlloc rather than going -+ // through its shims in `malloc()` etc so that we can support fallible -+ // allocation paths such as Vec::try_reserve without crashing on allocation -+ // failure. - if (align <= alignof(std::max_align_t)) { - return static_cast( - allocator_shim::UncheckedRealloc(p, new_size)); -diff --git a/build/rust/allocator/allocator_impls.h b/build/rust/allocator/allocator_impls.h -index e90ab7cd422c1..e562a877d886e 100644 ---- a/build/rust/allocator/allocator_impls.h -+++ b/build/rust/allocator/allocator_impls.h -@@ -10,6 +10,8 @@ - #include "build/build_config.h" - #include "build/rust/allocator/buildflags.h" - -+// This header exposes PartitionAlloc to Rust -+// (most APIs below are called from `impl GlobalAlloc` in `lib.rs`). - namespace rust_allocator_internal { - - unsigned char* alloc(size_t size, size_t align); -diff --git a/build/rust/allocator/lib.rs b/build/rust/allocator/lib.rs -index 4e2dad3d542a8..a4f898f9b107f 100644 ---- a/build/rust/allocator/lib.rs -+++ b/build/rust/allocator/lib.rs -@@ -5,72 +5,106 @@ - //! Define the allocator that Rust code in Chrome should use. - //! - //! Any final artifact that depends on this crate, even transitively, will use --//! the allocator defined here. Currently this is a thin wrapper around --//! allocator_impls.cc's functions; see the documentation there. -+//! the allocator defined here. -+//! -+//! List of known issues: -+//! -+//! 1. We'd like to use PartitionAlloc on Windows, but the stdlib uses Windows -+//! heap functions directly that PartitionAlloc can not intercept. -+//! 2. We'd like `Vec::try_reserve` to fail at runtime on Linux instead of -+//! crashing in malloc() where PartitionAlloc replaces that function. - - // Required to apply weak linkage to symbols. -+// -+// TODO(https://crbug.com/410596442): Stop using unstable features here. -+// https://github.com/rust-lang/rust/issues/29603 tracks stabilization of the `linkage` feature. - #![feature(linkage)] - // Required to apply `#[rustc_std_internal_symbol]` to our alloc error handler - // so the name is correctly mangled as rustc expects. --#![cfg_attr(mangle_alloc_error_handler, allow(internal_features))] --#![cfg_attr(mangle_alloc_error_handler, feature(rustc_attrs))] -+// -+// TODO(https://crbug.com/410596442): Stop using internal features here. -+#![allow(internal_features)] -+#![feature(rustc_attrs)] - -+/// Module that provides `#[global_allocator]` / `GlobalAlloc` interface for -+/// using an allocator from C++. - #[cfg(use_cpp_allocator_impls)] --use std::alloc::{GlobalAlloc, Layout}; -+mod cpp_allocator { -+ use super::ffi; -+ use std::alloc::{GlobalAlloc, Layout}; - --#[cfg(use_cpp_allocator_impls)] --struct Allocator; -+ struct Allocator; - --#[cfg(use_cpp_allocator_impls)] --unsafe impl GlobalAlloc for Allocator { -- unsafe fn alloc(&self, layout: Layout) -> *mut u8 { -- unsafe { ffi::alloc(layout.size(), layout.align()) } -- } -+ unsafe impl GlobalAlloc for Allocator { -+ unsafe fn alloc(&self, layout: Layout) -> *mut u8 { -+ unsafe { ffi::alloc(layout.size(), layout.align()) } -+ } - -- unsafe fn dealloc(&self, ptr: *mut u8, layout: Layout) { -- unsafe { -- ffi::dealloc(ptr, layout.size(), layout.align()); -+ unsafe fn dealloc(&self, ptr: *mut u8, layout: Layout) { -+ unsafe { -+ ffi::dealloc(ptr, layout.size(), layout.align()); -+ } - } -- } - -- unsafe fn alloc_zeroed(&self, layout: Layout) -> *mut u8 { -- unsafe { ffi::alloc_zeroed(layout.size(), layout.align()) } -- } -+ unsafe fn alloc_zeroed(&self, layout: Layout) -> *mut u8 { -+ unsafe { ffi::alloc_zeroed(layout.size(), layout.align()) } -+ } - -- unsafe fn realloc(&self, ptr: *mut u8, layout: Layout, new_size: usize) -> *mut u8 { -- unsafe { ffi::realloc(ptr, layout.size(), layout.align(), new_size) } -+ unsafe fn realloc(&self, ptr: *mut u8, layout: Layout, new_size: usize) -> *mut u8 { -+ unsafe { ffi::realloc(ptr, layout.size(), layout.align(), new_size) } -+ } - } --} - --#[cfg(use_cpp_allocator_impls)] --#[global_allocator] --static GLOBAL: Allocator = Allocator; -+ #[global_allocator] -+ static GLOBAL: Allocator = Allocator; -+} - -+/// Module that provides `#[global_allocator]` / `GlobalAlloc` interface for -+/// using the default Rust allocator. - #[cfg(not(use_cpp_allocator_impls))] --#[global_allocator] --static GLOBAL: std::alloc::System = std::alloc::System; -- --// As part of rustc's contract for using `#[global_allocator]` without --// rustc-generated shims we must define this symbol, since we are opting in to --// unstable functionality. See https://github.com/rust-lang/rust/issues/123015 --#[no_mangle] --#[linkage = "weak"] --static __rust_no_alloc_shim_is_unstable: u8 = 0; -- --// Mangle the symbol name as rustc expects. --#[cfg_attr(mangle_alloc_error_handler, rustc_std_internal_symbol)] --#[cfg_attr(not(mangle_alloc_error_handler), no_mangle)] --#[allow(non_upper_case_globals)] --#[linkage = "weak"] --static __rust_alloc_error_handler_should_panic: u8 = 0; -- --// Mangle the symbol name as rustc expects. --#[cfg_attr(mangle_alloc_error_handler, rustc_std_internal_symbol)] --#[cfg_attr(not(mangle_alloc_error_handler), no_mangle)] --#[allow(non_upper_case_globals)] --#[linkage = "weak"] --fn __rust_alloc_error_handler(_size: usize, _align: usize) { -- unsafe { ffi::crash_immediately() } -+mod rust_allocator { -+ #[global_allocator] -+ static GLOBAL: std::alloc::System = std::alloc::System; -+} -+ -+/// Module that provides global symbols that are needed both by `cpp_allocator` -+/// and `rust_allocator`. -+/// -+/// When `rustc` drives linking, then it will define the symbols below. But -+/// Chromium only uses `rustc` to link Rust-only executables (e.g. `build.rs` -+/// scripts) and otherwise uses a non-Rust linker. This is why we have to -+/// manually define a few symbols below. We define those symbols -+/// as "weak" symbols, so that Rust-provided symbols "win" in case where Rust -+/// actually does drive the linking. This hack works (not only for Chromium, -+/// but also for google3 and other projects), but isn't officially supported by -+/// `rustc`. -+/// -+/// TODO(https://crbug.com/410596442): Stop using internal features here. -+mod both_allocators { -+ use super::ffi; -+ -+ /// As part of rustc's contract for using `#[global_allocator]` without -+ /// rustc-generated shims we must define this symbol, since we are opting in -+ /// to unstable functionality. See https://github.com/rust-lang/rust/issues/123015 -+ #[no_mangle] -+ #[linkage = "weak"] -+ static __rust_no_alloc_shim_is_unstable: u8 = 0; -+ -+ // Mangle the symbol name as rustc expects. -+ #[rustc_std_internal_symbol] -+ #[allow(non_upper_case_globals)] -+ #[linkage = "weak"] -+ static __rust_alloc_error_handler_should_panic: u8 = 0; -+ -+ // Mangle the symbol name as rustc expects. -+ #[rustc_std_internal_symbol] -+ #[allow(non_upper_case_globals)] -+ #[linkage = "weak"] -+ fn __rust_alloc_error_handler(_size: usize, _align: usize) { -+ // TODO(lukasza): Investigate if we can just call `std::process::abort()` here. -+ // (Not really _needed_, but it could simplify code a little bit.) -+ unsafe { ffi::crash_immediately() } -+ } - } - - // TODO(crbug.com/408221149): conditionally include the FFI glue based on diff --git a/backports/electron/APKBUILD b/backports/electron/APKBUILD index 2ea2eb0..10023b6 100644 --- a/backports/electron/APKBUILD +++ b/backports/electron/APKBUILD @@ -1,15 +1,15 @@ # Contributor: lauren n. liberda # Maintainer: Antoine Martin (ayakael) pkgname=electron -pkgver=36.9.0 +pkgver=37.5.0 _gittag=v"${pkgver/_beta/-beta.}" pkgrel=0 -_chromium=136.0.7103.177 -_copium_tag=136.2 +_chromium=138.0.7204.251 +_copium_tag=138.0 _depot_tools=495b23b39aaba2ca3b55dd27cadc523f1cb17ee6 pkgdesc="Electron cross-platform desktop toolkit" url="https://github.com/electron/electron" -arch="aarch64 x86_64" # same as chromium +arch="aarch64 armv7 x86_64" # same as chromium license="MIT" depends="gtk+3.0 so:libudev.so.1 xdg-utils" _llvmver=20 @@ -134,13 +134,8 @@ source=" no-sandbox-settls.patch partalloc-no-tagging-arm64.patch pvalloc.patch + rust_no_alloc_shim_is_unstable_v2.patch temp-failure-retry.patch - 0001-Reland-Use-global_allocator-to-provide-Rust-allocato.patch - 0002-Call-Rust-default-allocator-directly-from-Rust.patch - 0003-Roll-rust-only-f7b43542838f0a4a6cfdb17fbeadf45002042.patch - 0004-Drop-remap_alloc-dep.patch - 0005-rust-Clean-up-build-rust-allocator-after-a-Rust-tool.patch - 0006-Define-__rust_no_alloc_shim_is_unstable_v2.patch electron_icon.patch electron_python-jinja-3.10.patch @@ -158,9 +153,7 @@ _copium_patches=" cr133-ffmpeg-no-noh264parse.patch cr133-is-musl-libcxx.patch cr135-mv2-still-not-dead.patch - cr135-unbundle-simdutf-v8-fix.patch - cr136-gpery-3.2-fallthrough.patch - cr136-node-version-check.patch + cr138-node-version-check.patch " # Avoid conflicting providers sonameprefix="$pkgname:" @@ -424,6 +417,8 @@ prepare() { third_party/blink/renderer/core/xml/parser/xml_document_parser.cc \ third_party/libxml/chromium/*.cc + echo "$CTARGET" >> build/rust/known-target-triples.txt + _configure } @@ -556,10 +551,10 @@ lang() { } sha512sums=" -687416deda53accc36722f5ab10244360916bc9cf4245f62416fe7dda1c818f2d739e3e3af7e2418f0b9e519da77116ae527077386baf552c4e8dc64e33ccbcc electron-v36.9.0-136.0.7103.177.tar.zst -7188e6020dbbe19923698e31c7b793f0125c92d397187a2b4075b3e90f8d1b9ad63f860c02113cdc4260bb05f45ad4781543156e8d925e7969ad7ec26ffdb52e copium-136.2.tar.gz +0027f27a0caecfaa6d4c7c9ac3dc9b74105aa07a1100d42ae1a7616182679f07c19737e27c8f302a75603babebc3d399c4670100ee8557f2e045f9b38d6d5aaf electron-v37.5.0-138.0.7204.251.tar.zst +32e1edad4d149c489e6c6f6818cf2b2ed3c7ae1cb62600576f54d7315804e5be2c1b62716e1c1bcc445cc1e874299605cc2602b0b8ff5be665fb4b1b4f11f051 copium-138.0.tar.gz 29bb685e03356a77df5fd347cdf55194cc8b3265c421cc76e54d64edefc329dbcb052deb26b22e8f587ce68456876c071de1b7d258dd0fcc6ee66c875ec4a020 chromium-revert-drop-of-system-java.patch -574e8dfd949925e8181b9cbae5bd82ba284d9f9236f6ce5de01bf9e097a443e0e964597b925c89761a009d286c8869ba1748e924a009b1bca2897aa2aa62071b compiler.patch +ac765796ecd46f724f788181b9b76e1d100d18de7d45b32e33406e8540a83fab2fc93f74664c0748ed7839dbfbb9675a81a39f2dc0fbc796179b7d0dbd4fb706 compiler.patch 4057cc78f10bfd64092bc35a373869abb1d68b880cdbca70422f39ffd78a929c19c7728d4d4c40709aaba25581148a93ae5343e724849fd35323062ed68753fa disable-dns_config_service.patch 2470904846e3adde2c9506f9e78220daca0932320b628dd3d427bf2b7c17a8f7880cb97e787b046c28de7aca642e1a8d30824d6049905976da77e7473baa64da disable-failing-tests.patch 5fc5c012c1db6cf1ba82f38c6f3f4f5ca3a209e47ac708a74de379b018e0649b7694877c9571ef79002dde875ffc07b458a3355425f1c01867f362c66c2bc1bf fc-cache-version.patch @@ -576,19 +571,14 @@ e4c4e5bc6f828f9c883dd418c0ba01887949c29c311f76206a1ec29f620b0c0ba0452949dc2778a9 6dc4d8dc92e685dace62265a1ddb3aebc558aed54d20ff6d36b030be0c48d7e84662326c31363612492574d9a03c62653cdc21a60995b97dee1d75cae86a9f9b no-sandbox-settls.patch b75908a45ee2f4f806eec8d86fca2f51fda3531b88de48ef4539c364a40d7e2897cdaf38b715682d712648e3f43aac983055e688385f85fa7b7204ffb6d617e1 partalloc-no-tagging-arm64.patch 03f829a2da633533ef3fd0f287f5ec602d936a97a98b53cd2415553c2537ae9d571f35397ca7c9fb3f4b0806c300e3b189569f8d979ca132e1a2a4dae7206396 pvalloc.patch +2fac0d195ec9ae97b5e0758fa00d871461990f58f777dd70d35583eccf117d7c65a0e92d9781bca7e97ad7509aa1f37dfd8c775dabd8b055e9935a786b81d2a9 rust_no_alloc_shim_is_unstable_v2.patch e48693e6b7aeebf69a5acbf80d9a35defe4c23835121dfeb58b051ac7c527e758a41004f4d193274fe1b01c0bfb1dbc77b09cb6a404a3fdee507a2918afb0edb temp-failure-retry.patch -858f8e3c544abf3ffe0f54ba303713e9b4058e15996c8dc10bab7c999d82e1960756325a41d6bebb3a00404efb8e51c299f61f60de4feaac6b621757ab85d329 0001-Reland-Use-global_allocator-to-provide-Rust-allocato.patch -077497c1598c7db9f4c23e000e9b86e1833de4866479fd921313543ad599e141427bf38ae687f84c3da59af68f09a776265c2a569e1a7abfa80440231baef10a 0002-Call-Rust-default-allocator-directly-from-Rust.patch -5002aa73eb19b87c702eef5b087ecb3a2679142c28cd95a5a9571aeffe24e6944497e862058ed1d609317a723cdec1678f84543235fb93f12653a92b92309efe 0003-Roll-rust-only-f7b43542838f0a4a6cfdb17fbeadf45002042.patch -d2e414135d2b046dd9efe277f88062bcb0a94749a17a014309260b1469305d55059931b9531572713c8e516897e30fd2f5317948ece1581ffe9b7b6c01078a6d 0004-Drop-remap_alloc-dep.patch -fe66228c0eefe3d08e2a7955b11e6a46f58f477befceba1628765fb016f30eb0bb02723aeedcabdb1ea3b84c42b5ea65073998e0a64f5ce082120fc7e65dee9a 0005-rust-Clean-up-build-rust-allocator-after-a-Rust-tool.patch -2fac0d195ec9ae97b5e0758fa00d871461990f58f777dd70d35583eccf117d7c65a0e92d9781bca7e97ad7509aa1f37dfd8c775dabd8b055e9935a786b81d2a9 0006-Define-__rust_no_alloc_shim_is_unstable_v2.patch 465107da7818b237e3c144a318ab80c3c9343b51ed38b8971ef204692d13346929becbe94cefad4c153788d3a200642143584d5ca070f6304e768ba2139c19ec electron_icon.patch e05180199ee1d559e4e577cedd3e589844ecf40d98a86321bf1bea5607b02eeb5feb486deddae40e1005b644550331f6b8500177aa7e79bcb3750d3c1ceb76c3 electron_python-jinja-3.10.patch 2aa340854316f1284217c0ca17cbf44953684ad6c7da90815117df30928612eb9fb9ffb734b948dfc309cd25d1a67cd57f77aac2d052a3dd9aca07a3a58cbb30 electron_webpack-hash.patch c7f57929943a86f9e5f333da9d5691da88038770eeb46dd0a0719962c934deb2879f0e7a1ed714e9383e38ee4d68eb754501f362c4d7cdee76cfc2e980b21272 electron_unbundle-node.patch 4d9287d4cdfe27fbfb7be3d4b26c0c40edbd6a0c3ff926d60f2093ca09c15bcb58e20c2ccc8c0606aafd66c6d25a54225bc329cb056d8c5b297db4c6d0e768e6 electron_system-zlib-headers.patch -38cbb4599b322321f157f477302729d0f6515ad1bd292912575ca334655eeadd5b53c66837f7ff54a572c34cf6b7db1d0f97d53ff42553f0f74c71eed8223b06 electron_do-not-strip-binaries.patch +f6622bbeb9a03300f8ebf20f1b1defb3a573eee596863956cc62c8968d66993382a6436653c99d1c406ace243799c619f512255300b3f4b421abd9f50dca29cc electron_do-not-strip-binaries.patch e8ea87c547546011c4c8fc2de30e4f443b85cd4cfcff92808e2521d2f9ada03feefb8e1b0cf0f6b460919c146e56ef8d5ad4bb5e2461cc5247c30d92eb4d068e default.conf 191559fc7aa1ea0353c6fb0cc321ee1d5803a0e44848c8be941cfab96277b0de6a59962d373e2a2a1686c8f9be2bcf2d2f33706759a339a959e297d3f7fda463 electron.desktop 5f7ba5ad005f196facec1c0f26108356b64cafb1e5cfa462ff714a33b8a4c757ac00bfcb080da09eb5b65032f8eb245d9676a61ec554515d125ed63912708648 electron-launcher.sh diff --git a/backports/electron/compiler.patch b/backports/electron/compiler.patch index 3ea2d7f..02e6814 100644 --- a/backports/electron/compiler.patch +++ b/backports/electron/compiler.patch @@ -1,6 +1,6 @@ --- ./build/config/compiler/BUILD.gn.orig +++ ./build/config/compiler/BUILD.gn -@@ -590,24 +590,6 @@ +@@ -604,24 +604,6 @@ } } @@ -25,7 +25,7 @@ # TODO(crbug.com/40192287): Investigate why/if this should be needed. if (is_win) { cflags += [ "/clang:-ffp-contract=off" ] -@@ -1033,20 +1015,6 @@ +@@ -1062,20 +1044,6 @@ # `-nodefaultlibs` from the linker invocation from Rust, which would be used # to compile dylibs on Android, such as for constructing unit test APKs. "-Cdefault-linker-libraries", @@ -46,7 +46,7 @@ ] if (!is_win || force_rustc_color_output) { -@@ -1095,7 +1063,6 @@ +@@ -1130,7 +1098,6 @@ # Don't allow unstable features to be enabled by `#![feature()]` without # additional command line flags. config("disallow_unstable_features") { @@ -54,7 +54,29 @@ } config("libcxx_hardening") { -@@ -1213,8 +1180,8 @@ +@@ -1234,8 +1201,8 @@ + if (current_cpu == "x64") { + if (is_clang && !is_android && !is_nacl && !is_fuchsia && + !is_chromeos_device) { +- cflags += [ "--target=x86_64-unknown-linux-gnu" ] +- ldflags += [ "--target=x86_64-unknown-linux-gnu" ] ++ cflags += [ "--target=x86_64-alpine-linux-musl" ] ++ ldflags += [ "--target=x86_64-alpine-linux-musl" ] + } else { + cflags += [ "-m64" ] + ldflags += [ "-m64" ] +@@ -1243,8 +1210,8 @@ + cflags += [ "-msse3" ] + } else if (current_cpu == "x86") { + if (is_clang && !is_android && !is_nacl && !is_chromeos_device) { +- cflags += [ "--target=i386-unknown-linux-gnu" ] +- ldflags += [ "--target=i386-unknown-linux-gnu" ] ++ cflags += [ "--target=i586-alpine-linux-musl" ] ++ ldflags += [ "--target=i586-alpine-linux-musl" ] + } else { + cflags += [ "-m32" ] + ldflags += [ "-m32" ] +@@ -1257,8 +1224,8 @@ } } else if (current_cpu == "arm") { if (is_clang && !is_android && !is_nacl && !is_chromeos_device) { @@ -65,7 +87,7 @@ } if (!is_nacl) { cflags += [ -@@ -1228,8 +1195,8 @@ +@@ -1272,8 +1239,8 @@ } else if (current_cpu == "arm64") { if (is_clang && !is_android && !is_nacl && !is_fuchsia && !is_chromeos_device) { @@ -76,7 +98,7 @@ } } else if (current_cpu == "mipsel" && !is_nacl) { ldflags += [ "-Wl,--hash-style=sysv" ] -@@ -2111,7 +2078,7 @@ +@@ -2262,7 +2229,7 @@ defines = [ "_HAS_NODISCARD" ] } } else { @@ -87,7 +109,7 @@ cflags += [ "-Wextra" ] --- ./build/config/rust.gni.orig +++ ./build/config/rust.gni -@@ -175,13 +175,13 @@ +@@ -188,13 +188,13 @@ rust_abi_target = "" if (is_linux || is_chromeos) { if (current_cpu == "arm64") { @@ -104,7 +126,7 @@ cargo_target_abi = "" } else if (current_cpu == "arm") { if (arm_float_abi == "hard") { -@@ -200,22 +200,18 @@ +@@ -213,31 +213,27 @@ # The thumbv7 vs. armv7 distinction is for legacy reasons and both # targets in fact target Thumb, see: # https://github.com/rust-lang/rust/issues/44722 @@ -124,18 +146,30 @@ - rust_abi_target = "riscv64gc-unknown-linux-gnu" + rust_abi_target = "riscv64-alpine-linux-musl" cargo_target_abi = "" + } else if (current_cpu == "ppc64") { +- rust_abi_target = "powerpc64le-unknown-linux-gnu" ++ rust_abi_target = "powerpc64le-alpine-linux-musl" + cargo_target_abi = "" + } else if (current_cpu == "s390x") { +- rust_abi_target = "s390x-unknown-linux-gnu" ++ rust_abi_target = "s390x-alpine-linux-musl" + cargo_target_abi = "" + } else if (current_cpu == "loong64") { +- rust_abi_target = "loongarch64-unknown-linux-gnu" ++ rust_abi_target = "loongarch64-alpine-linux-musl" + cargo_target_abi = "" } else { # Best guess for other future platforms. - rust_abi_target = current_cpu + "-unknown-linux-gnu" -+ rust_abi_target = current_cpu + "-alpine-linux-musl" ++ rust_abi_target = current_cpu + "-unknown-linux-musl" cargo_target_abi = "" } } else if (is_android) { --- ./build/config/clang/BUILD.gn.orig +++ ./build/config/clang/BUILD.gn -@@ -128,14 +128,15 @@ - } else if (is_apple) { - _dir = "darwin" +@@ -208,16 +208,17 @@ + assert(false) # Unhandled cpu type + } } else if (is_linux || is_chromeos) { + _dir = "linux" if (current_cpu == "x64") { @@ -150,6 +184,9 @@ } else if (current_cpu == "arm64") { - _dir = "aarch64-unknown-linux-gnu" + _suffix = "-aarch64" + } else if (current_cpu == "loong64") { +- _dir = "loongarch64-unknown-linux-gnu" ++ _suffix = "-loongarch64" } else { assert(false) # Unhandled cpu type } diff --git a/backports/electron/electron_do-not-strip-binaries.patch b/backports/electron/electron_do-not-strip-binaries.patch index e3f39bd..5cfb7f9 100644 --- a/backports/electron/electron_do-not-strip-binaries.patch +++ b/backports/electron/electron_do-not-strip-binaries.patch @@ -131,4 +131,3 @@ index 720d3cc7e13..47a5fb2ecec 100644 - deps = mksnapshot_deps - } -} - diff --git a/backports/electron/pipewire-1.4.patch b/backports/electron/pipewire-1.4.patch deleted file mode 100644 index ab9c37f..0000000 --- a/backports/electron/pipewire-1.4.patch +++ /dev/null @@ -1,23 +0,0 @@ -Patch-Source: https://webrtc-review.googlesource.com/c/src/+/380500 ---- ---- a/third_party/webrtc/modules/video_capture/linux/pipewire_session.cc -+++ b/third_party/webrtc/modules/video_capture/linux/pipewire_session.cc -@@ -87,7 +87,7 @@ - .param = OnNodeParam, - }; - -- pw_node_add_listener(proxy_, &node_listener_, &node_events, this); -+ pw_node_add_listener(reinterpret_cast(proxy_), &node_listener_, &node_events, this); - } - - // static -@@ -119,7 +119,7 @@ - uint32_t id = info->params[i].id; - if (id == SPA_PARAM_EnumFormat && - info->params[i].flags & SPA_PARAM_INFO_READ) { -- pw_node_enum_params(that->proxy_, 0, id, 0, UINT32_MAX, nullptr); -+ pw_node_enum_params(reinterpret_cast(that->proxy_), 0, id, 0, UINT32_MAX, nullptr); - break; - } - } - diff --git a/backports/electron/0006-Define-__rust_no_alloc_shim_is_unstable_v2.patch b/backports/electron/rust_no_alloc_shim_is_unstable_v2.patch similarity index 100% rename from backports/electron/0006-Define-__rust_no_alloc_shim_is_unstable_v2.patch rename to backports/electron/rust_no_alloc_shim_is_unstable_v2.patch -- 2.49.1 From 74990b55aa821f6eb75fb08959161b6a6841bb16 Mon Sep 17 00:00:00 2001 From: Antoine Martin Date: Sat, 13 Sep 2025 09:38:55 -0400 Subject: [PATCH 2/2] backports/*: rebuild against electron 37.5.0 --- backports/caprine/APKBUILD | 2 +- backports/element-desktop/APKBUILD | 2 +- backports/freetube/APKBUILD | 2 +- backports/signal-desktop/APKBUILD | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/backports/caprine/APKBUILD b/backports/caprine/APKBUILD index 5d159c7..09b3e99 100644 --- a/backports/caprine/APKBUILD +++ b/backports/caprine/APKBUILD @@ -2,7 +2,7 @@ # Maintainer: Antoine Martin (ayakael) pkgname=caprine pkgver=2.60.3 -pkgrel=3 +pkgrel=4 pkgdesc="Elegant Facebook Messenger desktop app" arch="x86_64 aarch64" # blocked by electron url="https://github.com/sindresorhus/caprine" diff --git a/backports/element-desktop/APKBUILD b/backports/element-desktop/APKBUILD index 6a3e842..464f196 100644 --- a/backports/element-desktop/APKBUILD +++ b/backports/element-desktop/APKBUILD @@ -2,7 +2,7 @@ maintainer="lauren n. liberda " pkgname=element-desktop pkgver=1.11.100 -pkgrel=2 +pkgrel=3 pkgdesc="Secure and independent communication, connected via Matrix" url="https://element.io/" arch="aarch64 x86_64" # same as electron diff --git a/backports/freetube/APKBUILD b/backports/freetube/APKBUILD index 0054141..2386285 100644 --- a/backports/freetube/APKBUILD +++ b/backports/freetube/APKBUILD @@ -2,7 +2,7 @@ # Contributor: Antoine Martin (ayakael) pkgname=freetube pkgver=0.23.5 -pkgrel=2 +pkgrel=3 pkgdesc="An open source desktop YouTube player built with privacy in mind." arch="x86_64 aarch64" # blocked by electron license="AGPL-3.0-only" diff --git a/backports/signal-desktop/APKBUILD b/backports/signal-desktop/APKBUILD index b983aa8..f1db656 100644 --- a/backports/signal-desktop/APKBUILD +++ b/backports/signal-desktop/APKBUILD @@ -3,7 +3,7 @@ # Maintainer: Antoine Martin (ayakael) pkgname=signal-desktop pkgver=7.70.0 -pkgrel=0 +pkgrel=1 pkgdesc="A messaging app for simple private communication with friends" url="https://github.com/signalapp/Signal-Desktop/" # same as electron -- 2.49.1