GNAT Zero Cost Exceptions and Asynchronous Task Aborting. Part 3.

February 18th, 2019

With kind help of asciilifeform I managed to bootstrap ave1gnat on cuntoo. First, before even running the compilation script, I checked how to make build-ada.sh use this compiler, and created the hardlinks just in case:

$ cd x86_64-linux-musl/bin/
$ find . -type f -name x86\* | awk -F- '{print "ln ", $0, $4}'

and executed the produced command trace.

In the process of bootstrapping, I have hit an issue that the distribution produced has absolute paths embedded into it, thus causing problem when it is moved to a different location. But it is easy to fix:

#!/bin/bash
set -e

SELF="$0"
usage() {
    printf "$SELF OLDTREE NEWTREE -- change hardcoded paths in ave1's GNAT from OLDTREE to its current location NEWTREE"
    exit 0
}

OLDTREE="$1"
NEWTREE="$2"
NEWTREE="$(realpath $NEWTREE)"
[ -z "$OLDTREE" ] && usage
[ -z "$NEWTREE" ] && usage
[ ! -d "$NEWTREE" ] && usage

find "$NEWTREE" -name '*.la' -exec sed -i -e "s#$OLDTREE#$NEWTREE#g" '{}' \;
find "$NEWTREE" -name '*.py' -exec sed -i -e "s#$OLDTREE#$NEWTREE#g" '{}' \;
for i in "$NEWTREE"/x86_64-linux-musl/lib/ldscripts/*; do
    sed -i -e "s#$OLDTREE#$NEWTREE#g" "$i"
done
sed -i -e "s#$OLDTREE#$NEWTREE#g" "$NEWTREE"/lib/gcc/x86_64-linux-musl/4.9.4/install-tools/mkheaders.conf
sed -i -e "s#$OLDTREE#$NEWTREE#g" "$NEWTREE"/libexec/gcc/x86_64-linux-musl/4.9.4/install-tools/mkheaders

What it basically does is rewrites paths in the linker scripts, libtool files, and service script that rewrites some system headers1. After this, the distribution is ready to use. I does not replace the paths in the binaries, AFAIK it is not necessary, not to mention that this would be a bit harder to do. After this change, the ./build-ada.sh worked out nicely, producing the expected compilers.

With the compilers in place, I ran my test application, and discovered that it works fine. Checked with GDB, indeed all the locks are in place. The lesson for me is that it's really not worth spending any time with gcc5+, and thinking that nothing bad could happen can result in huge time waste.

  1. This is what GCC docs say. I did only cursory examination of the script. []

One Response to “GNAT Zero Cost Exceptions and Asynchronous Task Aborting. Part 3.”

  1. [...] GNAT; SJLJ and ZCX versions using previously compiled 2018-05-15 on same machine (i.e. without running into the paths issue). For a summary of "why Ada", read Mocky's Log Reference on it. ↩Or so I hope - that in [...]

Leave a Reply