8
votes

I can't seem to get GNATCOLL to compile in an Alpine Linux based Docker Container.

My container so far is:

FROM alpine:edge

# Add extra repositories
RUN echo 'http://dl-cdn.alpinelinux.org/alpine/edge/testing' >> /etc/apk/repositories; \
    echo 'http://dl-cdn.alpinelinux.org/alpine/edge/community' >> /etc/apk/repositories; \
    echo 'http://dl-cdn.alpinelinux.org/alpine/edge/main' >> /etc/apk/repositories;

RUN apk add --no-cache build-base coreutils curl-dev gcc-gnat git gmp-dev openssl

# Bootstrap GPRBuild
RUN git clone https://github.com/AdaCore/xmlada.git; \
    git clone https://github.com/AdaCore/gprbuild.git; \
    cd gprbuild; ./bootstrap.sh --with-xmlada=../xmlada; \
    cd ..; \
    rm -rf xmlada gprbuild

This works fine and gets me a container with a working GNAT GPR based Ada development environment. The issue comes when I try to install GNATCOLL in this container.

Running docker run -i -t <built_image> the following occurs:

/ # git clone https://github.com/AdaCore/gnatcoll-core.git
<Typical git clone output>
/ # cd gnatcoll-core/
/gnatcoll-core # make setup
/gnatcoll-core # make
gprbuild -p -m --target=x86_64-linux  -j0 -XGNATCOLL_MMAP=yes -XGNATCOLL_MADVISE=yes -XGNATCOLL_VERSION=0.0 -XGNATCOLL_OS=unix -XBUILD=PROD  -XLIBRARY_TYPE=static -XXMLADA_BUILD=static -XGPR_BUILD=static \
        -XGNATCOLL_MMAP=yes -XGNATCOLL_MADVISE=yes -XGNATCOLL_VERSION=0.0 -XGNATCOLL_OS=unix -XBUILD=PROD gnatcoll.gpr
Setup
   [mkdir]        object directory for project GnatColl
   [mkdir]        library directory for project GnatColl
gnatcoll.gpr:24:06: unknown project file: "gpr"
make: *** [Makefile:128: build-static] Error 4

Based on the discussion in https://github.com/AdaCore/gnatcoll-core/issues/30 I checked my gprbuild version:

/gnatcoll-core # gprbuild --version
GPRBUILD Pro 18.0w (19940713) (x86_64-alpine-linux-musl)
Copyright (C) 2004-2016, AdaCore
This is free software; see the source for copying conditions.
See your AdaCore support agreement for details of warranty and support.
If you do not have a current support agreement, then there is absolutely
no warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR
PURPOSE.

So it would seem that gprbuild for musl is woefully out of date, leading to an inability to build GNATCOLL. Is there any way to get a more up-to-date version of gprbuild for musl-c? If not is there any other way to get GNATCOLL installed?

1
I would not expect that version to be correct given the fact that you clone it directly from the GitHub repository. A hint of why the version is stated as it is can be found in the comments of file gpr-version.ads, just before the beginning of the package spec.DeeDee
It seems as though you are right, though it doesn't explain why I can't build gnatcoll.LambdaBeta
It seems more likely that GPRbuild cannot find the project gpr.gpr when building GNATCOLL. This project file is located in the gpr directory of the GPRbuild repository (see here). You might want to add the location of the gpr.gpr project to the the environment variable GPR_PROJECT_PATH (and use export to make it visible to child processes). See also Importing Projects in the GPR Tools manual.DeeDee
On second thought, you might also want to check if gpr.gpr was not already installed somewhere along with the GPRbuild executable. In that case you could also use that version.DeeDee
I checked that and indeed no gpr.gpr was installed. I tried using the one in the project but it re-uses some build variables. In particular gnatcoll uses -XBUILD=PROD but gprbuild's gpr.gpr source file uses -XBUILD=production so they aren't compatible. There must be some other way to get the desired gpr.gpr file, but running make install in the gprbuild project doesn't seem to do it.LambdaBeta

1 Answers

10
votes

The issue is that ./bootstrap.sh in gprbuild doesn't install everything, it just creates a bare minimum gprbuild installation. Additionally it does not build gprlib, which is necessary for gnatcoll and also has to be installed.

The required steps are:

# As before...
git clone https://github.com/AdaCore/xmlada.git
git clone https://github.com/AdaCore/gprbuild.git
cd gprbuild; ./bootstrap.sh --with-xmlada=../xmlada

# New: build and install xmlada
cd ../xmlada; ./configure && make && make install

# New: build and install gprbuild fully
cd ../gprbuild
export GPR_PROJECT_PATH=/usr/local/share/gpr
make prefix=/usr/local setup && make all && make install

# New: build and install gprlib
make libgpr.build && make libgpr.install

With these additions I was able to build gnatcoll as specified in its project.