Skip to content

Commit

Permalink
build: start build on z/OS
Browse files Browse the repository at this point in the history
Update configure.py, Makefile, and common.gypi to get the
build started on z/OS.

Co-authored-by: Gaby Baghdadi <[email protected]>
Co-authored-by: Wayne Zhang <[email protected]>

PR-URL: #41273
Reviewed-By: Richard Lau <[email protected]>
Reviewed-By: Michael Dawson <[email protected]>
Reviewed-By: Ujjwal Sharma <[email protected]>
  • Loading branch information
alexcfyung authored and targos committed Jan 14, 2022
1 parent 2233f31 commit b0f0ad1
Show file tree
Hide file tree
Showing 3 changed files with 97 additions and 4 deletions.
10 changes: 10 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,9 @@ TEST_CI_ARGS ?=
STAGINGSERVER ?= node-www
LOGLEVEL ?= silent
OSTYPE := $(shell uname -s | tr '[:upper:]' '[:lower:]')
ifeq ($(findstring os/390,$OSTYPE),os/390)
OSTYPE ?= os390
endif
ARCHTYPE := $(shell uname -m | tr '[:upper:]' '[:lower:]')
COVTESTS ?= test-cov
COV_SKIP_TESTS ?= core_line_numbers.js,testFinalizer.js,test_function/test.js
Expand Down Expand Up @@ -824,6 +827,9 @@ endif # ifeq ($(DISTTYPE),release)
DISTTYPEDIR ?= $(DISTTYPE)
RELEASE=$(shell sed -ne 's/\#define NODE_VERSION_IS_RELEASE \([01]\)/\1/p' src/node_version.h)
PLATFORM=$(shell uname | tr '[:upper:]' '[:lower:]')
ifeq ($(findstring os/390,$PLATFORM),os/390)
PLATFORM ?= os390
endif
NPMVERSION=v$(shell cat deps/npm/package.json | grep '"version"' | sed 's/^[^:]*: "\([^"]*\)",.*/\1/')

