From c19203e06fb6eeb001c41fa1ab38c9a83bef7a94 Mon Sep 17 00:00:00 2001 From: Ihar Hrachyshka Date: Tue, 26 May 2026 21:16:59 -0400 Subject: [PATCH] buildMozillaMach: fix darwin build Versions before 144 vendor bindgen 0.69, which emits invalid Rust for libc++ 21's attributed basic_string::__self_view alias on Darwin. This was exposed by commit 0758fc3addcc ("darwin.libcxx: 20.1.0+apple-sdk-26.0 -> 21.1.6+apple-sdk-26.4"), where libc++ changed `basic_string::__self_view` from a typedef to an attributed `using` alias. bindgen then drops the alias template parameter and emits `basic_string___self_view = ...<_CharT>`. The solution is to blocklist the unused `string_view` internals for the profiler Rust API. They are not used in the actual build. Note: Mozilla 144 updated vendored bindgen via: https://bugzilla.mozilla.org/show_bug.cgi?id=1985509 Assisted-by: Codex gpt-5.5 xhigh --- .../140-bindgen-string-view.patch | 15 +++++++++++++++ pkgs/build-support/build-mozilla-mach/default.nix | 8 ++++++++ 2 files changed, 23 insertions(+) create mode 100644 pkgs/build-support/build-mozilla-mach/140-bindgen-string-view.patch diff --git a/pkgs/build-support/build-mozilla-mach/140-bindgen-string-view.patch b/pkgs/build-support/build-mozilla-mach/140-bindgen-string-view.patch new file mode 100644 index 000000000000..c67dd36f95a4 --- /dev/null +++ b/pkgs/build-support/build-mozilla-mach/140-bindgen-string-view.patch @@ -0,0 +1,15 @@ +diff --git a/tools/profiler/rust-api/build.rs b/tools/profiler/rust-api/build.rs +index 9bb27eb83e5e..3f09f7f01bcb 100644 +--- a/tools/profiler/rust-api/build.rs ++++ b/tools/profiler/rust-api/build.rs +@@ -88,6 +88,10 @@ fn generate_bindings() { + // successfully. Otherwise, it fails to build because MarkerSchema has + // some std::strings as its fields. + .opaque_type("std::string") ++ .blocklist_type(".*basic_string_view.*") ++ .opaque_type(".*basic_string_view.*") ++ .blocklist_type(".*basic_string___self_view.*") ++ .opaque_type(".*basic_string___self_view.*") + // std::vector needs to be converted to an opaque type because, if it's + // not an opaque type, bindgen can't find its size properly and + // MarkerSchema's total size reduces. That causes a heap buffer overflow. diff --git a/pkgs/build-support/build-mozilla-mach/default.nix b/pkgs/build-support/build-mozilla-mach/default.nix index 3363d89fa7b1..4b036b558c45 100644 --- a/pkgs/build-support/build-mozilla-mach/default.nix +++ b/pkgs/build-support/build-mozilla-mach/default.nix @@ -332,6 +332,14 @@ buildStdenv.mkDerivation { # https://hg-edge.mozilla.org/mozilla-central/rev/aa8a29bd1fb9 ./139-wayland-drag-animation.patch ] + ++ lib.optionals (lib.versionAtLeast version "140" && lib.versionOlder version "144") [ + # Versions before 144 vendor bindgen 0.69. On Darwin, libc++ 21 changed + # basic_string::__self_view from a typedef to an attributed using alias; + # bindgen then emits it without its template parameter, producing invalid + # Rust. Vendored bindgen was updated in: + # https://bugzilla.mozilla.org/show_bug.cgi?id=1985509 + ./140-bindgen-string-view.patch + ] ++ extraPatches; postPatch = ''