Files
takana/recipes/firefox-patches/glean-stub.patch
T
Sergio 428be5e8d1 firefox 154.0 — la cabeza de la familia Gecko (receta, sin construir todavía)
154 y no 155 pese a que Zen sigue 155.0.1 y Waterfox también va por release: los
parches de musl de Alpine son para 154.0, y son ONCE. Ese es el trabajo de
portabilidad que un import de nix pierde y sin el cual Firefox no compila contra
musl. Un Firefox que compila con el set probado vale más que uno con el número
correcto que no compila; y como Firefox se mueve cada 4 semanas, la paridad exacta
con Zen es una cinta de correr. Lo que se reutiliza entre los tres es la
PLATAFORMA (gtk3/nodejs/clang18/cbindgen, ya en el corpus) y este set de parches.
Subir a 155 después es un rebase, no un port.

Se traen los 11 de musl y NO los de ppc64le, loongarch ni Android: cada parche que
no hace falta es una forma más de que un rebase falle sin motivo.

TODO BUNDLEADO salvo GTK3. Alpine usa --with-system-{icu,nspr,nss,av1,libvpx,
webp,libevent} y de ésas el corpus tiene cero; Firefox las trae en el árbol.
Menos piezas móviles para el primer build, que es cuando conviene minimizar
variables.

SIN BRANDING OFICIAL, y no es descuido: el binario lleva once parches, y poner el
nombre y el logo de Firefox sobre un build modificado entra en la política de
marcas de Mozilla — es la historia de Iceweasel en Debian. Misma cautela que
dejavu-fonts-nerd con la licencia de Bitstream Vera: una fuente modificada no
puede llamarse como la original, y un navegador parcheado tampoco.

HERMÉTICO: --disable-bootstrap (su trabajo es descargar toolchains),
MACH_BUILD_PYTHON_NATIVE_PACKAGE_SOURCE=system (si no, mach arma un virtualenv con
pip y sale a la red) y MOZBUILD_STATE_PATH al árbol (por defecto escribe en $HOME,
que en el sandbox no es suyo). Los crates vienen vendorizados en el tarball.

Wayland-only heredado de gtk3 (-Dx11_backend=false) ⇒ este Firefox NO correrá como
cliente X11 ni bajo Xwayland. Escrito en las dos recetas.
2026-09-04 21:02:51 +00:00

293 lines
10 KiB
Diff

