chromium,electron: fix build with rust 1.89.0 (#434962)

This commit is contained in:
Vladimír Čunát
2025-08-20 07:57:22 +02:00
4 changed files with 41 additions and 33 deletions
@@ -526,6 +526,24 @@ let
# preventing compilations of chromium with versions below their intended version, not about running the very
# exact version or even running a newer version.
./patches/chromium-136-nodejs-assert-minimal-version-instead-of-exact-match.patch
]
++ lib.optionals (chromiumVersionAtLeast "138") [
(fetchpatch {
# Unbreak building with Rust 1.89+ which introduced
# a new mismatched_lifetime_syntaxes lint.
# https://issues.chromium.org/issues/424424323
name = "chromium-138-rust-1.86-mismatched_lifetime_syntaxes.patch";
# https://chromium-review.googlesource.com/c/chromium/src/+/6658267
url = "https://chromium.googlesource.com/chromium/src/+/94a87ff38c51fd1a71980a5051d3553978391608^!?format=TEXT";
decode = "base64 -d";
includes = [ "build/rust/cargo_crate.gni" ];
hash = "sha256-xf1Jq5v3InXkiVH0uT7+h1HPwZse5MDcHKuJNjSLR6k=";
})
]
++ lib.optionals (!chromiumVersionAtLeast "138") [
# Rebased variant of the patch above for
# electron 35 (M134) and 36 (M136)
./patches/chromium-134-rust-1.86-mismatched_lifetime_syntaxes.patch
];
postPatch =
@@ -0,0 +1,14 @@
diff --git a/build/rust/cargo_crate.gni b/build/rust/cargo_crate.gni
index 8266c44cbd1dfb8a53797dbe911ea74c32ce070e..ec7d751f2d068151dfeb71aa1f6510483bebd95c 100644
--- a/build/rust/cargo_crate.gni
+++ b/build/rust/cargo_crate.gni
@@ -285,6 +285,9 @@ template("cargo_crate") {
}
rustenv = _rustenv
+ # TODO(crbug.com/424424323): Clean up and enable.
+ rustflags += [ "-Amismatched_lifetime_syntaxes" ]
+
if (!defined(build_native_rust_unit_tests)) {
build_native_rust_unit_tests = _crate_type != "proc-macro"
}
+9 -20
View File
@@ -86,26 +86,6 @@ in
patches =
base.patches
# Fix building with Rust 1.86+
# electron_33 and electron_34 use older chromium versions which expect rust
# to provide the older `adler` library instead of the newer `adler2` library
# This patch makes those older versions also use the new adler2 library
++ lib.optionals (lib.versionOlder info.version "35") [
./use-rust-adler2.patch
]
# Requirements for the next section
++ lib.optionals (lib.versionOlder info.version "35") [
(fetchpatch {
name = "Avoid-build-rust-PartitionAlloc-dep-when-not-build_with_chromium.patch";
url = "https://github.com/chromium/chromium/commit/ee94f376a0dd642a93fbf4a5fa8e7aa8fb2a69b5.patch";
hash = "sha256-qGjy9VZ4d3T5AuqOrBKEajBswwBU/7j0n80rpvHZLmM=";
})
(fetchpatch {
name = "Suppress-unsafe_libc_call-warning-for-rust-remap_alloc-cc.patch";
url = "https://github.com/chromium/chromium/commit/d5d79d881e74c6c8630f7d2f3affd4f656fdeb4e.patch";
hash = "sha256-1oy5WRvNzKuUTJkt8kULUqE4JU+EKEV1PB9QN8HF4SE=";
})
]
# Fix building with Rust 1.87+
# https://issues.chromium.org/issues/407024458
++ lib.optionals (lib.versionOlder info.version "37") [
@@ -151,6 +131,15 @@ in
url = "https://github.com/chromium/chromium/commit/f8f21fb4aa01f75acbb12abf5ea8c263c6817141.patch";
hash = "sha256-z/aQ1oQjFZnkUeRnrD6P/WDZiYAI1ncGhOUM+HmjMZA=";
})
]
# Fix build with Rust 1.89.0
++ lib.optionals (lib.versionOlder info.version "38") [
# https://chromium-review.googlesource.com/c/chromium/src/+/6624733
(fetchpatch {
name = "Define-rust-no-alloc-shim-is-unstable-v2.patch";
url = "https://github.com/chromium/chromium/commit/6aae0e2353c857d98980ff677bf304288d7c58de.patch";
hash = "sha256-Dd38c/0hiH+PbGPJhhEFuW6kUR45A36XZqOVExoxlhM=";
})
];
npmRoot = "third_party/node";
@@ -1,13 +0,0 @@
diff --git a/build/rust/std/BUILD.gn b/build/rust/std/BUILD.gn
index 6b996aa1fe3865187d02c017e56c0918bcc9b8f4..68b085be200fa4f116aa709b9157c4d2efdf7d6a 100644
--- a/build/rust/std/BUILD.gn
+++ b/build/rust/std/BUILD.gn
@@ -89,7 +89,7 @@ if (toolchain_has_rust) {
# These are no longer present in the Windows toolchain.
stdlib_files += [
"addr2line",
- "adler",
+ "adler2",
"gimli",
"libc",
"memchr",