Skip to content

Commit 929b740

Browse files
authored
Build fixes for z/OS (#695)
Fixes to enable the code to build with a simple `CC=xlc ./configure --enable-ebcdic --disable-unicode`. Fixes to the tests, so that `make check` passes on EBCDIC platforms. Add a CI job to do z/OS testing.
1 parent 3e68381 commit 929b740

12 files changed

+232
-42
lines changed

.github/workflows/build.yml

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -281,6 +281,55 @@ jobs:
281281
../maint/RunManifestTest install-dir ../maint/manifest-cmakeinstall-solaris
282282
../maint/RunSymbolTest install-dir/lib/ ../maint/
283283
284+
zos:
285+
name: z/OS
286+
runs-on: ubuntu-latest
287+
if: github.event_name != 'pull_request'
288+
concurrency:
289+
group: zos-ssh-build
290+
steps:
291+
- name: Checkout
292+
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
293+
with:
294+
submodules: true
295+
296+
- name: Prepare
297+
run: ./autogen.sh
298+
299+
- name: Build & test
300+
env:
301+
ZOS_HOST: ${{ secrets.ZOS_HOST }}
302+
ZOS_PORT: ${{ secrets.ZOS_PORT }}
303+
ZOS_PRIVATE_KEY: ${{ secrets.ZOS_PRIVATE_KEY }}
304+
ZOS_KNOWN_HOSTS: ${{ secrets.ZOS_KNOWN_HOSTS }}
305+
run: |
306+
(umask 0077 && printenv ZOS_PRIVATE_KEY > id_rsa_zos)
307+
mkdir -p ~/.ssh
308+
printenv ZOS_KNOWN_HOSTS > ~/.ssh/known_hosts
309+
310+
tar czf ../pcre2-build.tar.gz --exclude=.git .
311+
mv ../pcre2-build.tar.gz .
312+
313+
scp -i id_rsa_zos -P "$ZOS_PORT" pcre2-build.tar.gz "$ZOS_HOST:/data/"
314+
ssh -i id_rsa_zos -p "$ZOS_PORT" "$ZOS_HOST" /data/zopen/usr/local/bin/bash -c \
315+
'export _BPXK_AUTOCVT=ON;
316+
export _CEE_RUNOPTS="FILETAG(AUTOCVT,AUTOTAG) POSIX(ON)";
317+
export _TAG_REDIR_ERR=txt;
318+
export _TAG_REDIR_IN=txt;
319+
export _TAG_REDIR_OUT=txt;
320+
. /data/zopen/etc/zopen-config;
321+
set -e;
322+
set -x;
323+
cd /data;
324+
rm -rf pcre2-build;
325+
mkdir pcre2-build;
326+
gtar xzf pcre2-build.tar.gz -C pcre2-build;
327+
cd pcre2-build;
328+
chtag -R -tc ISO8859-1 .;
329+
MAKE=gmake CC=xlc ./configure --enable-ebcdic --disable-unicode;
330+
gmake;
331+
gmake check'
332+
284333
distcheck:
285334
name: Build & verify distribution
286335
runs-on: ubuntu-latest

Makefile.am

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -235,6 +235,7 @@ lib_LTLIBRARIES =
235235
# TESTS is for binary unit tests, check_SCRIPTS for script-based tests
236236

237237
TESTS =
238+
XFAIL_TESTS =
238239
check_SCRIPTS =
239240
dist_noinst_SCRIPTS =
240241

@@ -725,6 +726,9 @@ if WITH_PCRE2_8
725726
TESTS += RunGrepTest
726727
EXTRA_DIST += RunGrepTest.bat
727728
dist_noinst_SCRIPTS += RunGrepTest
729+
if WITH_EBCDIC
730+
XFAIL_TESTS += RunGrepTest
731+
endif # WITH_EBCDIC
728732
endif # WITH_PCRE2_8
729733

730734
## Distribute all the test data files

RunTest

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -130,9 +130,11 @@ fi
130130

131131
# Set up a suitable "diff" command for comparison. Some systems
132132
# have a diff that lacks a -u option. Try to deal with this.
133+
# Use gdiff if available.
133134

134135
cf="diff"
135-
diff -u /dev/null /dev/null 2>/dev/null && cf="diff -u"
136+
gdiff /dev/null /dev/null 2>/dev/null && cf="gdiff"
137+
$cf -u /dev/null /dev/null 2>/dev/null && cf="$cf -u"
136138

137139
# Find the test data
138140

configure.ac

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,9 @@ m4_ifdef([AM_PROG_AR], [AM_PROG_AR])
7272
# Check for a 64-bit integer type
7373
AC_TYPE_INT64_T
7474

75+
# Check for xlc which has some special (broken/non-standard) behaviour on z/OS.
76+
PCRE2_ZOS_FIXES
77+
7578
AC_PROG_INSTALL
7679
LT_INIT([win32-dll])
7780
AC_PROG_LN_S

m4/pcre2_zos.m4

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
dnl Tests whether the compiler requires an additional flag in order to fail on
2+
dnl undefined headers.
3+
4+
dnl The concept of setting this commandline flag was learned from patches and
5+
dnl mailing list discussions of the gnulib and gawk projects (credit to
6+
dnl Bruno Haible).
7+
8+
AC_DEFUN([PCRE2_ZOS_FIXES],
9+
[
10+
AC_CACHE_CHECK([for OS/390 (z/OS)], [pcre2_cv_os390],
11+
[if test "`uname`" = "OS/390"; then
12+
pcre2_cv_os390=yes
13+
else
14+
pcre2_cv_os390=no
15+
fi])
16+
if test "$pcre2_cv_os390" = "yes"; then
17+
AC_CACHE_CHECK([whether the compiler supports -qhaltonmsg=CCN3296], [pcre2_cv_xlc_qhaltonmsg_support],
18+
[save_CFLAGS="$CFLAGS"
19+
CFLAGS="$CFLAGS -qhaltonmsg=CCN3296"
20+
AC_COMPILE_IFELSE([AC_LANG_PROGRAM([])],
21+
[pcre2_cv_xlc_qhaltonmsg_support=yes],
22+
[pcre2_cv_xlc_qhaltonmsg_support=no])
23+
CFLAGS="$save_CFLAGS"
24+
])
25+
26+
AC_CACHE_CHECK([whether non-existent headers fail the compile], [pcre2_cv_xlc_nonexistent_fatal],
27+
[AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <thereshouldbenoheader.h>]])],
28+
[pcre2_cv_xlc_nonexistent_fatal=no],
29+
[pcre2_cv_xlc_nonexistent_fatal=yes])
30+
])
31+
32+
if test "$pcre2_cv_xlc_nonexistent_fatal" = "no" && test "$pcre2_cv_xlc_qhaltonmsg_support" = "yes"; then
33+
AC_CACHE_CHECK([whether -qhaltonmsg=CCN3296 fixes the non-existent-header issue], [pcre2_cv_xlc_qhaltonmsg_fixes],
34+
[save_CFLAGS="$CFLAGS"
35+
CFLAGS="$CFLAGS -qhaltonmsg=CCN3296"
36+
AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <thereshouldbenoheader.h>]])],
37+
[pcre2_cv_xlc_qhaltonmsg_fixes=no],
38+
[pcre2_cv_xlc_qhaltonmsg_fixes=yes])
39+
CFLAGS="$save_CFLAGS"
40+
])
41+
42+
if test "$pcre2_cv_xlc_qhaltonmsg_fixes" = "no"; then
43+
AC_MSG_ERROR([-qhaltonmsg=CCN3296 not effective on non-existent headers])
44+
fi
45+
46+
CFLAGS="$CFLAGS -qhaltonmsg=CCN3296"
47+
fi
48+
49+
fi
50+
])

