From ef66d23b4077d528f46ddca2a84981b80be6e0c1 Mon Sep 17 00:00:00 2001 From: Jan-Erik Rediger Date: Thu, 28 May 2026 17:29:13 +0200 Subject: [PATCH] glean-sym: Enable it on iOS by using `this` library This is the equivalent of using `dlsym(RTLD_DEFAULT, name)`, that is: > looking for the desired symbols using the default shared object search order. > The search will include global symbols in the executable and its (from the dlsym(3) man page) --- glean-core/glean-sym/src/lib.rs | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/glean-core/glean-sym/src/lib.rs b/glean-core/glean-sym/src/lib.rs index 583403ef6a..0ab8a12986 100644 --- a/glean-core/glean-sym/src/lib.rs +++ b/glean-core/glean-sym/src/lib.rs @@ -55,20 +55,26 @@ macro_rules! library_binding { } impl GleanSym { - #[cfg(unix)] + #[cfg(all(unix, not(target_os = "ios")))] pub fn load() -> std::io::Result { let name = libloading::library_filename("xul"); let library = match unsafe { libloading::Library::new(name) } { Ok(lib) => Some(lib), Err(_e) => None, }; - // Try each of the libraries, debug-logging load failures. let $localname = library.ok_or_else(|| { std::io::Error::new(std::io::ErrorKind::NotFound, "failed to find glean library") })?; Ok(GleanSym { $($load)* _library: $localname }) } + #[cfg(target_os = "ios")] + pub fn load() -> std::io::Result { + // On iOS we compile it all together and can look up symbols without loading a library + let $localname: libloading::Library = libloading::os::unix::Library::this().into(); + Ok(GleanSym { $($load)* _library: $localname }) + } + #[cfg(not(unix))] pub fn load() -> std::io::Result { compile_error!("This crate is not implemented for Windows");