From be5db14160e2aa04a64f1a8fe027ad58c2f42c44 Mon Sep 17 00:00:00 2001 From: David Date: Tue, 18 Jun 2019 20:24:21 +0200 Subject: [PATCH] Enable aesni (#10756) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * Run cargo fix * Optimize imports * compiles * cleanup * Use Secret to store mac-key Truncate payload properly * cleanup * Reorg imports * brwchk hand waving * Review feedback * whitespace * error chain is dead * Build parity-ethereum with SSE2, SSSE3 and AES enabled This enables the `aesni` crate for 50x faster AES crypto. * Correct rustflag setting * List all target triples because [target.'cfg(…)'] is broken * whitespace * Enable hardware aes for CI builds * Add note about synchronizing changes * Remove "Linker" printout * Build artefacts to check hardware aesni * Skip signing windows binaries * Build windows like before * address grumble --- .cargo/config | 26 +++++++++++++++++++++++++- scripts/gitlab/build-linux.sh | 9 ++++++--- scripts/gitlab/build-windows.sh | 4 ++++ scripts/gitlab/test-linux.sh | 2 +- 4 files changed, 36 insertions(+), 5 deletions(-) diff --git a/.cargo/config b/.cargo/config index 3f07816e3..a818c0bf4 100644 --- a/.cargo/config +++ b/.cargo/config @@ -1,3 +1,27 @@ +# NOTE: if you make changes here, remember to also update: +# scripts/test-linux.sh +# scripts/build-linux.sh +# scripts/build-windows.sh + +# Using 'cfg` is broken, see https://github.com/rust-lang/cargo/issues/6858 +#[target.'cfg(target_arch = "x86_64")'] +#rustflags = ["-Ctarget-feature=+aes,+sse2,+ssse3"] + +# …so instead we list all target triples (Tier 1 64-bit platforms) +[target.x86_64-unknown-linux-gnu] +# Enables the aes-ni instructions for RustCrypto dependency. +rustflags = ["-Ctarget-feature=+aes,+sse2,+ssse3"] + +[target.x86_64-pc-windows-gnu] +# Enables the aes-ni instructions for RustCrypto dependency. +rustflags = ["-Ctarget-feature=+aes,+sse2,+ssse3"] + [target.x86_64-pc-windows-msvc] +# Enables the aes-ni instructions for RustCrypto dependency. # Link the C runtime statically ; https://github.com/paritytech/parity-ethereum/issues/6643 -rustflags = ["-Ctarget-feature=+crt-static"] +rustflags = ["-Ctarget-feature=+aes,+sse2,+ssse3", "-Ctarget-feature=+crt-static"] + +[target.x86_64-apple-darwin] +# Enables the aes-ni instructions for RustCrypto dependency. +rustflags = ["-Ctarget-feature=+aes,+sse2,+ssse3"] + diff --git a/scripts/gitlab/build-linux.sh b/scripts/gitlab/build-linux.sh index ebd65cd9b..8f3e6f14e 100755 --- a/scripts/gitlab/build-linux.sh +++ b/scripts/gitlab/build-linux.sh @@ -11,15 +11,18 @@ echo "CC: " $CC echo "CXX: " $CXX #strip ON export RUSTFLAGS=" -C link-arg=-s" -# Linker for crosscomile -echo "_____ Linker _____" -cat .cargo/config echo "_____ Building target: "$CARGO_TARGET" _____" if [ "${CARGO_TARGET}" = "armv7-linux-androideabi" ] then time cargo build --target $CARGO_TARGET --verbose --color=always --release -p parity-clib --features final else + if [ "${CARGO_TARGET}" = "x86_64-unknown-linux-gnu" ] || [ "${CARGO_TARGET}" = "x86_64-apple-darwin" ] + then + # NOTE: Enables the aes-ni instructions for RustCrypto dependency. + # If you change this please remember to also update .cargo/config + export RUSTFLAGS="$RUSTFLAGS -Ctarget-feature=+aes,+sse2,+ssse3" + fi time cargo build --target $CARGO_TARGET --verbose --color=always --release --features final time cargo build --target $CARGO_TARGET --verbose --color=always --release -p evmbin time cargo build --target $CARGO_TARGET --verbose --color=always --release -p ethstore-cli diff --git a/scripts/gitlab/build-windows.sh b/scripts/gitlab/build-windows.sh index 76332124d..3c32e866a 100755 --- a/scripts/gitlab/build-windows.sh +++ b/scripts/gitlab/build-windows.sh @@ -14,6 +14,10 @@ echo "RUSTC_WRAPPER: " $RUSTC_WRAPPER echo "SCCACHE_DIR: " $SCCACHE_DIR echo "_____ Building target: "$CARGO_TARGET" _____" + # NOTE: Enables the aes-ni instructions for RustCrypto dependency. + # If you change this please remember to also update .cargo/config +export RUSTFLAGS=" -Ctarget-feature=+aes,+sse2,+ssse3 -Ctarget-feature=+crt-static" + time cargo build --target $CARGO_TARGET --verbose --release --features final time cargo build --target $CARGO_TARGET --verbose --release -p evmbin time cargo build --target $CARGO_TARGET --verbose --release -p ethstore-cli diff --git a/scripts/gitlab/test-linux.sh b/scripts/gitlab/test-linux.sh index aac007ea6..2ad2ab9be 100755 --- a/scripts/gitlab/test-linux.sh +++ b/scripts/gitlab/test-linux.sh @@ -15,4 +15,4 @@ rustup show echo "________Running Parity Full Test Suite________" # Why are we using RUSTFLAGS? See https://github.com/paritytech/parity-ethereum/pull/10719 -CARGO_INCREMENTAL=0 RUSTFLAGS="-C opt-level=3 -C overflow-checks=on -C debuginfo=2" time cargo test $OPTIONS --features "$FEATURES" --locked --all --target $CARGO_TARGET --verbose --color=never -- --test-threads $THREADS +CARGO_INCREMENTAL=0 RUSTFLAGS="-C opt-level=3 -C overflow-checks=on -C debuginfo=2 -Ctarget-feature=+aes,+sse2,+ssse3" time cargo test $OPTIONS --features "$FEATURES" --locked --all --target $CARGO_TARGET --verbose --color=never -- --test-threads $THREADS