maint/manifest-tarball

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -295,6 +295,7 @@ drwxr-xr-x tarball-dir/pcre2-SNAPSHOT/m4
295295
-rw-r--r-- tarball-dir/pcre2-SNAPSHOT/m4/ltversion.m4
296296
-rw-r--r-- tarball-dir/pcre2-SNAPSHOT/m4/lt~obsolete.m4
297297
-rw-r--r-- tarball-dir/pcre2-SNAPSHOT/m4/pcre2_visibility.m4
298+
-rw-r--r-- tarball-dir/pcre2-SNAPSHOT/m4/pcre2_zos.m4
298299
-rwxr-xr-x tarball-dir/pcre2-SNAPSHOT/missing
299300
-rw-r--r-- tarball-dir/pcre2-SNAPSHOT/pcre2-config.in
300301
-rwxr-xr-x tarball-dir/pcre2-SNAPSHOT/perltest.sh

src/pcre2_compile.c

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -55,11 +55,14 @@ POSSIBILITY OF SUCH DAMAGE.
5555
#else
5656
#define PRINTABLE(c) ((c) >= 32 && (c) < 127)
5757
#endif
58-
#define CHAR_OUTPUT(c) (c)
59-
#define CHAR_INPUT(c) (c)
58+
#define CHAR_OUTPUT(c) (c)
59+
#define CHAR_OUTPUT_HEX(c) (c)
60+
#define CHAR_INPUT(c) (c)
61+
#define CHAR_INPUT_HEX(c) (c)
6062
#include "pcre2_printint.c"
6163
#undef PRINTABLE
6264
#undef CHAR_OUTPUT
65+
#undef CHAR_OUTPUT_HEX
6366
#undef CHAR_INPUT
6467
#define DEBUG_CALL_PRINTINT
6568
#endif

