Skip to content

Commit 7372780

Browse files
committed
Rust: Force symbol re-export from libglean_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. As the tests will use libglean_ffi functionality running the tests should ensure this actually happens. See rust-lang/rust#50007
1 parent 849337c commit 7372780

File tree

1 file changed

+18
-0
lines changed

1 file changed

+18
-0
lines changed

glean-core/bundle/src/lib.rs

+18
Original file line numberDiff line numberDiff line change
@@ -3,3 +3,21 @@
33
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
44

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

0 commit comments

Comments
 (0)