Skip to content
Permalink
Browse files

style: Rejigger a bit rust features so that rusttests still link.

We cannot compile with just feature(gecko + debug_assertions), since that's how
debug rusttests get compiled and they don't have the refcount logging stuff.

We were getting away with it for the pre-existing usage of the style crate,
because it wasn't used during any test and presumably the linker didn't
complain. But servo_arc is definitely used in tests.

Differential Revision: https://phabricator.services.mozilla.com/D32691
  • Loading branch information...
emilio committed May 27, 2019
1 parent 9a9a4e1 commit 3652a0f1e1babfdb3906803b9a081d7e42e8b2d8
@@ -12,7 +12,7 @@ path = "lib.rs"

[features]
servo = ["serde"]
gecko = []
gecko_refcount_logging = []

[dependencies]
nodrop = {version = "0.1.8"}
@@ -177,7 +177,7 @@ impl<T> Arc<T> {
data,
}));

#[cfg(all(feature = "gecko", debug_assertions))]
#[cfg(feature = "gecko_refcount_logging")]
unsafe {
// FIXME(emilio): Would be so amazing to have
// std::intrinsics::type_name() around, so that we could also report
@@ -312,7 +312,7 @@ impl<T: ?Sized> Arc<T> {

#[inline(always)]
fn record_drop(&self) {
#[cfg(all(feature = "gecko", debug_assertions))]
#[cfg(feature = "gecko_refcount_logging")]
unsafe {
NS_LogDtor(self.ptr() as *const _, b"ServoArc\0".as_ptr() as *const _, 8);
}
@@ -348,7 +348,7 @@ impl<T: ?Sized> Arc<T> {
}
}

#[cfg(all(feature = "gecko", debug_assertions))]
#[cfg(feature = "gecko_refcount_logging")]
extern "C" {
fn NS_LogCtor(aPtr: *const std::os::raw::c_void, aTypeName: *const std::os::raw::c_char, aSize: u32);
fn NS_LogDtor(aPtr: *const std::os::raw::c_void, aTypeName: *const std::os::raw::c_char, aSize: u32);
@@ -745,7 +745,7 @@ impl<H, T> Arc<HeaderSlice<H, [T]>> {
);
}

#[cfg(all(feature = "gecko", debug_assertions))]
#[cfg(feature = "gecko_refcount_logging")]
unsafe {
if !is_static {
// FIXME(emilio): Would be so amazing to have
@@ -22,6 +22,7 @@ servo = ["serde", "style_traits/servo", "servo_atoms", "servo_config", "html5eve
"cssparser/serde", "encoding_rs", "malloc_size_of/servo", "arrayvec/use_union",
"servo_url", "string_cache", "crossbeam-channel", "to_shmem/servo", "servo_arc/servo"]
gecko_debug = []
gecko_refcount_logging = []
gecko_profiler = []

[dependencies]
@@ -755,7 +755,7 @@ unsafe impl Sync for RuleTree {}
unsafe impl Send for RuleTree {}

// On Gecko builds, hook into the leak checking machinery.
#[cfg(all(feature = "gecko", debug_assertions))]
#[cfg(feature = "gecko_refcount_logging")]
mod gecko_leak_checking {
use super::RuleNode;
use std::mem::size_of;
@@ -788,13 +788,13 @@ mod gecko_leak_checking {

#[inline(always)]
fn log_new(_ptr: *const RuleNode) {
#[cfg(all(feature = "gecko", debug_assertions))]
#[cfg(feature = "gecko_refcount_logging")]
gecko_leak_checking::log_ctor(_ptr);
}

#[inline(always)]
fn log_drop(_ptr: *const RuleNode) {
#[cfg(all(feature = "gecko", debug_assertions))]
#[cfg(feature = "gecko_refcount_logging")]
gecko_leak_checking::log_dtor(_ptr);
}

0 comments on commit 3652a0f

Please sign in to comment.
You can’t perform that action at this time.