Skip to content

Commit

Permalink
deps,build,tools: fix openssl-is-fips for ninja builds
Browse files Browse the repository at this point in the history
Currently using the --openssl-is-fips configuration option in
combination with --ninja is broken.

This commit fixes two issues, one being an issue with the linker/version
script path variable. The second is that the locations of built
artifacts that differ for ninja and make.

ninja:
$ ./configure --openssl-is-fips --ninja
$ ninja -C out/Release
$ ./node --enable-fips -p 'crypto.getFips()'
1

make:
$ ./configure --openssl-is-fips
$ make -j8
$ ./node --enable-fips -p 'crypto.getFips()'
1

Refs: nodejs#40509
  • Loading branch information
danbev committed Oct 19, 2021
1 parent 0f78d26 commit 757e147
Show file tree
Hide file tree
Showing 6 changed files with 30 additions and 13 deletions.
1 change: 1 addition & 0 deletions configure.py
Original file line number Diff line number Diff line change
Expand Up @@ -1980,6 +1980,7 @@ def make_bin_override():


gyp_args = ['--no-parallel', '-Dconfiguring_node=1']
gyp_args += ['-Dbuild_type=' + config['BUILDTYPE']]

if options.use_ninja:
gyp_args += ['-f', 'ninja']
Expand Down
2 changes: 1 addition & 1 deletion deps/openssl/config/generate_gypi.pl
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@
copy("$src_dir/providers/common/include/prov/der_digests.h",
"$base_dir/providers/common/include/prov/") or die "Copy failed: $!";

my $linker_script_dir = "\$(srcdir)/deps/openssl/config/archs/$arch/$asm/providers";
my $linker_script_dir = "<(PRODUCT_DIR)/../../deps/openssl/config/archs/$arch/$asm/providers";
my $fips_linker_script = "";
if ($fips_ld ne "") {
$fips_linker_script = "$linker_script_dir/fips.ld";
Expand Down
11 changes: 9 additions & 2 deletions deps/openssl/openssl.gyp
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,21 @@
'conditions': [
['OS == "win"', {
'obj_dir_abs': '<(PRODUCT_DIR_ABS)/obj',
'openssl_dir': '<(PRODUCT_DIR_ABS)/obj/lib',
}],
['GENERATOR == "ninja"', {
'obj_dir_abs': '<(PRODUCT_DIR_ABS)/obj',
'modules_dir': '<(PRODUCT_DIR_ABS)/obj/lib/openssl-modules',
'openssl_dir': '<(PRODUCT_DIR_ABS)/obj/lib',
}, {
'obj_dir_abs%': '<(PRODUCT_DIR_ABS)/obj.target',
'modules_dir': '<(PRODUCT_DIR_ABS)/obj.target/deps/openssl/lib/openssl-modules',
'openssl_dir': '<(PRODUCT_DIR_ABS)/obj.target/deps/openssl',
}],
['OS=="mac"', {
'obj_dir_abs%': '<(PRODUCT_DIR_ABS)/obj.target',
'modules_dir': '<(PRODUCT_DIR_ABS)/obj.target/deps/openssl/lib/openssl-modules',
'openssl_dir': '<(PRODUCT_DIR_ABS)/obj.target/deps/openssl',
}],
],
},
Expand Down Expand Up @@ -49,8 +56,8 @@
}],
['node_shared_openssl=="false"', {
'defines': [
'MODULESDIR="<(obj_dir_abs)/deps/openssl/lib/openssl-modules"',
'OPENSSLDIR="<(obj_dir_abs)/deps/openssl"',
'MODULESDIR="<(modules_dir)"',
'OPENSSLDIR="<(openssl_dir)"',
]
}],
],
Expand Down
1 change: 0 additions & 1 deletion deps/openssl/openssl_common.gypi
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,6 @@
# linux and others
'cflags': ['-Wno-missing-field-initializers',],
'defines': [
'OPENSSLDIR="<(obj_dir_abs)/deps/openssl"',
'ENGINESDIR="/dev/null"',
'TERMIOS',
],
Expand Down
20 changes: 13 additions & 7 deletions node.gyp
Original file line number Diff line number Diff line change
Expand Up @@ -347,15 +347,21 @@
'variables': {
'openssl-cli': '<(PRODUCT_DIR)/<(EXECUTABLE_PREFIX)openssl-cli<(EXECUTABLE_SUFFIX)',
'provider_name': 'libopenssl-fipsmodule',
'fipsmodule_internal': '<(obj_dir)/deps/openssl/<(provider_name).so',
'fipsmodule': '<(obj_dir)/deps/openssl/lib/openssl-modules/fips.so',
'fipsconfig': '<(obj_dir)/deps/openssl/fipsmodule.cnf',
'opensslconfig_internal': '<(obj_dir)/deps/openssl/openssl.cnf',
'opensslconfig': './deps/openssl/openssl/apps/openssl.cnf',
'conditions': [
['GENERATOR == "ninja"', {
'fipsmodule_internal': '<(PRODUCT_DIR)/lib/<(provider_name).so',
'fipsmodule': '<(PRODUCT_DIR)/obj/lib/openssl-modules/fips.so',
'fipsconfig': '<(PRODUCT_DIR)/obj/lib/fipsmodule.cnf',
'opensslconfig_internal': '<(PRODUCT_DIR)/obj/lib/openssl.cnf',
}, {
'fipsmodule_internal': '<(PRODUCT_DIR)/obj.target/deps/openssl/<(provider_name).so',
'fipsmodule': '<(PRODUCT_DIR)/obj.target/deps/openssl/lib/openssl-modules/fips.so',
'fipsconfig': '<(PRODUCT_DIR)/obj/deps/openssl/fipsmodule.cnf',
'opensslconfig_internal': '<(PRODUCT_DIR)/obj.target/deps/openssl/openssl.cnf',
}],
],
},
#'dependencies': [
#'./deps/openssl/openssl.gyp:openssl-fipsmodule'
#],
'actions': [
{
'action_name': 'fipsinstall',
Expand Down
8 changes: 6 additions & 2 deletions tools/gyp/pylib/gyp/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -104,8 +104,12 @@ def Load(
default_variables.setdefault(key, val)

output_dir = params["options"].generator_output or params["options"].toplevel_dir
default_variables.setdefault("PRODUCT_DIR_ABS", os.path.join(output_dir,
default_variables['CONFIGURATION_NAME']))
if (default_variables['GENERATOR'] == 'ninja'):
default_variables.setdefault("PRODUCT_DIR_ABS", os.path.join(output_dir,
'out', default_variables['build_type']))
else:
default_variables.setdefault("PRODUCT_DIR_ABS", os.path.join(output_dir,
default_variables['build_type']))

# Give the generator the opportunity to set additional variables based on
# the params it will receive in the output phase.
Expand Down

0 comments on commit 757e147

Please sign in to comment.