Bug 1552080 - Rejigger a bit rust features so that rusttests still link. r=froydnj
authorEmilio Cobos Álvarez <emilio@crisal.io>
Mon, 27 May 2019 14:56:08 +0200
changeset 476126 0a53924e724918efd09679b74fd3f48b737084bd
parent 476125 0edd8c43147130a2b0d3acbcde5d53d4b4f6aaf4
child 476127 b860b13c8eae8d8eeb363c21f2aa3c1430e0301b
push id86675
push useremilio@crisal.io
push dateWed, 29 May 2019 19:32:14 +0000
treeherderautoland@0a53924e7249 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersfroydnj
bugs1552080
milestone69.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1552080 - Rejigger a bit rust features so that rusttests still link. r=froydnj 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
servo/components/servo_arc/Cargo.toml
servo/components/servo_arc/lib.rs
servo/components/style/Cargo.toml
servo/components/style/rule_tree/mod.rs
servo/ports/geckolib/Cargo.toml
toolkit/library/gtest/rust/Cargo.toml
toolkit/library/rust/Cargo.toml
toolkit/library/rust/gkrust-features.mozbuild
toolkit/library/rust/moz.build
toolkit/library/rust/shared/Cargo.toml
--- a/servo/components/servo_arc/Cargo.toml
+++ b/servo/components/servo_arc/Cargo.toml
@@ -7,14 +7,14 @@ repository = "https://github.com/servo/s
 description = "A fork of std::sync::Arc with some extra functionality and without weak references"
 
 [lib]
 name = "servo_arc"
 path = "lib.rs"
 
 [features]
 servo = ["serde"]
-gecko = []
+gecko_refcount_logging = []
 
 [dependencies]
 nodrop = {version = "0.1.8"}
 serde = {version = "1.0", optional = true}
 stable_deref_trait = "1.0.0"
