From 639b1d2f681632bff0ba92f775160f82d5dcf148 Mon Sep 17 00:00:00 2001 From: Shigeki Ohtsu Date: Thu, 8 Nov 2018 15:45:29 +0900 Subject: [PATCH] deps: add only avx2 configs for OpenSSL-1.1.1 OpenSSL-1.1.1 has new support of AVX-512 but AVX-2 asm files still need to be generated for the older assembler support to keep backward compatibilities. Backport-PR-URL: https://github.com/nodejs/node/pull/26270 PR-URL: https://github.com/nodejs/node/pull/25381 Reviewed-By: Daniel Bevenius Reviewed-By: Shigeki Ohtsu --- deps/openssl/config/Makefile | 12 ++-- deps/openssl/config/fake_gcc.pl | 9 +-- deps/openssl/config/generate_gypi.pl | 6 +- deps/openssl/openssl-cl_asm_avx2.gypi | 47 ++++++++++++++++ deps/openssl/openssl.gyp | 13 ++++- deps/openssl/openssl_asm_avx2.gypi | 81 +++++++++++++++++++++++++++ 6 files changed, 153 insertions(+), 15 deletions(-) create mode 100644 deps/openssl/openssl-cl_asm_avx2.gypi create mode 100644 deps/openssl/openssl_asm_avx2.gypi diff --git a/deps/openssl/config/Makefile b/deps/openssl/config/Makefile index a86f392ef23ace..300ab009d8fe8c 100644 --- a/deps/openssl/config/Makefile +++ b/deps/openssl/config/Makefile @@ -16,6 +16,8 @@ linux-ppc64 linux-ppc64le linux32-s390x linux64-s390x \ solaris-x86-gcc solaris64-x86_64-gcc VC-WIN64A VC-WIN32 CC = gcc +FAKE_GCC = ../config/fake_gcc.pl + CONFIGURE = ./Configure # no-comp: against CRIME attack # no-shared: openssl-cli needs static link @@ -45,12 +47,12 @@ all: $(ARCHS) replace $(ARCHS): # Remove openssl .gitignore to follow nodejs .gitignore if [ -e $(GITIGNORE) ]; then rm $(GITIGNORE); fi - if [ "$(findstring darwin, $@)" = "" ]; then \ - cd $(OPSSL_SRC); $(NO_WARN_ENV) ARC=$@ CC=$(CC) $(PERL) $(CONFIGURE) $(COPTS) $@; \ - else \ - cd $(OPSSL_SRC); $(NO_WARN_ENV) ARC=$@ CC=./fake_gcc.pl $(PERL) $(CONFIGURE) $(COPTS) $@; \ - fi + cd $(OPSSL_SRC); $(NO_WARN_ENV) CC=$(CC) $(PERL) $(CONFIGURE) $(COPTS) $@; $(PERL) -w -I$(OPSSL_SRC) $(GENERATE) asm $@ +# Confgure asm_avx2 and generate upto avx2 support + cd $(OPSSL_SRC); $(NO_WARN_ENV) CC=$(FAKE_GCC) $(PERL) $(CONFIGURE) \ + $(COPTS) $@; + $(PERL) -w -I$(OPSSL_SRC) $(GENERATE) asm_avx2 $@ # Confgure no-asm and generate no-asm sources cd $(OPSSL_SRC); $(NO_WARN_ENV) $(PERL) $(CONFIGURE) $(COPTS) \ no-asm $@; diff --git a/deps/openssl/config/fake_gcc.pl b/deps/openssl/config/fake_gcc.pl index aa9f9774499ead..6c77c3acbc41d7 100755 --- a/deps/openssl/config/fake_gcc.pl +++ b/deps/openssl/config/fake_gcc.pl @@ -1,11 +1,12 @@ #! /usr/bin/env perl use 5.10.0; use strict; -my $arch = $ENV{ARC}; +my $args = join(' ', @ARGV); + my $ret; -if ($arch =~ /^darwin/) { - $ret = "Apple LLVM version 10.0.0 (clang-1000.11.45.2)\n"; +if ($args eq '-Wa,-v -c -o /dev/null -x assembler /dev/null') { + $ret = "GNU assembler version 2.23.52.0.1 (x86_64-redhat-linux) using BFD version version 2.23.52.0.1-30.el7_1.2 20130226\n"; } else { - $ret = `gcc -Wa,-v -c -o /dev/null -x assembler /dev/null 2>&1`; + $ret = `gcc $args`; } print STDOUT $ret; diff --git a/deps/openssl/config/generate_gypi.pl b/deps/openssl/config/generate_gypi.pl index 813bd28a86a3f4..4a0a649c7cddd5 100755 --- a/deps/openssl/config/generate_gypi.pl +++ b/deps/openssl/config/generate_gypi.pl @@ -16,7 +16,7 @@ my $asm = $ARGV[0]; -unless ($asm eq "asm" or $asm eq "no-asm") { +unless ($asm eq "asm" or $asm eq "asm_avx2" or $asm eq "no-asm") { die "Error: $asm is invalid argument"; } my $arch = $ARGV[1]; @@ -25,7 +25,7 @@ my $nasm_banner = `nasm -v`; die "Error: nasm is not installed." if (!$nasm_banner); -my $nasm_version_min = 2.11; +my $nasm_version_min = 2.13.3; my ($nasm_version) = ($nasm_banner =~/^NASM version ([0-9]\.[0-9][0-9])+/); if ($nasm_version < $nasm_version_min) { die "Error: nasm version $nasm_version is too old." . @@ -33,7 +33,7 @@ } # gas version check -my $gas_version_min = 2.26; +my $gas_version_min = 2.30; my $gas_banner = `gcc -Wa,-v -c -o /dev/null -x assembler /dev/null 2>&1`; my ($gas_version) = ($gas_banner =~/GNU assembler version ([2-9]\.[0-9]+)/); if ($gas_version < $gas_version_min) { diff --git a/deps/openssl/openssl-cl_asm_avx2.gypi b/deps/openssl/openssl-cl_asm_avx2.gypi new file mode 100644 index 00000000000000..f05c02171a60bf --- /dev/null +++ b/deps/openssl/openssl-cl_asm_avx2.gypi @@ -0,0 +1,47 @@ +{ + 'conditions': [ + ['target_arch=="ppc" and OS=="aix"', { + 'includes': ['config/archs/aix-gcc/asm_avx2/openssl-cl.gypi'], + }, 'target_arch=="ppc" and OS=="linux"', { + 'includes': ['config/archs/linux-ppc/asm_avx2/openssl-cl.gypi'], + }, 'target_arch=="ppc64" and OS=="aix"', { + 'includes': ['config/archs/aix64-gcc/asm_avx2/openssl-cl.gypi'], + }, 'target_arch=="ppc64" and OS=="linux" and node_byteorder =="little"', { + 'includes': ['config/archs/linux-ppc64le/asm_avx2/openssl-cl.gypi'], + }, 'target_arch=="ppc64" and OS=="linux"', { + 'includes': ['config/archs/linux-ppc64/asm_avx2/openssl-cl.gypi'], + }, 'target_arch=="s390" and OS=="linux"', { + 'includes': ['config/archs/linux32-s390x/asm_avx2/openssl-cl.gypi'], + }, 'target_arch=="s390x" and OS=="linux"', { + 'includes': ['config/archs/linux64-s390x/asm_avx2/openssl-cl.gypi'], + }, 'target_arch=="arm" and OS=="linux"', { + 'includes': ['config/archs/linux-armv4/asm_avx2/openssl-cl.gypi'], + }, 'target_arch=="arm64" and OS=="linux"', { + 'includes': ['config/archs/linux-aarch64/asm_avx2/openssl-cl.gypi'], + }, 'target_arch=="ia32" and OS=="linux"', { + 'includes': ['config/archs/linux-elf/asm_avx2/openssl-cl.gypi'], + }, 'target_arch=="ia32" and OS=="mac"', { + 'includes': ['config/archs/darwin-i386-cc/asm_avx2/openssl-cl.gypi'], + }, 'target_arch=="ia32" and OS=="solaris"', { + 'includes': ['config/archs/solaris-x86-gcc/asm_avx2/openssl-cl.gypi'], + }, 'target_arch=="ia32" and OS=="win"', { + 'includes': ['config/archs/VC-WIN32/asm_avx2/openssl-cl.gypi'], + }, 'target_arch=="ia32"', { + # noasm linux-elf for other ia32 platforms + 'includes': ['config/archs/linux-elf/asm_avx2/openssl-cl.gypi'], + }, 'target_arch=="x64" and OS=="freebsd"', { + 'includes': ['config/archs/BSD-x86_64/asm_avx2/openssl-cl.gypi'], + }, 'target_arch=="x64" and OS=="mac"', { + 'includes': ['config/archs/darwin64-x86_64-cc/asm_avx2/openssl-cl.gypi'], + }, 'target_arch=="x64" and OS=="solaris"', { + 'includes': ['config/archs/solaris64-x86_64-gcc/asm_avx2/openssl-cl.gypi'], + }, 'target_arch=="x64" and OS=="win"', { + 'includes': ['config/archs/VC-WIN64A/asm_avx2/openssl-cl.gypi'], + }, 'target_arch=="x64" and OS=="linux"', { + 'includes': ['config/archs/linux-x86_64/asm_avx2/openssl-cl.gypi'], + }, { + # Other architectures don't use assembly + 'includes': ['config/archs/linux-x86_64/asm_avx2/openssl-cl.gypi'], + }], + ], +} diff --git a/deps/openssl/openssl.gyp b/deps/openssl/openssl.gyp index 6b0770ebbc1b0e..5f532487563601 100644 --- a/deps/openssl/openssl.gyp +++ b/deps/openssl/openssl.gyp @@ -1,6 +1,8 @@ { 'variables': { - 'openssl_no_asm%': 0, + 'gas_version%': 0, + 'llvm_version%': 0, + 'nasm_version%': 0, }, 'targets': [ { @@ -14,10 +16,15 @@ 'OPENSSL_NO_HW', ], 'conditions': [ - [ 'openssl_no_asm==0', { + [ 'openssl_no_asm==1', { + 'includes': ['./openssl_no_asm.gypi'], + }, 'gas_version >= "2.26" or nasm_version >= "2.11.8"', { + # Require AVX512IFMA supported. See + # https://www.openssl.org/docs/man1.1.1/man3/OPENSSL_ia32cap.html + # Currently crypto/poly1305/asm/poly1305-x86_64.pl requires AVX512IFMA. 'includes': ['./openssl_asm.gypi'], }, { - 'includes': ['./openssl_no_asm.gypi'], + 'includes': ['./openssl_asm_avx2.gypi'], }], ], 'direct_dependent_settings': { diff --git a/deps/openssl/openssl_asm_avx2.gypi b/deps/openssl/openssl_asm_avx2.gypi new file mode 100644 index 00000000000000..c5a636a3301a2a --- /dev/null +++ b/deps/openssl/openssl_asm_avx2.gypi @@ -0,0 +1,81 @@ +{ + 'conditions': [ + ['target_arch=="ppc" and OS=="aix"', { + 'includes': ['config/archs/aix-gcc/asm_avx2/openssl.gypi'], + }, 'target_arch=="ppc" and OS=="linux"', { + 'includes': ['config/archs/linux-ppc/asm_avx2/openssl.gypi'], + }, 'target_arch=="ppc64" and OS=="aix"', { + 'includes': ['config/archs/aix64-gcc/asm_avx2/openssl.gypi'], + }, 'target_arch=="ppc64" and OS=="linux" and node_byteorder =="little"', { + 'includes': ['config/archs/linux-ppc64le/asm_avx2/openssl.gypi'], + }, 'target_arch=="ppc64" and OS=="linux"', { + 'includes': ['config/archs/linux-ppc64/asm_avx2/openssl.gypi'], + }, 'target_arch=="s390" and OS=="linux"', { + 'includes': ['config/archs/linux32-s390x/asm_avx2/openssl.gypi'], + }, 'target_arch=="s390x" and OS=="linux"', { + 'includes': ['config/archs/linux64-s390x/asm_avx2/openssl.gypi'], + }, 'target_arch=="arm" and OS=="linux"', { + 'includes': ['config/archs/linux-armv4/asm_avx2/openssl.gypi'], + }, 'target_arch=="arm64" and OS=="linux"', { + 'includes': ['config/archs/linux-aarch64/asm_avx2/openssl.gypi'], + }, 'target_arch=="ia32" and OS=="linux"', { + 'includes': ['config/archs/linux-elf/asm_avx2/openssl.gypi'], + }, 'target_arch=="ia32" and OS=="mac"', { + 'includes': ['config/archs/darwin-i386-cc/asm_avx2/openssl.gypi'], + }, 'target_arch=="ia32" and OS=="solaris"', { + 'includes': ['config/archs/solaris-x86-gcc/asm_avx2/openssl.gypi'], + }, 'target_arch=="ia32" and OS=="win"', { + 'includes': ['config/archs/VC-WIN32/asm_avx2/openssl.gypi'], + 'rules': [ + { + 'rule_name': 'Assemble', + 'extension': 'asm', + 'inputs': [], + 'outputs': [ + '<(INTERMEDIATE_DIR)/<(RULE_INPUT_ROOT).obj', + ], + 'action': [ + 'nasm.exe', + '-f win32', + '-o', '<(INTERMEDIATE_DIR)/<(RULE_INPUT_ROOT).obj', + '<(RULE_INPUT_PATH)', + ], + } + ], + }, 'target_arch=="ia32"', { + 'includes': ['config/archs/linux-elf/asm_avx2/openssl.gypi'], + }, 'target_arch=="x64" and OS=="freebsd"', { + 'includes': ['config/archs/BSD-x86_64/asm_avx2/openssl.gypi'], + }, 'target_arch=="x64" and OS=="mac"', { + 'includes': ['config/archs/darwin64-x86_64-cc/asm_avx2/openssl.gypi'], + }, 'target_arch=="x64" and OS=="solaris"', { + 'includes': ['config/archs/solaris64-x86_64-gcc/asm_avx2/openssl.gypi'], + }, 'target_arch=="x64" and OS=="win"', { + 'includes': ['config/archs/VC-WIN64A/asm_avx2/openssl.gypi'], + 'rules': [ + { + 'rule_name': 'Assemble', + 'extension': 'asm', + 'inputs': [], + 'outputs': [ + '<(INTERMEDIATE_DIR)/<(RULE_INPUT_ROOT).obj', + ], + 'action': [ + 'nasm.exe', + '-f win64', + '-DNEAR', + '-Ox', + '-g', + '-o', '<(INTERMEDIATE_DIR)/<(RULE_INPUT_ROOT).obj', + '<(RULE_INPUT_PATH)', + ], + } + ], + }, 'target_arch=="x64" and OS=="linux"', { + 'includes': ['config/archs/linux-x86_64/asm_avx2/openssl.gypi'], + }, { + # Other architectures don't use assembly + 'includes': ['config/archs/linux-x86_64/asm_avx2/openssl.gypi'], + }], + ], +}