UNAME_M=$(shell uname -m)
Expand All @@ -845,6 +851,9 @@ else
ifeq ($(findstring s390,$(UNAME_M)),s390)
DESTCPU ?= s390
else
ifeq ($(findstring OS/390,$(shell uname -s)),OS/390)
DESTCPU ?= s390x
else
ifeq ($(findstring arm64,$(UNAME_M)),arm64)
DESTCPU ?= arm64
else
Expand Down Expand Up @@ -872,6 +881,7 @@ endif
endif
endif
endif
endif
ifeq ($(DESTCPU),x64)
ARCH=x64
else
Expand Down
56 changes: 53 additions & 3 deletions common.gypi
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,10 @@
}],
['OS=="linux"', {
'node_section_ordering_info%': ''
}],
['OS == "zos"', {
# use ICU data file on z/OS
'icu_use_data_file_flag%': 1
}]
],
},
Expand Down Expand Up @@ -200,7 +204,11 @@
# pull in V8's postmortem metadata
'ldflags': [ '-Wl,-z,allextract' ]
}],
['OS!="mac" and OS!="win"', {
['OS=="zos"', {
# increase performance, number from experimentation
'cflags': [ '-qINLINE=::150:100000' ]
}],
['OS!="mac" and OS!="win" and OS!="zos"', {
'cflags': [ '-fno-omit-frame-pointer' ],
}],
['OS=="linux"', {
Expand Down Expand Up @@ -327,7 +335,7 @@
[ 'target_arch=="arm64"', {
'msvs_configuration_platform': 'arm64',
}],
['asan == 1 and OS != "mac"', {
['asan == 1 and OS != "mac" and OS != "zos"', {
'cflags+': [
'-fno-omit-frame-pointer',
'-fsanitize=address',
Expand Down Expand Up @@ -419,7 +427,7 @@
'cflags': [ '-m64', '-mminimal-toc' ],
'ldflags': [ '-m64' ],
}],
[ 'target_arch=="s390x"', {
[ 'target_arch=="s390x" and OS=="linux"', {
'cflags': [ '-m64', '-march=z196' ],
'ldflags': [ '-m64', '-march=z196' ],
}],
Expand Down Expand Up @@ -566,6 +574,48 @@
'OPENSSL_NO_ASM',
],
}],
['OS == "zos"', {
'defines': [
'_XOPEN_SOURCE_EXTENDED',
'_XOPEN_SOURCE=600',
'_UNIX03_THREADS',
'_UNIX03_WITHDRAWN',
'_UNIX03_SOURCE',
'_OPEN_SYS_SOCK_IPV6',
'_OPEN_SYS_FILE_EXT=1',
'_POSIX_SOURCE',
'_OPEN_SYS',
'_OPEN_SYS_IF_EXT',
'_OPEN_SYS_SOCK_IPV6',
'_OPEN_MSGQ_EXT',
'_LARGE_TIME_API',
'_ALL_SOURCE',
'_AE_BIMODAL=1',
'__IBMCPP_TR1__',
'NODE_PLATFORM="os390"',
'PATH_MAX=1024',
'_ENHANCED_ASCII_EXT=0xFFFFFFFF',
'_Export=extern',
'__static_assert=static_assert',
],
'cflags': [
'-q64',
'-Wc,DLL',
'-Wa,GOFF',
'-qARCH=10',
'-qASCII',
'-qTUNE=12',
'-qENUM=INT',
'-qEXPORTALL',
'-qASM',
],
'cflags_cc': [
'-qxclang=-std=c++14',
],
'ldflags': [
'-q64',
],
}],
],
}
}
35 changes: 34 additions & 1 deletion configure.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,9 @@
"Flags that allows you to control whether you want to build against "
"built-in dependencies or its shared representations. If necessary, "
"provide multiple libraries with comma.")
static_optgroup = parser.add_argument_group("Static libraries",
"Flags that allows you to control whether you want to build against "
"additional static libraries.")
intl_optgroup = parser.add_argument_group("Internationalization",
"Flags that lets you enable i18n features in Node.js as well as which "
"library you want to build against.")
Expand Down Expand Up @@ -413,6 +416,13 @@

parser.add_argument_group(shared_optgroup)

static_optgroup.add_argument('--static-zoslib-gyp',
action='store',
dest='static_zoslib_gyp',
help='path to zoslib.gyp file for includes and to link to static zoslib libray')

parser.add_argument_group(static_optgroup)

parser.add_argument('--systemtap-includes',
action='store',
dest='systemtap_includes',
Expand Down Expand Up @@ -858,7 +868,11 @@ def try_check_compiler(cc, lang):
proc.stdin.write(b'__clang__ __GNUC__ __GNUC_MINOR__ __GNUC_PATCHLEVEL__ '
b'__clang_major__ __clang_minor__ __clang_patchlevel__')

values = (to_utf8(proc.communicate()[0]).split() + ['0'] * 7)[0:7]
if sys.platform == 'zos':
values = (to_utf8(proc.communicate()[0]).split('\n')[-2].split() + ['0'] * 7)[0:7]
else:
values = (to_utf8(proc.communicate()[0]).split() + ['0'] * 7)[0:7]

is_clang = values[0] == '1'
gcc_version = tuple(map(int, values[1:1+3]))
clang_version = tuple(map(int, values[4:4+3])) if is_clang else None
Expand Down Expand Up @@ -1045,6 +1059,8 @@ def is_arm_hard_float_abi():
def host_arch_cc():
"""Host architecture check using the CC command."""

if sys.platform.startswith('zos'):
return 's390x'
k = cc_macros(os.environ.get('CC_host'))

matchup = {
Expand Down Expand Up @@ -1130,6 +1146,14 @@ def configure_mips(o, target_arch):
host_byteorder = 'little' if target_arch in ('mipsel', 'mips64el') else 'big'
o['variables']['v8_host_byteorder'] = host_byteorder

def configure_zos(o):
o['variables']['node_static_zoslib'] = b(True)
if options.static_zoslib_gyp:
# Apply to all Node.js components for now
o['include_dirs'] += [os.path.dirname(options.static_zoslib_gyp) + '/include']
else:
raise Exception('--static-zoslib-gyp=<path to zoslib.gyp file> is required.')

def clang_version_ge(version_checked):
for compiler in [(CC, 'c'), (CXX, 'c++')]:
ok, is_clang, clang_version, gcc_version = \
Expand Down Expand Up @@ -1199,6 +1223,8 @@ def configure_node(o):
configure_arm(o)
elif target_arch in ('mips', 'mipsel', 'mips64el'):
configure_mips(o, target_arch)
elif sys.platform == 'zos':
configure_zos(o)

if flavor == 'aix':
o['variables']['node_target_type'] = 'static_library'
Expand Down Expand Up @@ -1311,6 +1337,8 @@ def configure_node(o):
shlib_suffix = '%s.dylib'
elif sys.platform.startswith('aix'):
shlib_suffix = '%s.a'
elif sys.platform.startswith('zos'):
shlib_suffix = '%s.x'
else:
shlib_suffix = 'so.%s'
if '%s' in shlib_suffix:
Expand Down Expand Up @@ -1401,6 +1429,8 @@ def configure_v8(o):
o['variables']['test_isolation_mode'] = 'noop' # Needed by d8.gyp.
if options.without_bundled_v8 and options.enable_d8:
raise Exception('--enable-d8 is incompatible with --without-bundled-v8.')
if options.static_zoslib_gyp:
o['variables']['static_zoslib_gyp'] = options.static_zoslib_gyp


def configure_openssl(o):
Expand Down Expand Up @@ -1804,6 +1834,9 @@ def icu_download(path):
elif sys.platform.startswith('aix'):
icu_config['variables']['icu_asm_ext'] = 'S'
icu_config['variables']['icu_asm_opts'] = [ '-a', 'xlc' ]
elif sys.platform == 'zos':
icu_config['variables']['icu_asm_ext'] = 'S'
icu_config['variables']['icu_asm_opts'] = [ '-a', 'zos' ]
else:
# assume GCC-compatible asm is OK
icu_config['variables']['icu_asm_ext'] = 'S'
Expand Down

0 comments on commit b0f0ad1

Please sign in to comment.