# HG changeset patch # User Mike Hommey # Date 1559868423 0 # Node ID f257594fa2949a008ca356c461c995e0f03ed3bb # Parent 4d4dfd3f314818f30b84aee1deb251e175264494 Bug 1557229 - Add `-d16` as a target_feature along `+neon` for rust code. r=nalexander When enabling neon (--with-fpu=neon, or when the C++ compiler defaults to use neon), we pass +neon as a target feature to the rust compiler. That enables neon in rust, which is the default with the thumbv7neon-linux-gnueabihf rust target, but not the default for the armv7-unknown-linux-gnueabihf rust target. ARM processors may have various different FPUs, with different number of registers. On ARMv7, there are FPUs with 16 registers and FPUs with 32 registers. NEON requires 32 registers. Because the common denominator for ARMv7 is 16 registers, the armv7-unknown-linux-gnueabihf rust target defaults to 16 registers, although by enabling neon, we're guaranteed the processor will have 32. But while the rust compiler keeps limited to 16 registers, it also hits a wall while compiling the hyper crate, where it finds it doesn't have enough registers (which in itself can be considered a bug). Since enabling neon means there are 32 registers available, it makes sense to tell the compiler to lift the restricted use of FPU registers, and that's what the `-d16` target feature does. That's the default for the thumbv7neon-linux-gnueabihf rust target, so nothing is changed, there, and fixes things for the armv7-unknown-linux-gnueabihf rust target. Differential Revision: https://phabricator.services.mozilla.com/D33907 diff --git a/config/makefiles/rust.mk b/config/makefiles/rust.mk --- a/config/makefiles/rust.mk +++ b/config/makefiles/rust.mk @@ -61,17 +61,19 @@ endif endif ifdef CARGO_INCREMENTAL export CARGO_INCREMENTAL endif rustflags_neon = ifeq (neon,$(MOZ_FPU)) -rustflags_neon += -C target_feature=+neon +# Enable neon and disable restriction to 16 FPU registers +# (CPUs with neon have 32 FPU registers available) +rustflags_neon += -C target_feature=+neon,-d16 endif rustflags_override = $(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