Skip to content

Commit b0f0ad1

Browse files
alexcfyungtargos
authored andcommittedJan 14, 2022
build: start build on z/OS
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]>
1 parent 2233f31 commit b0f0ad1

File tree

3 files changed

+97
-4
lines changed

3 files changed

+97
-4
lines changed
 

‎Makefile

+10
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,9 @@ TEST_CI_ARGS ?=
1010
STAGINGSERVER ?= node-www
1111
LOGLEVEL ?= silent
1212
OSTYPE := $(shell uname -s | tr '[:upper:]' '[:lower:]')
13+
ifeq ($(findstring os/390,$OSTYPE),os/390)
14+
OSTYPE ?= os390
15+
endif
1316
ARCHTYPE := $(shell uname -m | tr '[:upper:]' '[:lower:]')
1417
COVTESTS ?= test-cov
1518
COV_SKIP_TESTS ?= core_line_numbers.js,testFinalizer.js,test_function/test.js
@@ -824,6 +827,9 @@ endif # ifeq ($(DISTTYPE),release)
824827
DISTTYPEDIR ?= $(DISTTYPE)
825828
RELEASE=$(shell sed -ne 's/\#define NODE_VERSION_IS_RELEASE \([01]\)/\1/p' src/node_version.h)
826829
PLATFORM=$(shell uname | tr '[:upper:]' '[:lower:]')
830+
ifeq ($(findstring os/390,$PLATFORM),os/390)
831+
PLATFORM ?= os390
832+
endif
827833
NPMVERSION=v$(shell cat deps/npm/package.json | grep '"version"' | sed 's/^[^:]*: "\([^"]*\)",.*/\1/')
828834

829835
UNAME_M=$(shell uname -m)
@@ -845,6 +851,9 @@ else
845851
ifeq ($(findstring s390,$(UNAME_M)),s390)
846852
DESTCPU ?= s390
847853
else
854+
ifeq ($(findstring OS/390,$(shell uname -s)),OS/390)
855+
DESTCPU ?= s390x
856+
else
848857
ifeq ($(findstring arm64,$(UNAME_M)),arm64)
849858
DESTCPU ?= arm64
850859
else
@@ -872,6 +881,7 @@ endif
872881
endif
873882
endif
874883
endif
884+
endif
875885
ifeq ($(DESTCPU),x64)
876886
ARCH=x64
877887
else

‎common.gypi

