README.md: update recipe to use Automake git master
README.md: fix typo
README.md: add autoreconf step in Building godcc
godcc is written in Algol 68. The GNU Algol 68 compiler is still under development and is not yet integrated in GCC proper. Therefore to build godcc you will need to build an Algol 68 toolchain. But don't worry, it is very easy.
First build and install ga68, the GNU Algol 68 compiler:
$ git clone https://forge.sourceware.org/jemarch/a68-gcc
$ cd a68-gcc
$ git fetch origin a68:a68 && git checkout a68
$ ./contrib/download_prerequisites
$ mkdir build && cd build/
$ ../configure --prefix=$HOME/root-algol68 --enable-languages=algol68
$ make && make pdf && make html
$ make install
Next is Automake, which already has supports Algol 68 in its development (git) version:
$ git clone git://git.savannah.gnu.org/automake.git
$ cd automake
$ mkdir build && cd build/
$ ../configure --prefix=$HOME/root-algol68
$ make && make install
And finally Autoconf with Algol 68 support:
$ git clone https://git.sr.ht/~jemarch/a68-autoconf
$ cd a68-autoconf
$ git fetch origin a68:a68 && git checkout a68
$ mkdir build && cd build/
$ ../configure --prefix=$HOME/root-algol68
$ make && make install
At this point you should have working tools in whatever prefix you
specified in --prefix
.
Once you have the Algol 68 toolchain built in some reachable place, you can build godcc simply like:
$ cd godcc/
$ autoreconf
$ mkdir build && cd build/
$ ../configure && make && make install
It is possible to set A68FLAGS to specify extra compilation flags.
You configure godcc by setting a couple of environment variables:
GODCC_CEHOST
is the host where the instance of Compiler Explorer can
be reached. It is a hostname.
GODCC_CEPORT
is the port to connect to.
For example:
$ export GODCC_CEHOST=mycompilerexplorer.com GODCC_PORT=80
See below about how to deal with https. You will need that to get godcc to talk to godbolt.org.
The list
subcommand provides information about languages, compilers
and formatters supported by the instance of Compiler Explorer.
List of languages:
$ godcc list languages
The list compilers
subcommand will print a list of all the compilers
supported by the instance of Compiler Explorer:
$ godcc list compilers
This may be a long list. If you are interested in compilers for a particular programming language, you can use:
$ godcc list compilers -l zig
List of code formatting styles supported by Compiler Explorer:
$ godcc list formats
The compile
subcommand compiles some given source code in Compiler
Explorer into assembly language. The synopsis is:
godcc compile [-c COMPILER] [-o OUTFILE] [SRCFILE]
An example is:
$ godcc compile foo.c -c cbpfgtrunk
# Compilation provided by Compiler Explorer at https://godbolt.org/
foo:
*(u32 *) (r10+-4) = r1
r0 = *(u32 *) if w0 s<= 0 goto .L2
w0 += 1
r0 s>>= 32
.L2:
exit
By default the source code is read from standard input and the compiled assembly code is printed on the standard output. This can be changed using command-line options.
For example, to compile foo.c to assembly and put the result in foo.s:
$ godcc compile -c cbpfgtrunk foo.c -o foo.s
Options specified after --
are sent as-is to the remote compiler.
This is useful to change optimization levels, or library links, or
debug info options:
$ godcc compile -c cbpfgtrunk foo.c -- -O2 -Wall
Having to specify the compiler to use at every invocation can be
annoying. If godcc is invoked as godcc-COMPILER
, the COMPILER
part is interpreted as the default compiler to use. So for example,
if you often use godcc to compile C to BPF using GCC, you may want to
create a symlink:
$ ln -s /usr/bin/godcc /usr/bin/godcc-cbpfgtrunk
$ godcc-cbpfgtrunk compile foo.c
The format
subcommand provides access to format souce code using
Compiler Explorer. The synopsis is:
godcc format [-f FORMATTER] [-s STYLE] [SRCFILE]
An example is:
$ godcc format foo.c -f clangformat -s Google foo.c
int foo(int i) {
if (i > 0) {
return i + 1;
} else {
return 0;
}
}
By default the source code is read from standard input and the formatted code is printed on the standard output. This can be changed using command-line options.
For example, to format foo.c to use Google style and put the result in a file foo-google.c:
$ godcc format -f clangformat -s Google foo.c -o foo-google.c
Due to the generalized nonsense of today's Internet, which prescribes "security" for absolute everything effectively achieving insecurity for everyone, it is almost certain the Compiler Explorer instance you want to access, such as godbolt.org, will require being accessed via https.
In that case you will have to establish a tunnel that translates the plain http that godcc talks into the https gibberish. A way to do that is using the stunnel program. This is the recipe:
First create a godbolt.stunnel configuration file containing this:
sslVersion = all
foreground = yes
[remote]
client = yes
accept = 8888
connect = godbolt.org:443
Then run stunnel:
# sudo stunnel godbolt.stunnel
Finally configure godcc to connect to localhost:8888:
$ export GODCC_CEHOST=localhost GODCC_CEPORT=8888
Happy godccing!