COBOL for GCC Development
COBOLworx is developing a COBOL front end for the GCC Gnu Compiler Collection. GCOBOL is very much still under development, but it has reached a point where interested users can experiment with it.
We are also working on a version of GDB – the GNU Debugger – that has the capability of working with GCOBOL. This page will have more information as it becomes available.
Installation packages for the GCOBOL compiler
We have Debian installation packages for the GCOBOL compiler that are known to install properly on Debian-11 distributions and on Ubuntu-22.04.
These .deb files are found at our private registry. The list is updated with each commit, with the most recent at the top of the list.
Install the downloaded file with
sudo apt install ./gcobol-13_13.0.16-dev-xxxxxxxxx_x86_64.deb.
That installs the executable as
/usr/bin/gcobol and moves
the necessary libraries into place.
Note: At the end of the installation process you will probably see a warning message of the form
N: Download is performed unsandboxed as root as file '/home/bob/gcobol-13_13.0.16-dev-44fa482b9_x86_64.deb' couldn't be accessed by user '_apt'. - pkgAcquire::Run (13: Permission denied)
This is a warning, and does not affect the installation. If you prefer to avoid the warning message, move the downloaded file to /tmp and install it from there.
Using COBOL for GCC
Because it is part of the GCC family, GCOBOL works very much like the
Compile a COBOL program like this:
gcobol -o hello hello.cbl
and then run the resulting executable with
The source code for the compiler is available at https://gitlab.cobolworx.com/COBOLworx/gcc-cobol.git That repository is public; you should be able to clone it.
Those who prefer to work from tarballs can find them at https://gitlab.cobolworx.com/COBOLworx/gcc-cobol/-/releases.
They are generated automatically with each commit of the
master+cobol branch of the repository.
As mentioned, this project is very much under development. We are
trying to make sure that the
master+cobol branch of the
repository compiles and runs, but as it is the active development
branch, there can be no guarantees.
You should keep in mind that the GCOBOL compiler is part of the GCC compiler. Compiling GCC, which is one of the more complex programs any of us have ever had to work with, is an involved process.
Your best bet for compiling the GCOBOL compiler is to use one of the scripts that we have arrived at. They are found at
The first script is probably what most users want.
The second script builds a debug version of GCC using the -ggdb and -O0 optimization switches. That set of GCC executables provides for using a debugger like GDB to trap through a compilation.
Both scripts attempt to install any prerequisites necessary for compiling the GCC and GCOBOL compilers and using executables generated by them.
One caveat: You will need
bison, but it has to be
version 3.8 or later. On Ubuntu 22.04 LTS,
sudo apt install bison installs BISON-3.8
But on Debian-11, the same command installs BISON-3.7.5, which doesn’t do the job.
On a Debian-11 system, this worked to install a useful version of
cd~ mkdir -p builds cd builds wget https://ftp.gnu.org/gnu/bison/bison-3.8.2.tar.xz tar -xvf bison-3.8.2.tar.xz cd bison-3.8.2 mkdir build cd build ../configure --prefix=/usr/local make sudo make install
What are we developing?
The GCC architecture consists of a “front end” for each language; there is a front end for C, another for FORTRAN, yet another for ADA, and so on. Each front end parses the source code and passes the decoded intent of the programmer to a “code generator” that converts each instruction to an intermediate form known as GIMPLE. The intermediate form is fed into the GCC optimizer and from there to the assembly language generator.
We are developing a COBOL front end for GCC. It takes COBOL source
code as input, parses it and generates the GIMPLE tree. The COBOL front
end is incorporated into GCC and becomes an executable named
gcobol, which is used to compile COBOL source code files.
gcobol is part of GCC, the output can be .o object
files, .so shared objects, or executable binaries.
The primary development team:
Marty Heyman is the team leader. He is the subject matter expert for COBOL and its uses, and is the orchestrator of our business plans.
James K. Lowden is responsible for the non-trivial effort of parsing COBOL source code. COBOL was originally created around 1958, and computer science has learned a lot about compilation in general, and context-free grammars in specific, since then. Coping with a language intentionally designed to be “…like English…” from that era is an “interesting” project.
Robert Dubner is responsible for code generation. Code generation is also an “interesting” project, mainly because so few people have occasion to generate GIMPLE that there is little documentation, and less guidance, for how to do it. Mr. Dubner suspects he is the latest in a line of front end developers forced to reverse engineer what came before in order to do it at all.