Simon Sobisch - 2020-12-17

Just rechecked the current status. This is primarily a "documentary note" about GnuCOBOL 3.x on IBM/S390 with its supported Linux OS for that machine.

  • register, wait one business day to receive activation mail, login
  • create instance (on the first one let it create a key-pair, download as IBM.pem
  • ssh -o "UserKnownHostsFile=/dev/null" -o "StrictHostKeyChecking=no" -i "IBM.pem" "linux1@$ip_from_instance" (we totally disable the key check here as the servers key will change when changing the instance - if you have a "permanent" one you'd leave those two options aside).

Then, depending on the instance used do as follows.

SLES15SP1:

$ zypper search libdb # as the version number may change

$ sudo zypper install make gcc gmp-devel libjson-c-devel ncurses-devel libxml2-devel libdb-4_8-devel

$ wget https://ftpmirror.gnu.org/gnucobol/gnucobol-3.1.1.tar.xz

$ tar -xvf gnucobol-3.1.1.tar.xz && cd gnucobol-3.1.1 && ./configure

$ make -j3 # we have 2 cores with 5200MHz, give them something to do

$ make -j2 checkall TESTSUITEFLAGS="--jobs=3" # results: all as expected

$ sudo make install

$ cobc --info | grep build -A30  # see note below for LD_LIBRARY_PATH
build information
build environment        : s390x-ibm-linux-gnu
CC                       : gcc
C version                : "7.5.0"
CPPFLAGS                 :
CFLAGS                   : -O2 -pipe -finline-functions -fsigned-char
                           -Wall -Wwrite-strings -Wmissing-prototypes
                           -Wno-format-y2k
LD                       : /usr/s390x-suse-linux/bin/ld -m elf64_s390
LDFLAGS                  :  -Wl,-z,relro,-z,now,-O1

GnuCOBOL information
COB_CC                   : gcc
COB_CFLAGS               : -pipe -I/usr/local/include -Wno-unused
                           -fsigned-char -Wno-pointer-sign
COB_DEBUG_FLAGS          : -ggdb3 -fasynchronous-unwind-tables
COB_LDFLAGS              :
COB_LIBS                 : -L/usr/local/lib -lcob -lm
COB_CONFIG_DIR           : /usr/local/share/gnucobol/config
COB_COPY_DIR             : /usr/local/share/gnucobol/copy
COB_MSG_FORMAT           : GCC
COB_OBJECT_EXT           : o
COB_MODULE_EXT           : so
COB_EXE_EXT              :
64bit-mode               : yes
BINARY-C-LONG            : 8 bytes
endianness               : big-endian
native EBCDIC            : no
extended screen I/O      : ncursesw
variable file format     : 0
sequential file handler  : built-in
indexed file handler     : BDB

$ cobcrun -v -info | grep -A10 indexed
indexed file handler     : BDB, version 4.8.30
mathematical library     : GMP, version 6.1.2
XML library              : libxml2, version 2.9.7
JSON library             : json-c, version 0.13.0
extended screen I/O      : ncursesw, version 6.1.20180317 (CHTYPE=32, WIDE=1)
mouse support            : yes

note to myself: also tested with configure --enable-hardening PROGRAMS_LIBS="'-Wl,-rpath -Wl,${exec_prefix}/lib' , which also passed make checkall and removes the need to have LD_LIBRARY_PATH set for cobcandcobcrun

RHEL7.8:

$ sudo yum install gcc gmp-devel libxml2-devel ncurses-devel libdb-devel # no json-c-devel as it is too old; make is already installed

$ curl https://ftp.gnu.org/gnu/gnucobol/gnucobol-3.1.1.tar.xz -o gnucobol-3.1.1.tar.xz && tar -xvf gnucobol-3.1.1.tar.xz && cd gnucobol-3.1.1

$ https://raw.githubusercontent.com/DaveGamble/cJSON/v1.7.14/cJSON.c -o libcob/cJON.c
$ https://raw.githubusercontent.com/DaveGamble/cJSON/v1.7.14/cJSON.h -o libcob/cJON.h

$ ./configure

$ make -j3 # we have 2 cores with 5200MHz, give them something to do

$ make -j2 checkall TESTSUITEFLAGS="--jobs=3" # results: all as expected

$ sudo make install

$ cobc --info | grep build -A30
build information
build environment        : s390x-ibm-linux-gnu
CC                       : gcc -std=gnu99
C version                : "4.8.5 20150623 (Red Hat 4.8.5-44)"
CPPFLAGS                 :
CFLAGS                   : -O2 -pipe -finline-functions -fsigned-char
                           -Wall -Wwrite-strings -Wmissing-prototypes
                           -Wno-format-y2k
LD                       : /usr/bin/ld -m elf64_s390
LDFLAGS                  :  -Wl,-z,relro,-z,now,-O1

GnuCOBOL information
COB_CC                   : gcc -std=gnu99
COB_CFLAGS               : -pipe -I/usr/local/include -Wno-unused
                           -fsigned-char -Wno-pointer-sign
COB_DEBUG_FLAGS          : -ggdb3 -fasynchronous-unwind-tables
COB_LDFLAGS              :
COB_LIBS                 : -L/usr/local/lib -lcob -lm
COB_CONFIG_DIR           : /usr/local/share/gnucobol/config
COB_COPY_DIR             : /usr/local/share/gnucobol/copy
COB_MSG_FORMAT           : GCC
COB_OBJECT_EXT           : o
COB_MODULE_EXT           : so
COB_EXE_EXT              :
64bit-mode               : yes
BINARY-C-LONG            : 8 bytes
endianness               : big-endian
native EBCDIC            : no
extended screen I/O      : ncursesw
variable file format     : 0
sequential file handler  : built-in
indexed file handler     : BDB

$ cobcrun -v -info | grep -A10 indexed
indexed file handler     : BDB, version 5.3.21
mathematical library     : GMP, version 6.0.0
XML library              : libxml2, version 2.9.1
JSON library             : cJSON, version 1.7.14
extended screen I/O      : ncursesw, version 5.9.20130511 (CHTYPE=64, WIDE=1)
                           xterm with 256 colors
mouse support            : yes

RHEL 8.2:

$ sudo yum install make gcc gmp-devel libxml2-devel ncurses-devel json-c-devel libdb-devel  # json-c at 0.13 -> new enough; but make comes extra

$ curl https://ftp.gnu.org/gnu/gnucobol/gnucobol-3.1.1.tar.xz -o gnucobol-3.1.1.tar.xz && tar -xvf gnucobol-3.1.1.tar.xz && cd gnucobol-3.1.1 && ./configure

$ make -j3 # we have 2 cores with 5200MHz, give them something to do

$ make -j2 checkall TESTSUITEFLAGS="--jobs=3" # results: all as expected

$ sudo make install

$ cobc --info | grep build -A30
build information
build environment        : s390x-ibm-linux-gnu
CC                       : gcc
C version                : "8.3.1 20191121 (Red Hat 8.3.1-5)"
CPPFLAGS                 :
CFLAGS                   : -O2 -pipe -finline-functions -fsigned-char
                           -Wall -Wwrite-strings -Wmissing-prototypes
                           -Wno-format-y2k
LD                       : /usr/bin/ld
LDFLAGS                  :  -Wl,-z,relro,-z,now,-O1

GnuCOBOL information
COB_CC                   : gcc
COB_CFLAGS               : -pipe -I/usr/local/include -Wno-unused
                           -fsigned-char -Wno-pointer-sign
COB_DEBUG_FLAGS          : -ggdb3 -fasynchronous-unwind-tables
COB_LDFLAGS              :
COB_LIBS                 : -L/usr/local/lib -lcob -lm
COB_CONFIG_DIR           : /usr/local/share/gnucobol/config
COB_COPY_DIR             : /usr/local/share/gnucobol/copy
COB_MSG_FORMAT           : GCC
COB_OBJECT_EXT           : o
COB_MODULE_EXT           : so
COB_EXE_EXT              :
64bit-mode               : yes
BINARY-C-LONG            : 8 bytes
endianness               : big-endian
native EBCDIC            : no
extended screen I/O      : ncursesw
variable file format     : 0
sequential file handler  : built-in
indexed file handler     : BDB

$ cobcrun -v -info | grep -A10 indexed
indexed file handler     : BDB, version 5.3.28
mathematical library     : GMP, version 6.1.2
XML library              : libxml2, version 2.9.7
JSON library             : json-c, version 0.13.1
extended screen I/O      : ncursesw, version 6.1.20180224 (CHTYPE=32, WIDE=1)
                           xterm with 256 colors
mouse support            : yes

So... all checks passed in these environments and a sample way to build them is presented, too.

Bonus note - installing using EPEL-Release (using a fresh RHEL8 VM here):

$ sudo dnf install https://dl.fedoraproject.org/pub/epel/epel-release-latest-8.noarch.rpm
$ sudo yum update
$ sudo yum install gnucobol
Dependencies resolved.
========================================================================================================================
 Package                        Architecture       Version                            Repository                   Size
========================================================================================================================
Installing:
 gnucobol                       s390x              3.1-5.rc1.el8                      epel                        669 k
Installing dependencies:
 binutils                       s390x              2.30-79.el8                        rhel8-base                  5.9 M
 cpp                            s390x              8.3.1-5.1.el8                      rhel8-appstream             8.0 M
 gcc                            s390x              8.3.1-5.1.el8                      rhel8-appstream              18 M
 glibc-devel                    s390x              2.28-127.el8                       rhel8-base                  1.0 M
 glibc-headers                  s390x              2.28-127.el8                       rhel8-base                  467 k
 gmp-c++                        s390x              1:6.1.2-10.el8                     rhel8-base                   32 k
 gmp-devel                      s390x              1:6.1.2-10.el8                     rhel8-base                  189 k
 isl                            s390x              0.16.1-6.el8                       rhel8-appstream             801 k
 kernel-headers                 s390x              4.18.0-240.8.1.el8_3               rhel8-base                  5.5 M
 libasan                        s390x              8.3.1-5.1.el8                      rhel8-base                  371 k
 libatomic                      s390x              8.3.1-5.1.el8                      rhel8-base                   21 k
 libcob                         s390x              3.1-5.rc1.el8                      epel                        178 k
 libgomp                        s390x              8.3.1-5.1.el8                      rhel8-base                  198 k
 libmpc                         s390x              1.0.2-9.el8                        rhel8-appstream              56 k
 libpkgconf                     s390x              1.4.2-1.el8                        rhel8-base                   34 k
 libubsan                       s390x              8.3.1-5.1.el8                      rhel8-base                  144 k
 libxcrypt-devel                s390x              4.1.1-4.el8                        rhel8-base                   25 k
 pkgconf                        s390x              1.4.2-1.el8                        rhel8-base                   38 k
 pkgconf-m4                     noarch             1.4.2-1.el8                        rhel8-base                   17 k
 pkgconf-pkg-config             s390x              1.4.2-1.el8                        rhel8-base                   15 k

Transaction Summary
========================================================================================================================
Install  21 Packages

Total download size: 42 M
Installed size: 108 M

Installed:
  binutils-2.30-79.el8.s390x                  cpp-8.3.1-5.1.el8.s390x            gcc-8.3.1-5.1.el8.s390x
  glibc-devel-2.28-127.el8.s390x              glibc-headers-2.28-127.el8.s390x   gmp-c++-1:6.1.2-10.el8.s390x
  gmp-devel-1:6.1.2-10.el8.s390x              gnucobol-3.1-5.rc1.el8.s390x       isl-0.16.1-6.el8.s390x
  kernel-headers-4.18.0-240.8.1.el8_3.s390x   libasan-8.3.1-5.1.el8.s390x        libatomic-8.3.1-5.1.el8.s390x
  libcob-3.1-5.rc1.el8.s390x                  libgomp-8.3.1-5.1.el8.s390x        libmpc-1.0.2-9.el8.s390x
  libpkgconf-1.4.2-1.el8.s390x                libubsan-8.3.1-5.1.el8.s390x       libxcrypt-devel-4.1.1-4.el8.s390x
  pkgconf-1.4.2-1.el8.s390x                   pkgconf-m4-1.4.2-1.el8.noarch      pkgconf-pkg-config-1.4.2-1.el8.s390x

Complete!

$ cobc --version
cobc (GnuCOBOL) 3.1-rc1.0
Copyright (C) 2020 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <https://gnu.org/licenses/gpl.html>
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
Written by Keisuke Nishida, Roger While, Ron Norman, Simon Sobisch, Edward Hart
Built     Jul 03 2020 21:02:30
Packaged  Jul 01 2020 00:39:30 UTC
C version "8.3.1 20191121 (Red Hat 8.3.1-5)"

$ cobc --info | grep build -A30
build information
build environment        : s390x-ibm-linux-gnu
CC                       : gcc
C version                : "8.3.1 20191121 (Red Hat 8.3.1-5)"
CPPFLAGS                 :
CFLAGS                   : -O2 -g -pipe -Wall -Werror=format-security
                           -Wp,-D_FORTIFY_SOURCE=2
                           -Wp,-D_GLIBCXX_ASSERTIONS -fexceptions
                           -fstack-protector-strong
                           -grecord-gcc-switches
                           -specs=/usr/lib/rpm/redhat/redhat-hardened-cc1
                           -specs=/usr/lib/rpm/redhat/redhat-annobin-cc1
                           -m64 -march=z13 -mtune=z14
                           -fasynchronous-unwind-tables
                           -fstack-clash-protection -pipe
                           -finline-functions -fsigned-char -Wall
                           -Wwrite-strings -Wmissing-prototypes
                           -Wno-format-y2k -U_FORTIFY_SOURCE
LD                       : /usr/bin/ld -m elf64_s390
LDFLAGS                  : -Wl,-z,relro -Wl,-z,now
                           -specs=/usr/lib/rpm/redhat/redhat-hardened-ld
                           -Wl,-z,relro,-z,now,-O1

GnuCOBOL information
COB_CC                   : gcc
COB_CFLAGS               : -I/usr/include -Wno-unused -fsigned-char
                           -Wno-pointer-sign -pipe -Wall
                           -Werror=format-security
                           -Wp,-D_GLIBCXX_ASSERTIONS -fexceptions
                           -grecord-gcc-switches
                           -specs=/usr/lib/rpm/redhat/redhat-hardened-cc1
                           -specs=/usr/lib/rpm/redhat/redhat-annobin-cc1

$ cobcrun -v -info | grep -A30 "GnuCOBOL information"
GnuCOBOL information
COB_MODULE_EXT           : so
dynamic loading          : system
"CBL_" param check       : disabled
64bit-mode               : yes
BINARY-C-LONG            : 8 bytes
endianness               : big-endian
native EBCDIC            : no
extended screen I/O      : ncursesw, version 6.1.20180224 (CHTYPE=32, WIDE=1)
                           xterm with 256 colors
mouse support            : yes
variable file format     : 0
sequential file handler  : built-in
ISAM file handler        : BDB, version 5.3.28
mathematical library     : GMP, version 6.1.2
XML library              : libxml2, version 2.9.7
JSON library             : disabled

echo "DISPLAY 'Hello by EPEL''d GnuCOBOL'." | cobc -vxj -free -frelax-syntax -
cobc (GnuCOBOL) 3.1-rc1.0
Built     Jul 03 2020 21:02:30  Packaged  Jul 01 2020 00:39:30 UTC
C version "8.3.1 20191121 (Red Hat 8.3.1-5)"
loading standard configuration file 'default.conf'
command line:   cobc -vxj -free -frelax-syntax -
preprocessing:  - -> /tmp/cob21215_0.cob
return status:  0
parsing:        /tmp/cob21215_0.cob (a.cob)
-:1: warning: PROGRAM-ID header missing - assumed
-:1: warning: PROCEDURE DIVISION header missing - assumed
return status:  0
translating:    /tmp/cob21215_0.cob -> /tmp/cob21215_0.c (a.cob)
executing:      gcc -c -I/usr/include -Wno-unused -fsigned-char
                -Wno-pointer-sign -pipe -Wall -Werror=format-security
                -Wp,-D_GLIBCXX_ASSERTIONS -fexceptions -grecord-gcc-switches
                -specs=/usr/lib/rpm/redhat/redhat-hardened-cc1
                -specs=/usr/lib/rpm/redhat/redhat-annobin-cc1 -m64 -march=z13
                -mtune=z14 -fstack-clash-protection -pipe -o
                "/tmp/cob21215_0.o" "/tmp/cob21215_0.c"
gcc: error: /usr/lib/rpm/redhat/redhat-hardened-cc1: No such file or directory

Note: I think that RHEL7 would have the same procedure but the first command replaced by:

$ curl  https://dl.fedoraproject.org/pub/epel/epel-release-latest-7.noarch.rpm -o epel-release-latest-7.noarch.rpm
 $ sudo yum install epel-release-latest-7.noarch.rpm