Skip to content

Commit

Permalink
deps: add gyp, header and Makefile for openssl110
Browse files Browse the repository at this point in the history
This commit has a new binding scheme in builing OpenSSL-1.1.0 library
with Node. OpenSSL-1.1.0 uses a new build system with perl for various
supported platforms. See `Configurations/README` and
`Configurations/README.design` in the OpenSSL source for details.

In order to build OpenSSL library without perl in the build of Node
for various supported platforms, platform dependent files (e.g. asm
and header files ) are pre-generated and stored into the `config/arch`
directory.

- Makefile and generate_gypi.pl
Makefile has supported platform list and generates and copies platform
dependent files (e.g. asm files) into arch directory with
generate_gypi.pl. Platform dependent gypi files also created obtaining
build information from `configdata.pm` that is generated with
`Configure` in the OpenSSL build system.

For Windows, `Configure` generates makefile that is only available to
nmake command.  Since nmake is not supported in Linux,
`Makefile_VC-WIN32` and `Makefile_VC-WIN64A` are made created by hand
for the use of GNU make. If make rules or targets are changed in the
version up of OpenSSL, they should be also updated.

The following files are used in upgrading openssl-1.1.0.

- gyp and gypi files
openssl.gyp has two targets of openssl and openssl-cli referred from
node.gyp. They includes asm and no_asm gypi files with arch dependent
gypi according to its build options and platforms . The gyp data which
is common with asm and no_asm are stored in openssl_common.gypi.

- header files
bn_conf.h, dso_conf.h and opensslconf.h are platform dependent in the
OpenSSL sources. They are replaced with *.h.tmpl files to include the
file in the `../../../config/` and referred to each arch files that
depends on asm and no-asm option.

Fixes: #4270
PR-URL: #19794
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Rod Vagg <rod@vagg.org>
Reviewed-By: Michael Dawson <michael_dawson@ca.ibm.com>
  • Loading branch information
shigeki committed Apr 9, 2018
1 parent 1bcb6c0 commit 99eb744
Show file tree
Hide file tree
Showing 30 changed files with 3,955 additions and 342 deletions.
79 changes: 79 additions & 0 deletions deps/openssl/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
This has a new binding scheme in building OpenSSL-1.1.0 library with
Node.js. OpenSSL-1.1.0 uses a new build system with `Perl` for various
supported platforms. See `openssl/Configurations/README` and
`openssl/Configurations/README.design` in the OpenSSL source for
details.

In order to build OpenSSL library without `Perl` in the build of Node.js
for various supported platforms, platform dependent files (e.g. asm
and header files ) are pre-generated and stored into the
`config/archs` directory.

- `config/Makefile` and `config/generate_gypi.pl`

Makefile has supported platform list and generates and copies
platform dependent files (e.g. asm files) into arch directory with
`generate_gypi.pl`. Platform dependent gypi files also created
obtaining build information from `configdata.pm` that is generated
with `Configure` in the OpenSSL build system.

For Windows, `Configure` generates `makefile` that is only available
to `nmake` command. `config/Makefile_VC-WIN32` and
`config/Makefile_VC-WIN64A` are made by hand for the use of GNU
make. If `makefile` rules or targets are changed in the version up
of OpenSSL, they should be also updated.

- gyp and gypi files (`openssl*.{gyp,gypi}`)

`openssl.gyp` has two targets of openssl and openssl-cli referred
from `node.gyp`. They include asm and no_asm gypi files with arch
dependent gypi according to its build options and platforms. The
gyp data which is common with asm and no_asm are stored in
`openssl_common.gypi`.

- header files (`config/*.{h,h.tmpl}`)

`bn_conf.h`, `dso_conf.h` and `opensslconf.h` are platform dependent
in the OpenSSL sources. They are replaced with `config/*.h.tmpl`
files to include the file in the `../../../config/` and referred to
each arch file that depends on asm and no-asm option.

### Supported architectures for use of ASM

