deps,build,tools: fix openssl-is-fips for ninja builds

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

PR-URL: https://github.com/nodejs/node/pull/40518
Refs: https://github.com/nodejs/node/issues/40509
Reviewed-By: Richard Lau <rlau@redhat.com>
Reviewed-By: Beth Griggs <bgriggs@redhat.com>
pull/40543/head
Daniel Bevenius 2021-10-19 10:04:22 +02:00
parent 73b2d3bc41
commit f4bd91b0e2
6 changed files with 30 additions and 13 deletions

View File

@ -1980,6 +1980,7 @@ write('config.mk', do_not_edit + config_str)
gyp_args = ['--no-parallel', '-Dconfiguring_node=1']
gyp_args += ['-Dbuild_type=' + config['BUILDTYPE']]
if options.use_ninja:
gyp_args += ['-f', 'ninja']

View File

@ -100,7 +100,7 @@ copy("$src_dir/providers/common/include/prov/der_ec.h",
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";

View File

@ -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',
}],
],
},
@ -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)"',
]
}],
],

View File

@ -62,7 +62,6 @@
# linux and others
'cflags': ['-Wno-missing-field-initializers',],
'defines': [
'OPENSSLDIR="<(obj_dir_abs)/deps/openssl"',
'ENGINESDIR="/dev/null"',
'TERMIOS',
],

View File

@ -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',

View File

@ -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.