From: Patrycja Rosa <mozcontrib@ptrcnull.me>
Date: Mon, 1 Jun 2026 19:20:39 +0200
Subject: [PATCH] stub out some glean metrics
play stupid games, win `rustc-LLVM ERROR: out of memory`
---
.../components/glean/api/src/ffi/boolean.rs | 11 +-
.../components/glean/api/src/ffi/counter.rs | 8 +-
toolkit/components/glean/api/src/ffi/event.rs | 127 +-----------------
.../components/glean/api/src/ffi/string.rs | 14 +-
.../build_scripts/glean_parser_ext/rust.py | 19 +++
5 files changed, 34 insertions(+), 145 deletions(-)
diff --git a/toolkit/components/glean/api/src/ffi/boolean.rs b/toolkit/components/glean/api/src/ffi/boolean.rs
index 9184b23c0098e..fa13206627272 100644
--- a/toolkit/components/glean/api/src/ffi/boolean.rs
+++ b/toolkit/components/glean/api/src/ffi/boolean.rs
@@ -8,21 +8,18 @@ use nsstring::nsACString;
#[no_mangle]
pub extern "C" fn fog_boolean_test_has_value(id: u32, ping_name: &nsACString) -> bool {
- with_metric!(BOOLEAN_MAP, id, metric, test_has!(metric, ping_name))
+ false
}
#[no_mangle]
pub extern "C" fn fog_boolean_test_get_value(id: u32, ping_name: &nsACString) -> bool {
- with_metric!(BOOLEAN_MAP, id, metric, test_get!(metric, ping_name))
+ false
}
#[no_mangle]
pub extern "C" fn fog_boolean_test_get_error(id: u32, error_str: &mut nsACString) -> bool {
- let err = with_metric!(BOOLEAN_MAP, id, metric, test_get_errors!(metric));
- err.map(|err_str| error_str.assign(&err_str)).is_some()
+ false
}
#[no_mangle]
-pub extern "C" fn fog_boolean_set(id: u32, value: bool) {
- with_metric!(BOOLEAN_MAP, id, metric, metric.set(value));
-}
+pub extern "C" fn fog_boolean_set(id: u32, value: bool) {}
diff --git a/toolkit/components/glean/api/src/ffi/counter.rs b/toolkit/components/glean/api/src/ffi/counter.rs
index cf24d79d7dd8e..06a7017a7718c 100644
--- a/toolkit/components/glean/api/src/ffi/counter.rs
+++ b/toolkit/components/glean/api/src/ffi/counter.rs
@@ -8,23 +8,21 @@ use nsstring::nsACString;
#[no_mangle]
pub unsafe extern "C" fn fog_counter_add(id: u32, amount: i32) {
- with_metric!(COUNTER_MAP, id, metric, metric.add(amount));
}
#[no_mangle]
pub unsafe extern "C" fn fog_counter_test_has_value(id: u32, ping_name: &nsACString) -> bool {
- with_metric!(COUNTER_MAP, id, metric, test_has!(metric, ping_name))
+ true
}
#[no_mangle]
pub unsafe extern "C" fn fog_counter_test_get_value(id: u32, ping_name: &nsACString) -> i32 {
- with_metric!(COUNTER_MAP, id, metric, test_get!(metric, ping_name))
+ 0
}
#[no_mangle]
pub extern "C" fn fog_counter_test_get_error(id: u32, error_str: &mut nsACString) -> bool {
- let err = with_metric!(COUNTER_MAP, id, metric, test_get_errors!(metric));
- err.map(|err_str| error_str.assign(&err_str)).is_some()
+ false
}
#[no_mangle]
diff --git a/toolkit/components/glean/api/src/ffi/event.rs b/toolkit/components/glean/api/src/ffi/event.rs
index f75eebdddf32e..a29f92eaba55d 100644
--- a/toolkit/components/glean/api/src/ffi/event.rs
+++ b/toolkit/components/glean/api/src/ffi/event.rs
@@ -15,91 +15,16 @@ pub extern "C" fn fog_event_record(
id: u32,
extra_keys: &ThinVec<nsCString>,
extra_values: &ThinVec<nsCString>,
-) {
- // If no extra keys are passed, we can shortcut here.
- if extra_keys.is_empty() {
- if id & (1 << crate::factory::DYNAMIC_METRIC_BIT) > 0 {
- let map = crate::factory::__jog_metric_maps::EVENT_MAP
- .read()
- .expect("Read lock for dynamic metric map was poisoned");
- match map.get(&id.into()) {
- Some(m) => m.record_raw(Default::default()),
- None => panic!("No (dynamic) metric for event with id {}", id),
- }
- return;
- }
-
- if metric_maps::record_event_by_id(id, Default::default()).is_err() {
- panic!("No event for id {}", id);
- }
-
- return;
- }
-
- assert_eq!(
- extra_keys.len(),
- extra_values.len(),
- "Extra keys and values differ in length. ID: {}",
- id
- );
-
- // Otherwise we need to decode them and pass them along.
- let extra = extra_keys
- .iter()
- .zip(extra_values.iter())
- .map(|(k, v)| (k.to_string(), v.to_string()))
- .collect();
- if id & (1 << crate::factory::DYNAMIC_METRIC_BIT) > 0 {
- let map = crate::factory::__jog_metric_maps::EVENT_MAP
- .read()
- .expect("Read lock for dynamic metric map was poisoned");
- match map.get(&id.into()) {
- Some(m) => m.record_raw(extra),
- None => panic!("No (dynamic) metric for event with id {}", id),
- }
- } else {
- match metric_maps::record_event_by_id(id, extra) {
- Ok(()) => {}
- Err(EventRecordingError::InvalidId) => panic!("No event for id {}", id),
- Err(_) => panic!("Unpossible!"),
- }
- }
-}
+) {}
#[no_mangle]
pub unsafe extern "C" fn fog_event_test_has_value(id: u32, ping_name: &nsACString) -> bool {
- let storage = if ping_name.is_empty() {
- None
- } else {
- Some(ping_name.to_utf8().into_owned())
- };
- if id & (1 << crate::factory::DYNAMIC_METRIC_BIT) > 0 {
- let map = crate::factory::__jog_metric_maps::EVENT_MAP
- .read()
- .expect("Read lock for dynamic metric map was poisoned");
- match map.get(&id.into()) {
- Some(m) => m.test_get_value(storage).is_some(),
- None => panic!("No (dynamic) metric for event with id {}", id),
- }
- } else {
- metric_maps::event_test_get_value_wrapper(id, storage).is_some()
- }
+ false
}
#[no_mangle]
pub extern "C" fn fog_event_test_get_error(id: u32, error_str: &mut nsACString) -> bool {
- let err = if id & (1 << crate::factory::DYNAMIC_METRIC_BIT) > 0 {
- let map = crate::factory::__jog_metric_maps::EVENT_MAP
- .read()
- .expect("Read lock for dynamic metric map was poisoned");
- match map.get(&id.into()) {
- Some(m) => test_get_errors!(m),
- None => panic!("No (dynamic) metric for event with id {}", id),
- }
- } else {
- metric_maps::event_test_get_error(id)
- };
- err.map(|err_str| error_str.assign(&err_str)).is_some()
+ false
}
/// FFI-compatible representation of recorded event data.
@@ -118,48 +43,4 @@ pub extern "C" fn fog_event_test_get_value(
id: u32,
ping_name: &nsACString,
out_events: &mut ThinVec<FfiRecordedEvent>,
-) {
- let storage = if ping_name.is_empty() {
- None
- } else {
- Some(ping_name.to_utf8().into_owned())
- };
-
- let events = if id & (1 << crate::factory::DYNAMIC_METRIC_BIT) > 0 {
- let map = crate::factory::__jog_metric_maps::EVENT_MAP
- .read()
- .expect("Read lock for dynamic metric map was poisoned");
- let events = match map.get(&id.into()) {
- Some(m) => m.test_get_value(storage),
- None => return,
- };
- match events {
- Some(events) => events,
- None => return,
- }
- } else {
- match metric_maps::event_test_get_value_wrapper(id, storage) {
- Some(events) => events,
- None => return,
- }
- };
-
- for event in events {
- let extra = event.extra.unwrap_or_default();
- let extra_len = extra.len();
- let mut extras = ThinVec::with_capacity(extra_len * 2);
- for (k, v) in extra.into_iter() {
- extras.push(nsCString::from(k));
- extras.push(nsCString::from(v));
- }
-
- let event = FfiRecordedEvent {
- timestamp: event.timestamp,
- category: nsCString::from(event.category),
- name: nsCString::from(event.name),
- extras,
- };
-
- out_events.push(event);
- }
-}
+) {}
diff --git a/toolkit/components/glean/api/src/ffi/string.rs b/toolkit/components/glean/api/src/ffi/string.rs
index fc28e03a3860f..a1a4c140b988a 100644
--- a/toolkit/components/glean/api/src/ffi/string.rs
+++ b/toolkit/components/glean/api/src/ffi/string.rs
@@ -8,7 +8,7 @@ use nsstring::nsACString;
#[no_mangle]
pub extern "C" fn fog_string_test_has_value(id: u32, ping_name: &nsACString) -> bool {
- with_metric!(STRING_MAP, id, metric, test_has!(metric, ping_name))
+ false
}
#[no_mangle]
@@ -16,18 +16,12 @@ pub extern "C" fn fog_string_test_get_value(
id: u32,
ping_name: &nsACString,
value: &mut nsACString,
-) {
- let val = with_metric!(STRING_MAP, id, metric, test_get!(metric, ping_name));
- value.assign(&val);
-}
+) {}
#[no_mangle]
-pub extern "C" fn fog_string_set(id: u32, value: &nsACString) {
- with_metric!(STRING_MAP, id, metric, metric.set(value.to_utf8()));
-}
+pub extern "C" fn fog_string_set(id: u32, value: &nsACString) {}
#[no_mangle]
pub extern "C" fn fog_string_test_get_error(id: u32, error_str: &mut nsACString) -> bool {
- let err = with_metric!(STRING_MAP, id, metric, test_get_errors!(metric));
- err.map(|err_str| error_str.assign(&err_str)).is_some()
+ false
}
diff --git a/toolkit/components/glean/build_scripts/glean_parser_ext/rust.py b/toolkit/components/glean/build_scripts/glean_parser_ext/rust.py
index e37f704e502ba..ebaf0e84e4bd1 100644
--- a/toolkit/components/glean/build_scripts/glean_parser_ext/rust.py
+++ b/toolkit/components/glean/build_scripts/glean_parser_ext/rust.py
@@ -299,6 +299,25 @@ def output_rust(objs, output_fd, ping_names_by_app_id, options={}):
else:
template_filename = "rust.jinja2"
objs = get_metrics(objs)
+
+ # copy one metric of each type into a separate list
+ metric_per_type = {}
+ for category_name, category_value in objs.items():
+ for metric in category_value.values():
+ metric_per_type[metric.type] = metric
+
+ # remove types that we stubbed out
+ whitelist = ["fog.ipc"]
+ types_to_remove = ["counter", "event", "string", "boolean"]
+ for category_name, category_value in objs.items():
+ if category_name in whitelist: continue
+ objs[category_name] = {
+ name: metric
+ for name, metric in category_value.items()
+ if metric.type not in types_to_remove
+ }
+ objs['dummy'] = metric_per_type
+
for category_name, category_value in objs.items():
for metric in category_value.values():
# The constant is all uppercase and suffixed by `_MAP`
--
2.54.0