AdaCore / gprbuild

GPRbuild is an advanced build system designed to help automate the construction of multi-language systems.
Other
65 stars 21 forks source link

Cannot configure gprconfig/gprbuild with source-built GCC in custom directory: `gprconfig: can't find a native toolchain for language` #122

Closed GavinRay97 closed 1 year ago

GavinRay97 commented 1 year ago

I've built GCC 13 from source, with Ada/Gnat support, and I'd like to set it up with the VS Code extension. Unfortunately, I can't seem to figure out how to configure this properly =/

$ ls /usr/local/gcc-dev/bin
c++-dev     gcc-nm-dev      gcov-tool-dev  gnatclean-dev  gnatls-dev    lto-dump-dev                    x86_64-pc-linux-gnu-gcc-dev
cpp-dev     gcc-ranlib-dev  g++-dev        gnat-dev       gnatmake-dev  x86_64-pc-linux-gnu-c++-dev     x86_64-pc-linux-gnu-gcc-nm-dev
gcc-ar-dev  gcov-dev        gnatbind-dev   gnatkr-dev     gnatname-dev  x86_64-pc-linux-gnu-gcc-13.0.0  x86_64-pc-linux-gnu-gcc-ranlib-dev
gcc-dev     gcov-dump-dev   gnatchop-dev   gnatlink-dev   gnatprep-dev  x86_64-pc-linux-gnu-gcc-ar-dev  x86_64-pc-linux-gnu-g++-dev
# generate-gprconfig.sh
GCC_BINDIR=/usr/local/gcc-dev/bin

# --config=language[,version[,runtime[,path[,name]]]]
gprconfig --batch \
    --target=x86_64-pc-linux-gnu \
    --config=Ada,,,$GCC_BINDIR,gnat-dev \
    --config=C,,,$GCC_BINDIR,gcc-dev \
    --config=C++,,,$GCC_BINDIR,g++-dev \
$ ./generate-gprconfig.sh 
gprconfig: can't find a native toolchain for language 'Ada'
gprconfig: can't find a native toolchain for language 'C'
gprconfig: can't find a native toolchain for language 'C++'
t-14 commented 1 year ago

The tool expects to find the executable "gcc" or "gcc-", not "gcc-dev". Adding a symlink will probably help.

GavinRay97 commented 1 year ago

Ah, thanks for clarifying. It may be fruitful to clarify this section in the docs, or the error message returned IMO. I understood it to mean other names than gcc, like dcc or gcc-dev could be used:

image

GavinRay97 commented 1 year ago

Here's the script in case anyone else winds up finding this on the internet in the future:

#!/bin/env bash

# Set up GCC 13 dev binaries for at /usr/local/gcc-dev/bin
# for use with Ada Core's gprbuild
# (and gprconfig, which is used by gprbuild)
GCC_BINDIR=/usr/local/gcc-dev/bin

# We need to create symlinks from "-dev" to unprefixed binaries, because gprconfig expects this (or "<name>-<ver>")
# See: https://github.com/AdaCore/gprbuild/issues/122

# find every binary beginning with "gnat*", and ending with "-dev", and symlink it to the same name without "-dev"
for f in $(find $GCC_BINDIR -maxdepth 1 -type f -name "gnat*" -name "*-dev"); do
    ln -s $f ${f%-dev}
done

ln -s $GCC_BINDIR/gcc-dev $GCC_BINDIR/gcc
ln -s $GCC_BINDIR/g++-dev $GCC_BINDIR/g++ 

# --config=language[,version[,runtime[,path[,name]]]]
gprconfig --batch \
    --target=x86_64-pc-linux-gnu \
    --config=Ada,,,$GCC_BINDIR \
    --config=C,,,$GCC_BINDIR,gcc \
    --config=C++,,,$GCC_BINDIR,g++
t-14 commented 1 year ago

I understood it to mean other names than gcc, like dcc or gcc-dev could be used:

Yes, but the executable thus specified must match one of regexes in the knowledge base. In other words "--config" is a filter, not an extension mechanism. "dcc" does match one of the stanzas, whereas "gcc-dev" doesn't match anything (but of course it can be taught to - currently the regexp is "...gcc(-\d+)", one could extend it to also match gcc-dev...)

GavinRay97 commented 1 year ago

Ohh, that makes sense, thank you