Skip to content

Commit

Permalink
deps: add only avx2 configs for OpenSSL-1.1.1
Browse files Browse the repository at this point in the history
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.

PR-URL: nodejs#25381
Reviewed-By: Daniel Bevenius <[email protected]>
Reviewed-By: Shigeki Ohtsu <[email protected]>
  • Loading branch information
shigeki authored and sam-github committed Jan 22, 2019
1 parent 0d9a86c commit 576d0c6
Show file tree
Hide file tree
Showing 6 changed files with 155 additions and 14 deletions.
12 changes: 7 additions & 5 deletions deps/openssl/config/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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 $@;
Expand Down
9 changes: 5 additions & 4 deletions deps/openssl/config/fake_gcc.pl
Original file line number Diff line number Diff line change
@@ -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;
6 changes: 3 additions & 3 deletions deps/openssl/config/generate_gypi.pl
Original file line number Diff line number Diff line change
Expand Up @@ -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];
Expand All @@ -25,15 +25,15 @@
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." .
"$nasm_version_min or higher is required.";
}

# 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) {
Expand Down
47 changes: 47 additions & 0 deletions deps/openssl/openssl-cl_asm_avx2.gypi
Original file line number Diff line number Diff line change
@@ -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'],
}],
],
}
14 changes: 12 additions & 2 deletions deps/openssl/openssl.gyp
Original file line number Diff line number Diff line change
@@ -1,4 +1,9 @@
{
'variables': {
'gas_version%': 0,
'llvm_version%': 0,
'nasm_version%': 0,
},
'targets': [
{
'target_name': 'openssl',
Expand All @@ -11,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': {
Expand Down
81 changes: 81 additions & 0 deletions deps/openssl/openssl_asm_avx2.gypi
Original file line number Diff line number Diff line change
@@ -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'],
}],
],
}

0 comments on commit 576d0c6

Please sign in to comment.