--- a/servo/components/servo_arc/lib.rs
+++ b/servo/components/servo_arc/lib.rs
@@ -172,17 +172,17 @@ impl<T> Arc<T> {
     /// Construct an `Arc<T>`
     #[inline]
     pub fn new(data: T) -> Self {
         let ptr = Box::into_raw(Box::new(ArcInner {
             count: atomic::AtomicUsize::new(1),
             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
             // a real size.
             NS_LogCtor(ptr as *const _, b"ServoArc\0".as_ptr() as *const _, 8);
         }
 
         unsafe {
@@ -307,17 +307,17 @@ impl<T: ?Sized> Arc<T> {
         // `ArcInner` structure itself is `Sync` because the inner data is
         // `Sync` as well, so we're ok loaning out an immutable pointer to these
         // contents.
         unsafe { &*self.ptr() }
     }
 
     #[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);
         }
     }
 
     /// Marks this `Arc` as intentionally leaked for the purposes of refcount
     /// logging.
     ///
@@ -343,17 +343,17 @@ impl<T: ?Sized> Arc<T> {
         this.ptr() == other.ptr()
     }
 
     fn ptr(&self) -> *mut ArcInner<T> {
         self.p.as_ptr()
     }
 }
 
-#[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);
 }
 
 impl<T: ?Sized> Clone for Arc<T> {
     #[inline]
     fn clone(&self) -> Self {
@@ -740,17 +740,17 @@ impl<H, T> Arc<HeaderSlice<H, [T]>> {
                 );
             }
             assert!(
                 items.next().is_none(),
                 "ExactSizeIterator under-reported length"
             );
         }
 
-        #[cfg(all(feature = "gecko", debug_assertions))]
+        #[cfg(feature = "gecko_refcount_logging")]
         unsafe {
             if !is_static {
                 // FIXME(emilio): Would be so amazing to have
                 // std::intrinsics::type_name() around.
                 NS_LogCtor(ptr as *const _, b"ServoArc\0".as_ptr() as *const _, 8)
             }
         }
 
--- a/servo/components/style/Cargo.toml
+++ b/servo/components/style/Cargo.toml
@@ -11,22 +11,23 @@ build = "build.rs"
 links = "for some reason the links key is required to pass data around between build scripts"
 
 [lib]
 name = "style"
 path = "lib.rs"
 doctest = false
 
 [features]
-gecko = ["nsstring", "servo_arc/gecko", "style_traits/gecko", "fallible/known_system_malloc"]
+gecko = ["nsstring", "style_traits/gecko", "fallible/known_system_malloc"]
 use_bindgen = ["bindgen", "regex", "toml"]
 servo = ["serde", "style_traits/servo", "servo_atoms", "servo_config", "html5ever",
          "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]
 app_units = "0.7"
 arrayvec = "0.4.6"
 atomic_refcell = "0.1"
 bitflags = "1.0"
 byteorder = "1.0"
--- a/servo/components/style/rule_tree/mod.rs
+++ b/servo/components/style/rule_tree/mod.rs
@@ -750,17 +750,17 @@ pub struct RuleNode {
     /// synchronously.
     next_free: AtomicPtr<RuleNode>,
 }
 
 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;
     use std::os::raw::{c_char, c_void};
 
     extern "C" {
         pub fn NS_LogCtor(aPtr: *const c_void, aTypeName: *const c_char, aSize: u32);
         pub fn NS_LogDtor(aPtr: *const c_void, aTypeName: *const c_char, aSize: u32);
@@ -783,23 +783,23 @@ mod gecko_leak_checking {
             NS_LogDtor(ptr as *const c_void, s, size_of::<RuleNode>() as u32);
         }
     }
 
 }
 
 #[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);
 }
 
 impl RuleNode {
     fn new(
         root: WeakRuleNode,
         parent: StrongRuleNode,
         source: StyleSource,
--- a/servo/ports/geckolib/Cargo.toml
+++ b/servo/ports/geckolib/Cargo.toml
@@ -7,16 +7,17 @@ license = "MPL-2.0"
 [lib]
 name = "geckoservo"
 path = "lib.rs"
 
 [features]
 bindgen = ["style/use_bindgen"]
 gecko_debug = ["style/gecko_debug", "nsstring/gecko_debug"]
 gecko_profiler = ["style/gecko_profiler"]
+gecko_refcount_logging = ["style/gecko_refcount_logging", "servo_arc/gecko_refcount_logging"]
 
 [dependencies]
 atomic_refcell = "0.1"
 cssparser = "0.25"
 cstr = "0.1.2"
 libc = "0.2"
 log = {version = "0.4", features = ["release_max_level_info"]}
 malloc_size_of = {path = "../../components/malloc_size_of"}
--- a/toolkit/library/gtest/rust/Cargo.toml
+++ b/toolkit/library/gtest/rust/Cargo.toml
@@ -7,16 +7,17 @@ description = "Testing code for libgkrus
 
 [features]
 bindgen = ["gkrust-shared/bindgen"]
 servo = ["gkrust-shared/servo"]
 quantum_render = ["gkrust-shared/quantum_render"]
 cubeb-remoting = ["gkrust-shared/cubeb-remoting"]
 cubeb_pulse_rust = ["gkrust-shared/cubeb_pulse_rust"]
 gecko_debug = ["gkrust-shared/gecko_debug"]
+gecko_refcount_logging = ["gkrust-shared/gecko_refcount_logging"]
 simd-accel = ["gkrust-shared/simd-accel"]
 moz_memory = ["gkrust-shared/moz_memory"]
 moz_places = ["gkrust-shared/moz_places"]
 spidermonkey_rust = ["gkrust-shared/spidermonkey_rust"]
 cranelift_x86 = ["gkrust-shared/cranelift_x86"]
 cranelift_arm32 = ["gkrust-shared/cranelift_arm32"]
 cranelift_arm64 = ["gkrust-shared/cranelift_arm64"]
 cranelift_none = ["gkrust-shared/cranelift_none"]
--- a/toolkit/library/rust/Cargo.toml
+++ b/toolkit/library/rust/Cargo.toml
@@ -8,16 +8,17 @@ description = "Rust code for libxul"
 [features]
 bindgen = ["gkrust-shared/bindgen"]
 servo = ["gkrust-shared/servo"]
 quantum_render = ["gkrust-shared/quantum_render"]
 webrender_debugger = ["gkrust-shared/webrender_debugger"]
 cubeb-remoting = ["gkrust-shared/cubeb-remoting"]
 cubeb_pulse_rust = ["gkrust-shared/cubeb_pulse_rust"]
 gecko_debug = ["gkrust-shared/gecko_debug"]
+gecko_refcount_logging = ["gkrust-shared/gecko_refcount_logging"]
 simd-accel = ["gkrust-shared/simd-accel"]
 moz_memory = ["gkrust-shared/moz_memory"]
 moz_places = ["gkrust-shared/moz_places"]
 spidermonkey_rust = ["gkrust-shared/spidermonkey_rust"]
 cranelift_x86 = ["gkrust-shared/cranelift_x86"]
 cranelift_arm32 = ["gkrust-shared/cranelift_arm32"]
 cranelift_arm64 = ["gkrust-shared/cranelift_arm64"]
 cranelift_none = ["gkrust-shared/cranelift_none"]
--- a/toolkit/library/rust/gkrust-features.mozbuild
+++ b/toolkit/library/rust/gkrust-features.mozbuild
@@ -2,17 +2,20 @@
 # vim: set filetype=python:
 # This Source Code Form is subject to the terms of the Mozilla Public
 # License, v. 2.0. If a copy of the MPL was not distributed with this
 # file, You can obtain one at http://mozilla.org/MPL/2.0/.
 
 gkrust_features = ['servo', 'bindgen']
 
 if CONFIG['MOZ_DEBUG']:
-    gkrust_features += ['gecko_debug']
+    gkrust_features += [
+        'gecko_debug',
+        'gecko_refcount_logging',
+    ]
 
 if CONFIG['MOZ_BUILD_WEBRENDER']:
     gkrust_features += ['quantum_render']
     if CONFIG['MOZ_WEBRENDER_DEBUGGER']:
         gkrust_features += ['webrender_debugger']
 
 if CONFIG['MOZ_PULSEAUDIO']:
     gkrust_features += ['cubeb_pulse_rust']
--- a/toolkit/library/rust/moz.build
+++ b/toolkit/library/rust/moz.build
@@ -10,17 +10,22 @@ RustLibrary('gkrust', gkrust_features)
 
 # Target directory doesn't matter a lot here, since we can't share panic=abort
 # compilation artifacts with gkrust.
 RUST_TESTS = [
     'selectors',
     'servo_arc',
     'stylo_tests',
 ]
-RUST_TEST_FEATURES = gkrust_features
+
+for feature in gkrust_features:
+    # We don't want to enable refcount logging during rusttests, since the
+    # relevant FFI symbols wouldn't be found.
+    if feature != 'gecko_refcount_logging':
+        RUST_TEST_FEATURES.append(feature)
 
 if CONFIG['CPU_ARCH'] != 'x86':
     # malloc_size_of_derive is a build dependency, so if we are doing
     # cross-compile for x86, this may not run correctly.
     RUST_TESTS += ['malloc_size_of_derive']
 
 if CONFIG['MOZ_BITS_DOWNLOAD']:
     RUST_TESTS += ['bits_client']
--- a/toolkit/library/rust/shared/Cargo.toml
+++ b/toolkit/library/rust/shared/Cargo.toml
@@ -46,16 +46,17 @@ rustc_version = "0.2"
 default = []
 bindgen = ["geckoservo/bindgen"]
 servo = ["geckoservo"]
 quantum_render = ["webrender_bindings"]
 webrender_debugger = ["webrender_bindings/webrender_debugger"]
 cubeb-remoting = ["cubeb-sys", "audioipc-client", "audioipc-server"]
 cubeb_pulse_rust = ["cubeb-sys", "cubeb-pulse"]
 gecko_debug = ["geckoservo/gecko_debug", "nsstring/gecko_debug"]
+gecko_refcount_logging = ["geckoservo/gecko_refcount_logging"]
 simd-accel = ["encoding_c/simd-accel", "encoding_glue/simd-accel"]
 moz_memory = ["mp4parse_capi/mp4parse_fallible"]
 moz_places = ["bookmark_sync"]
 spidermonkey_rust = ["jsrust_shared"]
 cranelift_x86 = ["jsrust_shared/cranelift_x86"]
 cranelift_arm32 = ["jsrust_shared/cranelift_arm32"]
 cranelift_arm64 = ["jsrust_shared/cranelift_arm64"]
 cranelift_none = ["jsrust_shared/cranelift_none"]