Skip to content

Commit

Permalink
Bug 1670261 - Upgrade Glean, include glean-ffi and re-export its symb…
Browse files Browse the repository at this point in the history
…ols. r=chutten

Differential Revision: https://phabricator.services.mozilla.com/D121084
  • Loading branch information
badboy committed Aug 10, 2021
1 parent e416eff commit 64a64d2
Show file tree
Hide file tree
Showing 4 changed files with 32 additions and 3 deletions.
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -105,4 +105,4 @@ path = "third_party/rust/mio"

# Patch failure 0.1.8 to disable the backtrace feature by default. See bug 1608157.
[patch.crates-io.failure]
path = "third_party/rust/failure"
path = "third_party/rust/failure"
11 changes: 10 additions & 1 deletion toolkit/components/glean/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,16 @@ edition = "2018"
license = "MPL-2.0"

[dependencies]
glean = { version = "39.0.0", features = ["rkv-safe-mode"] }
glean = { version = "40.0.0", features = ["rkv-safe-mode"] }
# In theory we only need this for `target_os = "android"` builds.
# Cargo has the ability to do that with `[target.'cfg(target_os = "android")'.dependencies]`.
# However that seems to confuse `cbindgen` quite a lot;
# it suddenly starts generating completely unrelated code and not adhering to the cbindgen.toml configuration
# placed next to this file.
# So for now we unconditionally depend on it, but in the code we only `extern crate` it on Android builds.
# While `glean-ffi` is still built (I think it is),
# it's not linked into the final library.
glean-ffi = "40.0.0"
log = "0.4"
nserror = { path = "../../../xpcom/rust/nserror" }
nsstring = { path = "../../../xpcom/rust/nsstring" }
Expand Down
2 changes: 1 addition & 1 deletion toolkit/components/glean/api/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ publish = false
[dependencies]
bincode = "1.0"
chrono = "0.4.10"
glean = "39.0.0"
glean = "40.0.0"
inherent = "0.1.4"
log = "0.4"
nsstring = { path = "../../../../xpcom/rust/nsstring", optional = true }
Expand Down
20 changes: 20 additions & 0 deletions toolkit/components/glean/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,26 @@
// compiled.
pub extern crate fog;

pub use glean_ffi;

/// Workaround to force a re-export of the `no_mangle` symbols from `glean_ffi`
///
/// Due to how linking works and hides symbols the symbols from `glean_ffi` might not be
/// re-exported and thus not usable.
/// By forcing use of _at least one_ symbol in an exported function the functions will also be
/// rexported.
/// This is only required for debug builds (and `debug_assertions` is the closest thing we have to
/// check that).
/// In release builds we rely on LTO builds to take care of it.
/// Our tests should ensure this actually happens.
///
/// See https://github.com/rust-lang/rust/issues/50007
#[cfg(debug_assertions)]
#[no_mangle]
pub unsafe extern "C" fn _fog_force_reexport_donotcall() {
glean_ffi::glean_enable_logging();
}

#[macro_use]
extern crate cstr;
#[macro_use]
Expand Down

0 comments on commit 64a64d2

Please sign in to comment.