src/pcre2_compile_class.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1285,7 +1285,7 @@ while (TRUE)
12851285
uint8_t posix_vertical[4] = { CHAR_LF, CHAR_VT, CHAR_FF, CHAR_CR };
12861286
uint8_t posix_underscore = CHAR_UNDERSCORE;
12871287
uint8_t *chars = NULL;
1288-
uint n = 0;
1288+
int n = 0;
12891289

12901290
if (tabopt == 1) { chars = posix_vertical; n = 4; }
12911291
else if (tabopt == 2) { chars = &posix_underscore; n = 1; }

src/pcre2_printint.c

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -120,10 +120,10 @@ if (utf)
120120
if (one_code_unit)
121121
{
122122
if (PRINTABLE(c))
123-
fprintf(f, "%c", (char)CHAR_OUTPUT(c));
123+
fprintf(f, "%c", CHAR_OUTPUT(c));
124124
else
125125
{
126-
c = CHAR_OUTPUT(c);
126+
c = CHAR_OUTPUT_HEX(c);
127127
if (c < 0x80) fprintf(f, "\\x%02x", c);
128128
else fprintf(f, "\\x{%02x}", c);
129129
}
@@ -219,7 +219,7 @@ while (*ptr != '\0')
219219
{
220220
uint32_t c = *ptr++;
221221
if (PRINTABLE(c)) fprintf(f, "%c", CHAR_OUTPUT(c));
222-
else fprintf(f, "\\x{%x}", CHAR_OUTPUT(c));
222+
else fprintf(f, "\\x{%x}", CHAR_OUTPUT_HEX(c));
223223
}
224224
}
225225

@@ -230,7 +230,7 @@ for (; len > 0; len--)
230230
{
231231
uint32_t c = *ptr++;
232232
if (PRINTABLE(c)) fprintf(f, "%c", CHAR_OUTPUT(c));
233-
else fprintf(f, "\\x{%x}", CHAR_OUTPUT(c));
233+
else fprintf(f, "\\x{%x}", CHAR_OUTPUT_HEX(c));
234234
}
235235
}
236236

@@ -481,22 +481,22 @@ if (negated)
481481

482482
for (input = 0; input < 256; input++)
483483
{
484-
i = CHAR_INPUT(input);
484+
i = CHAR_INPUT_HEX(input);
485485
if ((map[i/8] & (1u << (i&7))) != 0)
486486
{
487487
int j, jinput;
488488
for (jinput = input; jinput+1 < 256; jinput++)
489489
{
490-
j = CHAR_INPUT(jinput+1);
490+
j = CHAR_INPUT_HEX(jinput+1);
491491
if ((map[j/8] & (1u << (j&7))) == 0) break;
492492
}
493-
j = CHAR_INPUT(jinput);
493+
j = CHAR_INPUT_HEX(jinput);
494494
if (i == CHAR_MINUS || i == CHAR_BACKSLASH ||
495495
i == CHAR_RIGHT_SQUARE_BRACKET ||
496496
(first && i == CHAR_CIRCUMFLEX_ACCENT))
497497
fprintf(f, "\\");
498498
if (PRINTABLE(i)) fprintf(f, "%c", CHAR_OUTPUT(i));
499-
else fprintf(f, "\\x%02x", CHAR_OUTPUT(i));
499+
else fprintf(f, "\\x%02x", CHAR_OUTPUT_HEX(i));
500500
first = FALSE;
501501
if (jinput > input)
502502
{
@@ -505,7 +505,7 @@ for (input = 0; input < 256; input++)
505505
j == CHAR_RIGHT_SQUARE_BRACKET)
506506
fprintf(f, "\\");
507507
if (PRINTABLE(j)) fprintf(f, "%c", CHAR_OUTPUT(j));
508-
else fprintf(f, "\\x%02x", CHAR_OUTPUT(j));
508+
else fprintf(f, "\\x%02x", CHAR_OUTPUT_HEX(j));
509509
}
510510
input = jinput;
511511
}

0 commit comments

Comments
 (0)