Here is a list of supported architectures for use of ASM in OpenSSL.

| --dest-os | --dest-cpu | OpenSSL target arch | CI |
| --------- | ---------- | -------------------- | --- |
| aix | ppc | aix-gcc | o |
| aix | ppc64 | aix64-gcc | o |
| linux | ia32 | linux-elf | o |
| linux | x32 | linux-x32 | - |
| linux | x64 | linux-x86_64 | o |
| linux | arm | linux-armv4 | o |
| linux | arm64 | linux-aarch64 | o |
| linux | ppc | linux-ppc | o |
| linux | ppc64 | linux-ppc64 | o |
| linux | ppc64(*1) | linux-ppc64le | o |
| linux | s390 | linux32-s390x | o |
| linux | s390x | linux64-s390x | o |
| mac | ia32 | darwin-i386-cc | - |
| mac | x64 | darwin64-x86-cc | o |
| win | ia32 | VC-WIN32 | - |
| win | x64 | VC-WIN64A | o |
| solaris | ia32 | solaris-x86-gcc | o |
| solaris | x64 | solaris64-x86_64-gcc | o |
| freebsd | ia32 | BSD-x86 | - |
| freebsd | x64 | BSD-x86_64 | o |
| openbsd | ia32 | BSD-x86 | - |
| openbsd | x64 | BSD-x86_64 | - |
| others | others | linux-elf | - |

(*1: This needs to be configured with the variable of node_byteorder:
little)

These are listed in [config/Makefile](config/Makefile).
Please refer [config/opensslconf_asm.h](config/opensslconf_asm.h) for details.

### Upgrading OpenSSL

Please refer [config/README.md](config/README.md).
64 changes: 64 additions & 0 deletions deps/openssl/config/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
# This Makefile is confirmed to be run only on Linux (CentOS and
# Ubuntu). perl5 and gas(>=2.26) are needed.

UNAME_S := $(shell uname -s)
ifneq ($(UNAME_S),Linux)
$(error This can be run only on Linux)
endif

PERL = perl

# Supported architecture list
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

CONFIGURE = ./Configure
# no-comp: against CRIME attack
# no-shared: openssl-cli needs static link
# no-afalgeng: old Linux kernel < 4.0 does not support it
COPTS = no-comp no-shared no-afalgeng

# disable platform check in Configure
NO_WARN_ENV = CONFIGURE_CHECKER_WARN=1

GITIGNORE = $(OPSSL_SRC)/.gitignore
GENERATE = ./generate_gypi.pl

OPSSL_SRC = ../openssl

# Header files generated with Configure
CFG = opensslconf.h
SRC_CFG = $(OPSSL_SRC)/include/openssl/$(CFG)
INT_CFGS = bn_conf.h dso_conf.h
INT_CFG_DIR = $(OPSSL_SRC)/crypto/include/internal

PHONY = all clean replace
.PHONY: $(PHONY)

all: $(ARCHS) replace

# Configure and generate openssl asm files for each archs
$(ARCHS):
# Remove openssl .gitignore to follow nodejs .gitignore
if [ -e $(GITIGNORE) ]; then rm $(GITIGNORE); fi
# Confgure asm and generate asm sources
cd $(OPSSL_SRC); $(NO_WARN_ENV) $(PERL) $(CONFIGURE) $(COPTS) $@;
$(PERL) -w -I$(OPSSL_SRC) $(GENERATE) asm $@
# Confgure 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 $@

# Replace and copy arch dependent headers
replace:
cp ./$(CFG).tmpl $(SRC_CFG)
@for c in $(INT_CFGS); do \
cp ./$$c.tmpl $(INT_CFG_DIR)/$$c; \
done

clean:
find archs \( -name \*.S -o -name \*.s -o -name \*.asm -o \
-name \*.gypi -o -name \*.h -o -name \*.pm \) -exec rm "{}" \;
Loading

0 comments on commit 99eb744

Please sign in to comment.