From 341eacc94919e1dd51b68e98dffaa59c86262b13 Mon Sep 17 00:00:00 2001 From: Shigeki Ohtsu Date: Sun, 24 Feb 2019 02:47:25 +0900 Subject: [PATCH] deps: add ARM64 Windows support in openssl This adds ARM64 Windows support in the OpenSSL build system. Since OpenSSL's ARM64 Windows support does not have support for ASM-- that is, VC-WIN64-ARM inherits from VC-noCE-common which has no ASM files--`openssl_no_asm.gypi` is always used for building. This essentially forces the 'no-asm' Configure flag. PR-URL: https://github.com/nodejs/node/pull/26001 Fixes: https://github.com/nodejs/node/issues/25998 Reviewed-By: James M Snell Reviewed-By: Sam Roberts Signed-off-by: Beth Griggs --- deps/openssl/config/Makefile | 16 ++- deps/openssl/config/Makefile_VC-WIN64-ARM | 147 ++++++++++++++++++++++ deps/openssl/config/bn_conf_no-asm.h | 2 + deps/openssl/config/dso_conf_no-asm.h | 2 + deps/openssl/config/opensslconf_no-asm.h | 2 + deps/openssl/openssl-cl_no_asm.gypi | 2 + deps/openssl/openssl.gyp | 12 +- deps/openssl/openssl_no_asm.gypi | 2 + 8 files changed, 178 insertions(+), 7 deletions(-) create mode 100644 deps/openssl/config/Makefile_VC-WIN64-ARM diff --git a/deps/openssl/config/Makefile b/deps/openssl/config/Makefile index 5de96ab84d1dbc..ff87bba7126534 100644 --- a/deps/openssl/config/Makefile +++ b/deps/openssl/config/Makefile @@ -9,12 +9,14 @@ endif PERL = perl # Supported architecture list -ARCHS = aix-gcc aix64-gcc BSD-x86_64 \ +ASM_ARCHS = aix-gcc aix64-gcc BSD-x86_64 \ darwin64-x86_64-cc darwin-i386-cc linux-aarch64 \ linux-armv4 linux-elf linux-x32 linux-x86_64 linux-ppc \ linux-ppc64 linux-ppc64le linux32-s390x linux64-s390x \ solaris-x86-gcc solaris64-x86_64-gcc VC-WIN64A VC-WIN32 +NO_ASM_ARCHS = VC-WIN64-ARM + CC = gcc FAKE_GCC = ../config/fake_gcc.pl @@ -40,17 +42,23 @@ INT_CFG_DIR = $(OPSSL_SRC)/crypto/include/internal PHONY = all clean replace .PHONY: $(PHONY) -all: $(ARCHS) replace +all: $(ASM_ARCHS) $(NO_ASM_ARCHS) replace # Configure and generate openssl asm files for each archs -$(ARCHS): +$(ASM_ARCHS): 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 +# Configure no-asm and generate no-asm sources + cd $(OPSSL_SRC); $(NO_WARN_ENV) $(PERL) $(CONFIGURE) $(COPTS) \ + no-asm $@; + $(PERL) -w -I$(OPSSL_SRC) $(GENERATE) no-asm $@ + +$(NO_ASM_ARCHS): +# Configure no-asm and generate no-asm sources cd $(OPSSL_SRC); $(NO_WARN_ENV) $(PERL) $(CONFIGURE) $(COPTS) \ no-asm $@; $(PERL) -w -I$(OPSSL_SRC) $(GENERATE) no-asm $@ diff --git a/deps/openssl/config/Makefile_VC-WIN64-ARM b/deps/openssl/config/Makefile_VC-WIN64-ARM new file mode 100644 index 00000000000000..9937bd5492a39b --- /dev/null +++ b/deps/openssl/config/Makefile_VC-WIN64-ARM @@ -0,0 +1,147 @@ + +## +## Makefile for OpenSSL +## +## WARNING: do not edit! +## Generated by Configure from Configurations/common0.tmpl, Configurations/windows-makefile.tmpl, Configurations/common.tmpl + + +PLATFORM=VC-WIN64-ARM +SRCDIR=. +BLDDIR=. + +VERSION=1.1.1a +MAJOR=1 +MINOR=1.1 + +SHLIB_VERSION_NUMBER=1.1 + +GENERATED_MANDATORY=crypto/include/internal/bn_conf.h crypto/include/internal/dso_conf.h include/openssl/opensslconf.h + +INSTALL_LIBS="libcrypto.lib" "libssl.lib" +INSTALL_SHLIBS="libcrypto-1_1-arm64.dll" "libssl-1_1-arm64.dll" +INSTALL_SHLIBPDBS="libcrypto-1_1-arm64.pdb" "libssl-1_1-arm64.pdb" +INSTALL_ENGINES="engines/capi.dll" "engines/padlock.dll" +INSTALL_ENGINEPDBS="engines/capi.pdb" "engines/padlock.pdb" +INSTALL_PROGRAMS="apps/openssl.exe" +INSTALL_PROGRAMPDBS="apps/openssl.pdb" + +BIN_SCRIPTS="$(BLDDIR)\tools\c_rehash.pl" +MISC_SCRIPTS="$(BLDDIR)\apps\CA.pl" "$(BLDDIR)\apps\tsget.pl" + + +APPS_OPENSSL="apps/openssl" + +# Do not edit these manually. Use Configure with --prefix or --openssldir +# to change this! Short explanation in the top comment in Configure +INSTALLTOP_dev= +INSTALLTOP_dir=\OpenSSL +OPENSSLDIR_dev= +OPENSSLDIR_dir=\SSL +LIBDIR=lib +ENGINESDIR_dev= +ENGINESDIR_dir=\OpenSSL/lib/engines-1_1 +INSTALLTOP=$(INSTALLTOP_dev)$(INSTALLTOP_dir) +OPENSSLDIR=$(OPENSSLDIR_dev)$(OPENSSLDIR_dir) +ENGINESDIR=$(ENGINESDIR_dev)$(ENGINESDIR_dir) + +# $(libdir) is chosen to be compatible with the GNU coding standards +libdir=$(INSTALLTOP)\$(LIBDIR) + +##### User defined commands and flags ################################ + +CC=cl +CPP=$(CC) /EP /C +CPPFLAGS= +CFLAGS=/W3 /wd4090 /nologo /O2 +LD=link +LDFLAGS=/nologo /debug +EX_LIBS= + +PERL=/usr/bin/perl + +AR=lib +ARFLAGS= /nologo + +MT=mt +MTFLAGS= -nologo + +AS= +ASFLAGS= + +RC=rc + +ECHO="$(PERL)" "$(SRCDIR)\util\echo.pl" + +##### Special command flags ########################################## + +COUTFLAG=/Fo$(OSSL_EMPTY) +LDOUTFLAG=/out:$(OSSL_EMPTY) +AROUTFLAG=/out:$(OSSL_EMPTY) +MTINFLAG=-manifest $(OSSL_EMPTY) +MTOUTFLAG=-outputresource:$(OSSL_EMPTY) +ASOUTFLAG=$(OSSL_EMPTY) +RCOUTFLAG=/fo$(OSSL_EMPTY) + +##### Project flags ################################################## + +# Variables starting with CNF_ are common variables for all product types + +CNF_ASFLAGS= +CNF_CPPFLAGS=-D"OPENSSL_SYS_WIN32" -D"WIN32_LEAN_AND_MEAN" -D"UNICODE" -D"_UNICODE" -D"_CRT_SECURE_NO_DEPRECATE" -D"_WINSOCK_DEPRECATED_NO_WARNINGS" -D"_ARM_WINAPI_PARTITION_DESKTOP_SDK_AVAILABLE" -D"OPENSSL_SYS_WIN_CORE" -D"NDEBUG" +CNF_CFLAGS=/Gs0 /GF /Gy /MD +CNF_CXXFLAGS= +CNF_LDFLAGS=/NODEFAULTLIB:kernel32.lib +CNF_EX_LIBS=onecore.lib + +# Variables starting with LIB_ are used to build library object files +# and shared libraries. +# Variables starting with DSO_ are used to build DSOs and their object files. +# Variables starting with BIN_ are used to build programs and their object +# files. + +LIB_ASFLAGS=$(CNF_ASFLAGS) $(ASFLAGS) +LIB_CPPFLAGS=-D"L_ENDIAN" -D"OPENSSL_PIC" -D"OPENSSLDIR=\"\\SSL\"" -D"ENGINESDIR=\"\\OpenSSL/lib/engines-1_1\"" $(CNF_CPPFLAGS) $(CPPFLAGS) +LIB_CFLAGS=/Zi /Fdossl_static.pdb $(CNF_CFLAGS) $(CFLAGS) +LIB_LDFLAGS=/dll $(CNF_LDFLAGS) $(LDFLAGS) +LIB_EX_LIBS=$(CNF_EX_LIBS) $(EX_LIBS) +DSO_ASFLAGS=$(CNF_ASFLAGS) $(ASFLAGS) +DSO_CPPFLAGS=$(CNF_CPPFLAGS) $(CPPFLAGS) +DSO_CFLAGS=/Zi /Fddso.pdb $(CNF_CFLAGS) $(CFLAGS) +DSO_LDFLAGS=/dll $(CNF_LDFLAGS) $(LDFLAGS) +DSO_EX_LIBS=$(CNF_EX_LIBS) $(EX_LIBS) +BIN_ASFLAGS=$(CNF_ASFLAGS) $(ASFLAGS) +BIN_CPPFLAGS=$(CNF_CPPFLAGS) $(CPPFLAGS) +BIN_CFLAGS=/Zi /Fdapp.pdb $(CNF_CFLAGS) $(CFLAGS) +BIN_LDFLAGS=/subsystem:console /opt:ref $(CNF_LDFLAGS) $(LDFLAGS) +BIN_EX_LIBS=$(CNF_EX_LIBS) $(EX_LIBS) + +# CPPFLAGS_Q is used for one thing only: to build up buildinf.h +CPPFLAGS_Q=-D"L_ENDIAN" -D"OPENSSL_PIC" + +PERLASM_SCHEME= + +PROCESSOR= + +build_generated: $(GENERATED_MANDATORY) + +crypto/buildinf.h: + "$(PERL)" "util/mkbuildinf.pl" "$(CC) $(LIB_CFLAGS) $(CPPFLAGS_Q)" "$(PLATFORM)" > $@ + +apps/progs.h: + "$(PERL)" "apps/progs.pl" $(APPS_OPENSSL) > $@ + +crypto/include/internal/bn_conf.h: + "$(PERL)" "-I$(BLDDIR)" -Mconfigdata "util/dofile.pl" \ + "-omakefile" "crypto/include/internal/bn_conf.h.in" > $@ +crypto/include/internal/dso_conf.h: + "$(PERL)" "-I$(BLDDIR)" -Mconfigdata "util/dofile.pl" \ + "-omakefile" "crypto/include/internal/dso_conf.h.in" > $@ +include/openssl/opensslconf.h: + "$(PERL)" "-I$(BLDDIR)" -Mconfigdata "util/dofile.pl" \ + "-omakefile" "include/openssl/opensslconf.h.in" > $@ + +distclean: + $(RM) $(GENERATED) + $(RM) /Q /F configdata.pm + $(RM) /Q /F makefile diff --git a/deps/openssl/config/bn_conf_no-asm.h b/deps/openssl/config/bn_conf_no-asm.h index d577b15c77e47b..e7cbb88d966148 100644 --- a/deps/openssl/config/bn_conf_no-asm.h +++ b/deps/openssl/config/bn_conf_no-asm.h @@ -21,6 +21,8 @@ # include "./archs/VC-WIN32/no-asm/crypto/include/internal/bn_conf.h" #elif defined(_WIN32) && defined(_M_X64) # include "./archs/VC-WIN64A/no-asm/crypto/include/internal/bn_conf.h" +#elif defined(_WIN32) && defined(_M_ARM64) +# include "./archs/VC-WIN64-ARM/no-asm/crypto/include/internal/bn_conf.h" #elif (defined(__FreeBSD__) || defined(__OpenBSD__)) && defined(__i386__) # include "./archs/BSD-x86/no-asm/crypto/include/internal/bn_conf.h" #elif (defined(__FreeBSD__) || defined(__OpenBSD__)) && defined(__x86_64__) diff --git a/deps/openssl/config/dso_conf_no-asm.h b/deps/openssl/config/dso_conf_no-asm.h index 9d0e3e0e1c4e63..c3507ce3d24fde 100644 --- a/deps/openssl/config/dso_conf_no-asm.h +++ b/deps/openssl/config/dso_conf_no-asm.h @@ -21,6 +21,8 @@ # include "./archs/VC-WIN32/no-asm/crypto/include/internal/dso_conf.h" #elif defined(_WIN32) && defined(_M_X64) # include "./archs/VC-WIN64A/no-asm/crypto/include/internal/dso_conf.h" +#elif defined(_WIN32) && defined(_M_ARM64) +# include "./archs/VC-WIN64-ARM/no-asm/crypto/include/internal/dso_conf.h" #elif (defined(__FreeBSD__) || defined(__OpenBSD__)) && defined(__i386__) # include "./archs/BSD-x86/no-asm/crypto/include/internal/dso_conf.h" #elif (defined(__FreeBSD__) || defined(__OpenBSD__)) && defined(__x86_64__) diff --git a/deps/openssl/config/opensslconf_no-asm.h b/deps/openssl/config/opensslconf_no-asm.h index 7ef62f91820fff..1a8763f631525a 100644 --- a/deps/openssl/config/opensslconf_no-asm.h +++ b/deps/openssl/config/opensslconf_no-asm.h @@ -16,6 +16,8 @@ # include "./archs/VC-WIN32/no-asm/include/openssl/opensslconf.h" #elif defined(_WIN32) && defined(_M_X64) # include "./archs/VC-WIN64A/no-asm/include/openssl/opensslconf.h" +#elif defined(_WIN32) && defined(_M_ARM64) +# include "./archs/VC-WIN64-ARM/no-asm/include/openssl/opensslconf.h" #elif (defined(__FreeBSD__) || defined(__OpenBSD__)) && defined(__i386__) # include "./archs/BSD-x86/no-asm/include/openssl/opensslconf.h" #elif (defined(__FreeBSD__) || defined(__OpenBSD__)) && defined(__x86_64__) diff --git a/deps/openssl/openssl-cl_no_asm.gypi b/deps/openssl/openssl-cl_no_asm.gypi index 8b44e1f64fe677..8ba246d3035fee 100644 --- a/deps/openssl/openssl-cl_no_asm.gypi +++ b/deps/openssl/openssl-cl_no_asm.gypi @@ -18,6 +18,8 @@ 'includes': ['config/archs/linux-armv4/no-asm/openssl-cl.gypi'], }, 'target_arch=="arm64" and OS=="linux"', { 'includes': ['config/archs/linux-aarch64/no-asm/openssl-cl.gypi'], + }, 'target_arch=="arm64" and OS=="win"', { + 'includes': ['config/archs/VC-WIN64-ARM/no-asm/openssl-cl.gypi'], }, 'target_arch=="ia32" and OS=="linux"', { 'includes': ['config/archs/linux-elf/no-asm/openssl-cl.gypi'], }, 'target_arch=="ia32" and OS=="mac"', { diff --git a/deps/openssl/openssl.gyp b/deps/openssl/openssl.gyp index 5f532487563601..60f6ee03a7a9e4 100644 --- a/deps/openssl/openssl.gyp +++ b/deps/openssl/openssl.gyp @@ -18,6 +18,9 @@ 'conditions': [ [ 'openssl_no_asm==1', { 'includes': ['./openssl_no_asm.gypi'], + }, 'target_arch=="arm64" and OS=="win"', { + # VC-WIN64-ARM inherits from VC-noCE-common that has no asms. + '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 @@ -37,10 +40,13 @@ 'dependencies': ['openssl'], 'includes': ['./openssl_common.gypi'], 'conditions': [ - ['openssl_no_asm==0', { - 'includes': ['./openssl-cl_asm.gypi'], - }, { + ['openssl_no_asm==1', { 'includes': ['./openssl-cl_no_asm.gypi'], + }, 'target_arch=="arm64" and OS=="win"', { + # VC-WIN64-ARM inherits from VC-noCE-common that has no asms. + 'includes': ['./openssl-cl_no_asm.gypi'], + }, { + 'includes': ['./openssl-cl_asm.gypi'], }], ], }, diff --git a/deps/openssl/openssl_no_asm.gypi b/deps/openssl/openssl_no_asm.gypi index 2e0d9639590a69..d09f944539bb26 100644 --- a/deps/openssl/openssl_no_asm.gypi +++ b/deps/openssl/openssl_no_asm.gypi @@ -38,6 +38,8 @@ 'includes': ['config/archs/solaris64-x86_64-gcc/no-asm/openssl.gypi'], }, 'target_arch=="x64" and OS=="win"', { 'includes': ['config/archs/VC-WIN64A/no-asm/openssl.gypi'], + }, 'target_arch=="arm64" and OS=="win"', { + 'includes': ['config/archs/VC-WIN64-ARM/no-asm/openssl.gypi'], }, 'target_arch=="x64" and OS=="linux"', { 'includes': ['config/archs/linux-x86_64/no-asm/openssl.gypi'], }, {