Bug 1532689: Use Cranelift features to include only architecture-specific support; r=froydnj
☠☠ backed out by 398dfc746ccd ☠ ☠
authorBenjamin Bouvier <benj@benj.me>
Fri, 08 Mar 2019 13:47:35 +0000
changeset 524152 ed3b55f9d32607b2f60156551c627a5b88930373
parent 524151 27136b19341e66034f2cf3ca8d706f91626c4211
child 524153 535960a9513908dd884704e8c7edf7cc71bcb07e
push id2032
push userffxbld-merge
push dateMon, 13 May 2019 09:36:57 +0000
treeherdermozilla-release@455c1065dcbe [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersfroydnj
bugs1532689
milestone67.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 1532689: Use Cranelift features to include only architecture-specific support; r=froydnj This introduces features in the jsrust crate, so we can enable/disable compilation for a specific platform at compile-time. It also does only select the architecture targeted by the JIT, which should result in slightly lower compilation times on every platform, and lower binary sizes too. Differential Revision: https://phabricator.services.mozilla.com/D22280
js/src/rust/Cargo.toml
js/src/rust/moz.build
js/src/rust/shared/Cargo.toml
js/src/wasm/cranelift/Cargo.toml
toolkit/library/rust/Cargo.toml
toolkit/library/rust/gkrust-features.mozbuild
toolkit/library/rust/shared/Cargo.toml
--- a/js/src/rust/Cargo.toml
+++ b/js/src/rust/Cargo.toml
@@ -3,10 +3,16 @@ name = "jsrust"
 version = "0.1.0"
 authors = ["The Spidermonkey developers"]
 
 [lib]
 name = "jsrust"
 crate-type = ["staticlib"]
 path = "lib.rs"
 
+[features]
+cranelift_x86 = ['jsrust_shared/cranelift_x86']
+cranelift_arm32 = ['jsrust_shared/cranelift_arm32']
+cranelift_arm64 = ['jsrust_shared/cranelift_arm64']
+cranelift_none = ['jsrust_shared/cranelift_none']
+
 [dependencies]
 jsrust_shared = { path = "./shared" }
--- a/js/src/rust/moz.build
+++ b/js/src/rust/moz.build
@@ -1,15 +1,26 @@
 # -*- Mode: python; indent-tabs-mode: nil; tab-width: 40 -*-
 # 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/.
 
-RustLibrary('jsrust')
+features = []
+
+if CONFIG['JS_CODEGEN_X64'] or CONFIG['JS_CODEGEN_X86']:
+    features += ['cranelift_x86']
+elif CONFIG['JS_CODEGEN_ARM']:
+    features += ['cranelift_arm32']
+elif CONFIG['JS_CODEGEN_ARM64']:
+    features += ['cranelift_arm64']
+else:
+    features += ['cranelift_none']
+
+RustLibrary('jsrust', features)
 
 CONFIGURE_SUBST_FILES += ['extra-bindgen-flags']
 
 if CONFIG['JS_SHARED_LIBRARY']:
     FINAL_LIBRARY = 'js'
 
 if CONFIG['OS_ARCH'] == 'Darwin':
     # The Rust standard library references libresolv on macOS, so we need to
--- a/js/src/rust/shared/Cargo.toml
+++ b/js/src/rust/shared/Cargo.toml
@@ -7,11 +7,17 @@ authors = ["The Spidermonkey developers"
 crate-type = ["rlib"]
 name = "jsrust_shared"
 path = "lib.rs"
 
 [dependencies]
 baldrdash = { path = "../../wasm/cranelift" }
 mozilla-central-workspace-hack = { path = "../../../../build/workspace-hack" }
 
+[features]
+cranelift_x86 = ['baldrdash/cranelift_x86']
+cranelift_arm32 = ['baldrdash/cranelift_arm32']
+cranelift_arm64 = ['baldrdash/cranelift_arm64']
+cranelift_none = ['baldrdash/cranelift_none']
+
 # Uncomment this to enable perf support in release mode.
 #[profile.release]
 #debug = true
--- a/js/src/wasm/cranelift/Cargo.toml
+++ b/js/src/wasm/cranelift/Cargo.toml
@@ -3,20 +3,30 @@ name = "baldrdash"
 version = "0.1.0"
 authors = ["The Spidermonkey and Cranelift developers"]
 
 [lib]
 crate-type = ["rlib"]
 name = "baldrdash"
 
 [dependencies]
-cranelift-codegen = "0.29.0"
+cranelift-codegen = { version = "0.29.0", default-features = false }
 cranelift-wasm = "0.29.0"
 target-lexicon = "0.2.0"
 log = { version = "0.4.6", default-features = false, features = ["release_max_level_info"] }
 env_logger = "0.5.6"
 
 [build-dependencies]
 bindgen = {version = "0.43", default-features = false} # disable `logging` to reduce code size
 
+[features]
+default = ['cranelift-codegen/std']
+cranelift_x86 = ['cranelift-codegen/x86']
+cranelift_arm32 = ['cranelift-codegen/arm32']
+cranelift_arm64 = ['cranelift-codegen/arm64']
+
+# The "none" support is a lie (so far): Cranelift has to include support for
+# one ISA at the moment, so request to include support for a small one: riscv.
+cranelift_none = ['cranelift-codegen/riscv']
+
 # Uncomment this to enable perf support in release mode.
 #[profile.release]
 #debug = true
--- a/toolkit/library/rust/Cargo.toml
+++ b/toolkit/library/rust/Cargo.toml
@@ -10,16 +10,20 @@ 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"]
 simd-accel = ["gkrust-shared/simd-accel"]
 moz_memory = ["gkrust-shared/moz_memory"]
 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"]
 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]
--- a/toolkit/library/rust/gkrust-features.mozbuild
+++ b/toolkit/library/rust/gkrust-features.mozbuild
@@ -23,14 +23,22 @@ if CONFIG['MOZ_RUST_SIMD']:
 if (CONFIG['OS_ARCH'] == 'Linux' and CONFIG['OS_TARGET'] != 'Android') or CONFIG['OS_ARCH'] == 'Darwin' or (CONFIG['OS_ARCH'] == 'WINNT' and CONFIG['CPU_ARCH'] != 'aarch64'):
     gkrust_features += ['cubeb-remoting']
 
 if CONFIG['MOZ_MEMORY']:
     gkrust_features += ['moz_memory']
 
 if CONFIG['ENABLE_WASM_CRANELIFT']:
     gkrust_features += ['spidermonkey_rust']
+    if CONFIG['JS_CODEGEN_X86'] or CONFIG['JS_CODEGEN_X64']:
+        gkrust_features += ['cranelift_x86']
+    elif CONFIG['JS_CODEGEN_ARM']:
+        gkrust_features += ['cranelift_arm32']
+    elif CONFIG['JS_CODEGEN_ARM64']:
+        gkrust_features += ['cranelift_arm64']
+    else:
+        gkrust_features += ['cranelift_none']
 
 if CONFIG['MOZ_GECKO_PROFILER']:
     gkrust_features += ['gecko_profiler']
 
 if CONFIG['MOZ_GECKO_PROFILER_PARSE_ELF']:
     gkrust_features += ['gecko_profiler_parse_elf']
--- a/toolkit/library/rust/shared/Cargo.toml
+++ b/toolkit/library/rust/shared/Cargo.toml
@@ -42,16 +42,20 @@ bindgen = ["geckoservo/bindgen"]
 servo = ["geckoservo"]
 quantum_render = ["webrender_bindings"]
 cubeb-remoting = ["cubeb-sys", "audioipc-client", "audioipc-server"]
 cubeb_pulse_rust = ["cubeb-sys", "cubeb-pulse"]
 gecko_debug = ["geckoservo/gecko_debug", "nsstring/gecko_debug"]
 simd-accel = ["encoding_c/simd-accel", "encoding_glue/simd-accel"]
 moz_memory = ["mp4parse_capi/mp4parse_fallible"]
 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"]
 gecko_profiler = ["profiler_helper"]
 gecko_profiler_parse_elf = ["profiler_helper/parse_elf"]
 
 [lib]
 path = "lib.rs"
 test = false
 doctest = false
 bench = false