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

--HG--
extra : moz-landing-system : lando
This commit is contained in:
Benjamin Bouvier 2019-03-11 13:09:58 +00:00
Родитель fb98cd9527
Коммит 48f0d69763
8 изменённых файлов: 55 добавлений и 2 удалений

Просмотреть файл

@ -8,5 +8,11 @@ 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" }

Просмотреть файл

@ -4,7 +4,18 @@
# 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']

Просмотреть файл

@ -12,6 +12,12 @@ path = "lib.rs"
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

Просмотреть файл

@ -8,7 +8,7 @@ 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"] }
@ -17,6 +17,16 @@ 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

Просмотреть файл

@ -15,6 +15,10 @@ 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"]

Просмотреть файл

@ -15,6 +15,10 @@ 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"]

Просмотреть файл

@ -28,6 +28,14 @@ if CONFIG['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']

Просмотреть файл

@ -47,6 +47,10 @@ 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"]