+53-3
Original file line numberDiff line numberDiff line change
@@ -109,6 +109,10 @@
109109
}],
110110
['OS=="linux"', {
111111
'node_section_ordering_info%': ''
112+
}],
113+
['OS == "zos"', {
114+
# use ICU data file on z/OS
115+
'icu_use_data_file_flag%': 1
112116
}]
113117
],
114118
},
@@ -200,7 +204,11 @@
200204
# pull in V8's postmortem metadata
201205
'ldflags': [ '-Wl,-z,allextract' ]
202206
}],
203-
['OS!="mac" and OS!="win"', {
207+
['OS=="zos"', {
208+
# increase performance, number from experimentation
209+
'cflags': [ '-qINLINE=::150:100000' ]
210+
}],
211+
['OS!="mac" and OS!="win" and OS!="zos"', {
204212
'cflags': [ '-fno-omit-frame-pointer' ],
205213
}],
206214
['OS=="linux"', {
@@ -327,7 +335,7 @@
327335
[ 'target_arch=="arm64"', {
328336
'msvs_configuration_platform': 'arm64',
329337
}],
330-
['asan == 1 and OS != "mac"', {
338+
['asan == 1 and OS != "mac" and OS != "zos"', {
331339
'cflags+': [
332340
'-fno-omit-frame-pointer',
333341
'-fsanitize=address',
@@ -419,7 +427,7 @@
419427
'cflags': [ '-m64', '-mminimal-toc' ],
420428
'ldflags': [ '-m64' ],
421429
}],
422-
[ 'target_arch=="s390x"', {
430+
[ 'target_arch=="s390x" and OS=="linux"', {
423431
'cflags': [ '-m64', '-march=z196' ],
424432
'ldflags': [ '-m64', '-march=z196' ],
425433
}],
@@ -566,6 +574,48 @@
566574
'OPENSSL_NO_ASM',
567575
],
568576
}],
577+
['OS == "zos"', {
578+
'defines': [
579+
'_XOPEN_SOURCE_EXTENDED',
580+
'_XOPEN_SOURCE=600',
581+
'_UNIX03_THREADS',
582+
'_UNIX03_WITHDRAWN',
583+
'_UNIX03_SOURCE',
584+
'_OPEN_SYS_SOCK_IPV6',
585+
'_OPEN_SYS_FILE_EXT=1',
586+
'_POSIX_SOURCE',
587+
'_OPEN_SYS',
588+
'_OPEN_SYS_IF_EXT',
589+
'_OPEN_SYS_SOCK_IPV6',
590+
'_OPEN_MSGQ_EXT',
591+
'_LARGE_TIME_API',
592+
'_ALL_SOURCE',
593+
'_AE_BIMODAL=1',
594+
'__IBMCPP_TR1__',
595+
'NODE_PLATFORM="os390"',
596+
'PATH_MAX=1024',
597+
'_ENHANCED_ASCII_EXT=0xFFFFFFFF',
598+
'_Export=extern',
599+
'__static_assert=static_assert',
600+
],
601+
'cflags': [
602+
'-q64',
603+
'-Wc,DLL',
604+
'-Wa,GOFF',
605+
'-qARCH=10',
606+
'-qASCII',
607+
'-qTUNE=12',
608+
'-qENUM=INT',
609+
'-qEXPORTALL',
610+
'-qASM',
611+
],
612+
'cflags_cc': [
613+
'-qxclang=-std=c++14',
614+
],
615+
'ldflags': [
616+
'-q64',
617+
],
618+
}],
569619
],
570620
}
571621
}

‎configure.py

+34-1
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,9 @@
6262
"Flags that allows you to control whether you want to build against "
6363
"built-in dependencies or its shared representations. If necessary, "
6464
"provide multiple libraries with comma.")
65+
static_optgroup = parser.add_argument_group("Static libraries",
66+
"Flags that allows you to control whether you want to build against "
67+
"additional static libraries.")
6568
intl_optgroup = parser.add_argument_group("Internationalization",
6669
"Flags that lets you enable i18n features in Node.js as well as which "
6770
"library you want to build against.")
@@ -413,6 +416,13 @@
413416

414417
parser.add_argument_group(shared_optgroup)
415418

419+
static_optgroup.add_argument('--static-zoslib-gyp',
420+
action='store',
421+
dest='static_zoslib_gyp',
422+
help='path to zoslib.gyp file for includes and to link to static zoslib libray')
423+
424+
parser.add_argument_group(static_optgroup)
425+
416426
parser.add_argument('--systemtap-includes',
417427
action='store',
418428
dest='systemtap_includes',
@@ -858,7 +868,11 @@ def try_check_compiler(cc, lang):
858868
proc.stdin.write(b'__clang__ __GNUC__ __GNUC_MINOR__ __GNUC_PATCHLEVEL__ '
859869
b'__clang_major__ __clang_minor__ __clang_patchlevel__')
860870

861-
values = (to_utf8(proc.communicate()[0]).split() + ['0'] * 7)[0:7]
871+
if sys.platform == 'zos':
872+
values = (to_utf8(proc.communicate()[0]).split('\n')[-2].split() + ['0'] * 7)[0:7]
873+
else:
874+
values = (to_utf8(proc.communicate()[0]).split() + ['0'] * 7)[0:7]
875+
862876
is_clang = values[0] == '1'
863877
gcc_version = tuple(map(int, values[1:1+3]))
864878
clang_version = tuple(map(int, values[4:4+3])) if is_clang else None
@@ -1045,6 +1059,8 @@ def is_arm_hard_float_abi():
10451059
def host_arch_cc():
10461060
"""Host architecture check using the CC command."""
10471061

1062+
if sys.platform.startswith('zos'):
1063+
return 's390x'
10481064
k = cc_macros(os.environ.get('CC_host'))
10491065

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

1149+
def configure_zos(o):
1150+
o['variables']['node_static_zoslib'] = b(True)
1151+
if options.static_zoslib_gyp:
1152+
# Apply to all Node.js components for now
1153+
o['include_dirs'] += [os.path.dirname(options.static_zoslib_gyp) + '/include']
1154+
else:
1155+
raise Exception('--static-zoslib-gyp=<path to zoslib.gyp file> is required.')
1156+
11331157
def clang_version_ge(version_checked):
11341158
for compiler in [(CC, 'c'), (CXX, 'c++')]:
11351159
ok, is_clang, clang_version, gcc_version = \
@@ -1199,6 +1223,8 @@ def configure_node(o):
11991223
configure_arm(o)
12001224
elif target_arch in ('mips', 'mipsel', 'mips64el'):
12011225
configure_mips(o, target_arch)
1226+
elif sys.platform == 'zos':
1227+
configure_zos(o)
12021228

12031229
if flavor == 'aix':
12041230
o['variables']['node_target_type'] = 'static_library'
@@ -1311,6 +1337,8 @@ def configure_node(o):
13111337
shlib_suffix = '%s.dylib'
13121338
elif sys.platform.startswith('aix'):
13131339
shlib_suffix = '%s.a'
1340+
elif sys.platform.startswith('zos'):
1341+
shlib_suffix = '%s.x'
13141342
else:
13151343
shlib_suffix = 'so.%s'
13161344
if '%s' in shlib_suffix:
@@ -1401,6 +1429,8 @@ def configure_v8(o):
14011429
o['variables']['test_isolation_mode'] = 'noop' # Needed by d8.gyp.
14021430
if options.without_bundled_v8 and options.enable_d8:
14031431
raise Exception('--enable-d8 is incompatible with --without-bundled-v8.')
1432+
if options.static_zoslib_gyp:
1433+
o['variables']['static_zoslib_gyp'] = options.static_zoslib_gyp
14041434

14051435

14061436
def configure_openssl(o):
@@ -1804,6 +1834,9 @@ def icu_download(path):
18041834
elif sys.platform.startswith('aix'):
18051835
icu_config['variables']['icu_asm_ext'] = 'S'
18061836
icu_config['variables']['icu_asm_opts'] = [ '-a', 'xlc' ]
1837+
elif sys.platform == 'zos':
1838+
icu_config['variables']['icu_asm_ext'] = 'S'
1839+
icu_config['variables']['icu_asm_opts'] = [ '-a', 'zos' ]
18071840
else:
18081841
# assume GCC-compatible asm is OK
18091842
icu_config['variables']['icu_asm_ext'] = 'S'

0 commit comments

Comments
 (0)
Please sign in to comment.