Bug 1397807 - Allow rustc to emit NEON instructions when clang does on ARMv7 and use NEON in encoding_rs. draft
authorHenri Sivonen <hsivonen@hsivonen.fi>
Tue, 05 Jun 2018 14:56:11 +0300
changeset 814082 03b10d41d8a00ae6a80b82e26d7c2ddeafe9cb17
parent 813052 15c9eddbb3312d7fc2a852cb6d9ec5ec12700f7f
push id115085
push userbmo:hsivonen@hsivonen.fi
push dateWed, 04 Jul 2018 12:27:42 +0000
bugs1397807
milestone63.0a1
Bug 1397807 - Allow rustc to emit NEON instructions when clang does on ARMv7 and use NEON in encoding_rs. MozReview-Commit-ID: LNd4jeIGIRg
build/autoconf/arch.m4
config/rules.mk
toolkit/moz.configure
--- a/build/autoconf/arch.m4
+++ b/build/autoconf/arch.m4
@@ -262,10 +262,11 @@ if test "$CPU_ARCH" = "arm"; then
 
 fi # CPU_ARCH = arm
 
 AC_SUBST(HAVE_ARM_SIMD)
 AC_SUBST(HAVE_ARM_NEON)
 AC_SUBST(BUILD_ARM_NEON)
 AC_SUBST(ARM_ARCH)
 AC_SUBST_LIST(NEON_FLAGS)
+AC_SUBST(MOZ_FPU)
 
 ])
--- a/config/rules.mk
+++ b/config/rules.mk
@@ -842,17 +842,22 @@ ifndef MOZ_DEBUG_RUST
 cargo_rustc_flags += -C lto
 endif
 endif
 
 ifdef CARGO_INCREMENTAL
 cargo_incremental := CARGO_INCREMENTAL=$(CARGO_INCREMENTAL)
 endif
 
-rustflags_override = RUSTFLAGS='$(MOZ_RUST_DEFAULT_FLAGS) $(RUSTFLAGS)'
+rustflags_neon =
+ifeq (neon,$(MOZ_FPU))
+rustflags_neon += -C target_feature=+neon
+endif
+
+rustflags_override = RUSTFLAGS='$(MOZ_RUST_DEFAULT_FLAGS) $(RUSTFLAGS) $(rustflags_neon)'
 
 ifdef MOZ_MSVCBITS
 # If we are building a MozillaBuild shell, we want to clear out the
 # vcvars.bat environment variables for cargo builds. This is because
 # a 32-bit MozillaBuild shell on a 64-bit machine will try to use
 # the 32-bit compiler/linker for everything, while cargo/rustc wants
 # to use the 64-bit linker for build.rs scripts. This conflict results
 # in a build failure (see bug 1350001). So we clear out the environment
--- a/toolkit/moz.configure
+++ b/toolkit/moz.configure
@@ -837,20 +837,19 @@ set_config('MOZ_ENABLE_WEBRENDER', webre
 
 # SIMD acceleration for Rust code (currently just encoding_rs)
 
 option('--enable-rust-simd', env='MOZ_RUST_SIMD',
        help='Enable explicit SIMD in Rust code.')
 
 @depends('--enable-rust-simd', target)
 def rust_simd(value, target):
-    # As of 2017-06-13, the simd crate only works on aarch64,
-    # x86 and x86_64. It's meant to work on 32-bit ARM, too,
-    # but currently does not.
-    if target.cpu in ('aarch64', 'x86', 'x86_64') and value:
+    # As of 2018-06-05, the simd crate only works on aarch64,
+    # armv7, x86 and x86_64.
+    if target.cpu in ('aarch64', 'arm', 'x86', 'x86_64') and value:
         return True
 
 set_config('MOZ_RUST_SIMD', rust_simd)
 set_define('MOZ_RUST_SIMD', rust_simd)
 
 # Printing
 # ==============================================================
 @depends(target)