Bug 1499196 - Introduce a mozilla-central-workspace-hack crate to unify features seen by rust deps. r=ted,firefox-build-system-reviewers
authorChris Manchester <cmanchester@mozilla.com>
Thu, 18 Oct 2018 10:39:05 +0000
changeset 443651 e1c9e5aec40a2ee8b1b3affddd72618016719018
parent 443650 afa1cebbba882b70f4f8952236c4fd6594a3e650
child 443652 d5c6b95843e380e6fd7870d9e7d3847ff331888f
push id34964
push useraciure@mozilla.com
push dateWed, 31 Oct 2018 05:08:54 +0000
treeherdermozilla-central@1c5ee1a29757 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersted, firefox-build-system-reviewers
bugs1499196
milestone65.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 1499196 - Introduce a mozilla-central-workspace-hack crate to unify features seen by rust deps. r=ted,firefox-build-system-reviewers This is the equivalent of the rustc-workspace-hack used by the rust build to ensure cargo and RLS see the same set of features for dependencies so that these dependencies may be reused by invocations of cargo for these two projects. The trivial crate added specifies the union of the set of features activated for a particular crate for each time it appears in the dependency tree so that cargo will understand these dependencies to be re-usable across cargo implementations. This eliminates re-building jsrust and some of its dependencies twice, and reduces the number of crates compiled in the tree by about 90 in testing on linux. Differential Revision: https://phabricator.services.mozilla.com/D9041
Cargo.lock
build/workspace-hack/Cargo.toml
build/workspace-hack/src/lib.rs
js/src/rust/Cargo.toml
toolkit/library/rust/Cargo.toml
--- a/Cargo.lock
+++ b/Cargo.lock
@@ -1007,16 +1007,17 @@ dependencies = [
  "typenum 1.10.0 (registry+https://github.com/rust-lang/crates.io-index)",
 ]
 
 [[package]]
 name = "gkrust"
 version = "0.1.0"
 dependencies = [
  "gkrust-shared 0.1.0",
+ "mozilla-central-workspace-hack 0.1.0",
  "stylo_tests 0.0.1",
 ]
 
 [[package]]
 name = "gkrust-gtest"
 version = "0.1.0"
 dependencies = [
  "bench-collections-gtest 0.1.0",
@@ -1218,16 +1219,17 @@ dependencies = [
  "num-traits 0.1.43 (registry+https://github.com/rust-lang/crates.io-index)",
 ]
 
 [[package]]
 name = "jsrust"
 version = "0.1.0"
 dependencies = [
  "jsrust_shared 0.1.0",
+ "mozilla-central-workspace-hack 0.1.0",
 ]
 
 [[package]]
 name = "jsrust_shared"
 version = "0.1.0"
 dependencies = [
  "baldrdash 0.1.0",
  "bindgen 0.43.0 (registry+https://github.com/rust-lang/crates.io-index)",
@@ -1535,16 +1537,30 @@ dependencies = [
 ]
 
 [[package]]
 name = "moz_cbor"
 version = "0.1.1"
 source = "registry+https://github.com/rust-lang/crates.io-index"
 
 [[package]]
+name = "mozilla-central-workspace-hack"
+version = "0.1.0"
+dependencies = [
+ "log 0.4.5 (registry+https://github.com/rust-lang/crates.io-index)",
+ "proc-macro2 0.3.5 (registry+https://github.com/rust-lang/crates.io-index)",
+ "quote 0.5.2 (registry+https://github.com/rust-lang/crates.io-index)",
+ "serde 1.0.66 (registry+https://github.com/rust-lang/crates.io-index)",
+ "serde_derive 1.0.66 (git+https://github.com/servo/serde?branch=deserialize_from_enums8)",
+ "syn 0.14.6 (registry+https://github.com/rust-lang/crates.io-index)",
+ "void 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)",
+ "winapi 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)",
+]
+
+[[package]]
 name = "mozjs_sys"
 version = "0.0.0"
 dependencies = [
  "glob 0.2.11 (registry+https://github.com/rust-lang/crates.io-index)",
  "libc 0.2.43 (registry+https://github.com/rust-lang/crates.io-index)",
  "libz-sys 1.0.16 (registry+https://github.com/rust-lang/crates.io-index)",
  "num_cpus 1.7.0 (registry+https://github.com/rust-lang/crates.io-index)",
 ]
new file mode 100644
--- /dev/null
+++ b/build/workspace-hack/Cargo.toml
@@ -0,0 +1,58 @@
+[package]
+name = "mozilla-central-workspace-hack"
+version = "0.1.0"
+
+# This is a hack to help rust code in the tree that are built by different
+# invocations of cargo share dependencies rather than rebuilding them. This is
+# based on the "rustc-workspace-hack" used by the rustc build system to achieve
+# the same. From the description of the issue given there:
+#
+#  "Each time Cargo runs a build it will re-resolve the dependency graph, "
+#  "notably selecting different features sometimes for each build."
+#
+# We work around this by specifying the union of the set of features selected
+# by dependencies in each cargo invocation for each instance they would differ.
+
+[build-dependencies]
+void = { features = ["std", "default"], version = "1.0.2" }
+syn = { features = ["extra-traits", "fold", "full"],  version = "0.14" }
+log = { features = ["release_max_level_info", "release_max_level_warn", "std"],  version = "0.4.5" }
+serde = { features = ["default", "rc", "serde_derive", "std"], version = "1.0.66" }
+serde_derive = { features = ["default", "deserialize_in_place"], version = "1.0.66" }
+quote = { features = ["default", "proc-macro"], version = "0.5.2" }
+proc-macro2 = { features = ["default", "proc-macro"], version = "0.3.5" }
+
+[target."cfg(windows)".dependencies.winapi]
+version = "0.3.6"
+features = [
+    "basetsd",
+    "consoleapi",
+    "dwrite",
+    "dwrite_1",
+    "dwrite_3",
+    "errhandlingapi",
+    "fileapi",
+    "handleapi",
+    "hidclass",
+    "hidpi",
+    "hidusage",
+    "libloaderapi",
+    "memoryapi",
+    "minwinbase",
+    "minwindef",
+    "ntdef",
+    "ntsecapi",
+    "ntstatus",
+    "processenv",
+    "profileapi",
+    "setupapi",
+    "std",
+    "sysinfoapi",
+    "timezoneapi",
+    "unknwnbase",
+    "winbase",
+    "wincon",
+    "winerror",
+    "winnls",
+    "winnt"
+]
new file mode 100644
--- /dev/null
+++ b/build/workspace-hack/src/lib.rs
@@ -0,0 +1,7 @@
+#[cfg(test)]
+mod tests {
+    #[test]
+    fn it_works() {
+        assert_eq!(2 + 2, 4);
+    }
+}
--- a/js/src/rust/Cargo.toml
+++ b/js/src/rust/Cargo.toml
@@ -5,8 +5,9 @@ authors = ["The Spidermonkey developers"
 
 [lib]
 name = "jsrust"
 crate-type = ["staticlib"]
 path = "lib.rs"
 
 [dependencies]
 jsrust_shared = { path = "./shared" }
+mozilla-central-workspace-hack = { path = "../../../build/workspace-hack" }
--- a/toolkit/library/rust/Cargo.toml
+++ b/toolkit/library/rust/Cargo.toml
@@ -15,16 +15,17 @@ gecko_debug = ["gkrust-shared/gecko_debu
 simd-accel = ["gkrust-shared/simd-accel"]
 moz_memory = ["gkrust-shared/moz_memory"]
 spidermonkey_rust = ["gkrust-shared/spidermonkey_rust"]
 gecko_profiler = ["gkrust-shared/gecko_profiler"]
 gecko_profiler_parse_elf = ["gkrust-shared/gecko_profiler_parse_elf"]
 
 [dependencies]
 gkrust-shared = { path = "shared" }
+mozilla-central-workspace-hack = { path = "../../../build/workspace-hack" }
 
 [dev-dependencies]
 stylo_tests = { path = "../../../servo/ports/geckolib/tests/" }
 
 [lib]
 path = "lib.rs"
 crate-type = ["staticlib"]
 test = false