Skip to content

Commit c49a651

Browse files
alexcfyungdanielleadams
authored andcommitted
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 fc38d15 commit c49a651

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
@@ -118,6 +118,10 @@
118118
}],
119119
['OS=="linux"', {
120120
'node_section_ordering_info%': ''
121+
}],
122+
['OS == "zos"', {
123+
# use ICU data file on z/OS
124+
'icu_use_data_file_flag%': 1
121125
}]
122126
],
123127
},
@@ -209,7 +213,11 @@
209213
# pull in V8's postmortem metadata
210214
'ldflags': [ '-Wl,-z,allextract' ]
211215
}],
212-
['OS!="mac" and OS!="win"', {
216+
['OS=="zos"', {
217+
# increase performance, number from experimentation
218+
'cflags': [ '-qINLINE=::150:100000' ]
219+
}],
220+
['OS!="mac" and OS!="win" and OS!="zos"', {
213221
'cflags': [ '-fno-omit-frame-pointer' ],
214222
}],
215223
['OS=="linux"', {
@@ -333,7 +341,7 @@
333341
[ 'target_arch=="arm64"', {
334342
'msvs_configuration_platform': 'arm64',
335343
}],
336-
['asan == 1 and OS != "mac"', {
344+
['asan == 1 and OS != "mac" and OS != "zos"', {
337345
'cflags+': [
338346
'-fno-omit-frame-pointer',
339347
'-fsanitize=address',
@@ -425,7 +433,7 @@
425433
'cflags': [ '-m64', '-mminimal-toc' ],
426434
'ldflags': [ '-m64' ],
427435
}],
428-
[ 'target_arch=="s390x"', {
436+
[ 'target_arch=="s390x" and OS=="linux"', {
429437
'cflags': [ '-m64', '-march=z196' ],
430438
'ldflags': [ '-m64', '-march=z196' ],
431439
}],
@@ -572,6 +580,48 @@
572580
'OPENSSL_NO_ASM',
573581
],
574582
}],
583+
['OS == "zos"', {
584+
'defines': [
585+
'_XOPEN_SOURCE_EXTENDED',
586+
'_XOPEN_SOURCE=600',
587+
'_UNIX03_THREADS',
588+
'_UNIX03_WITHDRAWN',
589+
'_UNIX03_SOURCE',
590+
'_OPEN_SYS_SOCK_IPV6',
591+
'_OPEN_SYS_FILE_EXT=1',
592+
'_POSIX_SOURCE',
593+
'_OPEN_SYS',
594+
'_OPEN_SYS_IF_EXT',
595+
'_OPEN_SYS_SOCK_IPV6',
596+
'_OPEN_MSGQ_EXT',
597+
'_LARGE_TIME_API',
598+
'_ALL_SOURCE',
599+
'_AE_BIMODAL=1',
600+
'__IBMCPP_TR1__',
601+
'NODE_PLATFORM="os390"',
602+
'PATH_MAX=1024',
603+
'_ENHANCED_ASCII_EXT=0xFFFFFFFF',
604+
'_Export=extern',
605+
'__static_assert=static_assert',
606+
],
607+
'cflags': [
608+
'-q64',
609+
'-Wc,DLL',
610+
'-Wa,GOFF',
611+
'-qARCH=10',
612+
'-qASCII',
613+
'-qTUNE=12',
614+
'-qENUM=INT',
615+
'-qEXPORTALL',
616+
'-qASM',
617+
],
618+
'cflags_cc': [
619+
'-qxclang=-std=c++14',
620+
],
621+
'ldflags': [
622+
'-q64',
623+
],
624+
}],
575625
],
576626
}
577627
}

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.")
@@ -418,6 +421,13 @@
418421

419422
parser.add_argument_group(shared_optgroup)
420423

424+
static_optgroup.add_argument('--static-zoslib-gyp',
425+
action='store',
426+
dest='static_zoslib_gyp',
427+
help='path to zoslib.gyp file for includes and to link to static zoslib libray')
428+
429+
parser.add_argument_group(static_optgroup)
430+
421431
parser.add_argument('--systemtap-includes',
422432
action='store',
423433
dest='systemtap_includes',
@@ -863,7 +873,11 @@ def try_check_compiler(cc, lang):
863873
proc.stdin.write(b'__clang__ __GNUC__ __GNUC_MINOR__ __GNUC_PATCHLEVEL__ '
864874
b'__clang_major__ __clang_minor__ __clang_patchlevel__')
865875

866-
values = (to_utf8(proc.communicate()[0]).split() + ['0'] * 7)[0:7]
876+
if sys.platform == 'zos':
877+
values = (to_utf8(proc.communicate()[0]).split('\n')[-2].split() + ['0'] * 7)[0:7]
878+
else:
879+
values = (to_utf8(proc.communicate()[0]).split() + ['0'] * 7)[0:7]
880+
867881
is_clang = values[0] == '1'
868882
gcc_version = tuple(map(int, values[1:1+3]))
869883
clang_version = tuple(map(int, values[4:4+3])) if is_clang else None
@@ -1050,6 +1064,8 @@ def is_arm_hard_float_abi():
10501064
def host_arch_cc():
10511065
"""Host architecture check using the CC command."""
10521066

1067+
if sys.platform.startswith('zos'):
1068+
return 's390x'
10531069
k = cc_macros(os.environ.get('CC_host'))
10541070

10551071
matchup = {
@@ -1135,6 +1151,14 @@ def configure_mips(o, target_arch):
11351151
host_byteorder = 'little' if target_arch in ('mipsel', 'mips64el') else 'big'
11361152
o['variables']['v8_host_byteorder'] = host_byteorder
11371153

1154+
def configure_zos(o):
1155+
o['variables']['node_static_zoslib'] = b(True)
1156+
if options.static_zoslib_gyp:
1157+
# Apply to all Node.js components for now
1158+
o['include_dirs'] += [os.path.dirname(options.static_zoslib_gyp) + '/include']
1159+
else:
1160+
raise Exception('--static-zoslib-gyp=<path to zoslib.gyp file> is required.')
1161+
11381162
def clang_version_ge(version_checked):
11391163
for compiler in [(CC, 'c'), (CXX, 'c++')]:
11401164
ok, is_clang, clang_version, gcc_version = \
@@ -1204,6 +1228,8 @@ def configure_node(o):
12041228
configure_arm(o)
12051229
elif target_arch in ('mips', 'mipsel', 'mips64el'):
12061230
configure_mips(o, target_arch)
1231+
elif sys.platform == 'zos':
1232+
configure_zos(o)
12071233

12081234
if flavor == 'aix':
12091235
o['variables']['node_target_type'] = 'static_library'
@@ -1316,6 +1342,8 @@ def configure_node(o):
13161342
shlib_suffix = '%s.dylib'
13171343
elif sys.platform.startswith('aix'):
13181344
shlib_suffix = '%s.a'
1345+
elif sys.platform.startswith('zos'):
1346+
shlib_suffix = '%s.x'
13191347
else:
13201348
shlib_suffix = 'so.%s'
13211349
if '%s' in shlib_suffix:
@@ -1406,6 +1434,8 @@ def configure_v8(o):
14061434
o['variables']['test_isolation_mode'] = 'noop' # Needed by d8.gyp.
14071435
if options.without_bundled_v8 and options.enable_d8:
14081436
raise Exception('--enable-d8 is incompatible with --without-bundled-v8.')
1437+
if options.static_zoslib_gyp:
1438+
o['variables']['static_zoslib_gyp'] = options.static_zoslib_gyp
14091439

14101440

14111441
def configure_openssl(o):
@@ -1809,6 +1839,9 @@ def icu_download(path):
18091839
elif sys.platform.startswith('aix'):
18101840
icu_config['variables']['icu_asm_ext'] = 'S'
18111841
icu_config['variables']['icu_asm_opts'] = [ '-a', 'xlc' ]
1842+
elif sys.platform == 'zos':
1843+
icu_config['variables']['icu_asm_ext'] = 'S'
1844+
icu_config['variables']['icu_asm_opts'] = [ '-a', 'zos' ]
18121845
else:
18131846
# assume GCC-compatible asm is OK
18141847
icu_config['variables']['icu_asm_ext'] = 'S'

0 commit comments

Comments
 (0)