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

Does not build -- cannot find knowledge base when bootstraped with `prefix=$HOME/.local/` #104

Closed byu9 closed 2 years ago

byu9 commented 2 years ago

Hi,

At least since v22.0.0, the bootstrap gprconfig installed into my prefix directory by the bootstrap program is having trouble locating its knowledge base. The bootstrap process successfully completed with --prefix=$HOME/.local. However, when running make all, the following error appears

$ which gprbuild
/home/jdoe/.local/bin/gprbuild

$ make
gprbuild -p -m   -j0 -XBUILD=production  gprbuild.gpr -XLIBRARY_TYPE=static -XXMLADA_BUILD=static
No valid configuration found
Generation of configuration files failed
GNAT-TEMP-000002.TMP:1:01: "project" expected
gprbuild: processing of configuration project "/tmp/GNAT-TEMP-000002.TMP" failed
make: *** [Makefile:95: build] Error 4

Attempts to run gprconfig fails with the following message

$ which gprconfig
/home/jdoe/.local/bin/gprconfig

$ gprconfig
No compilers found for target x86_64-pc-linux-gnu

Explicitly specifying knowledge base location to the bootstrap gprconfig appears to resolve issue

$ which gprconfig
/home/jdoe/.local/bin/gprconfig

$ gprconfig --db $HOME/.local/share/gprconfig
--------------------------------------------------
gprconfig has found the following compilers on your PATH.
Only those matching the target and the selected compilers are displayed.
   1. GNAT for Ada in /home/jdoe/.local/stow/gcc-11.2.0/bin/ version 11.2 (default runtime)
   2. GCC-ASM for Asm in /home/jdoe/.local/stow/gcc-11.2.0/bin/ version 11.2.0
   3. GCC-ASM for Asm in /usr/bin/ version 10.2.1
   4. GCC-ASM for Asm2 in /home/jdoe/.local/stow/gcc-11.2.0/bin/ version 11.2.0
   5. GCC-ASM for Asm2 in /usr/bin/ version 10.2.1
   6. GCC-ASM for Asm_Cpp in /home/jdoe/.local/stow/gcc-11.2.0/bin/ version 11.2.0
   7. GCC-ASM for Asm_Cpp in /usr/bin/ version 10.2.1
   8. LD for Bin_Img in /usr/bin/ version 2.35.2
   9. GCC for C in /home/jdoe/.local/stow/gcc-11.2.0/bin/ version 11.2.0
  10. GCC for C in /usr/bin/ version 10.2.1
  11. G++ for C++ in /home/jdoe/.local/stow/gcc-11.2.0/bin/ version 11.2.0
  12. G++ for C++ in /usr/bin/ version 10.2.1
Select or unselect the following compiler (or "s" to save):
byu9 commented 2 years ago

UPDATE -- the problem appears to be caused by the symlinks of GNU Stow. Issue does not appear if gnat is directly installed into $HOME/.local instead of into $HOME/.local/stow then stowed into $HOME/.local.

t-14 commented 2 years ago

We have no experience with stow. What file system structure do you get at destination location compared to pure install when using it?

byu9 commented 2 years ago

Hi,

I think I'm sure at this point the problem is caused by the symlinks created by GNU Stow interfering with the build system and not by a bug in gprbuild

I attempted to use GNU Stow to support different compiler versions since I can unstow a compiler and restow a different version into my $PATH. My directory structure using GNU Stow is

Stow then computed the minimum number of symlinks that needed to be created in $HOME/.local to make it appear that the packages are installed directly into the parent $HOME/.local. However, when running the bootstrapped gprconfig, the program attempted to use the dereferenced compiler path ($HOME/.local/stow/gcc-11.2.0-native/share) to find the knowledge base. However, the knowledge base has been silently installed into the parent $HOME/.local/share/gprconfig by bootstrap. This is why the knowledge base was not found.

cd $HOME/.local/stow
stow xmlada-22.0-native gcc-11.2.0-native

For anyone encountering similar issues, the workaround is to call ./bootstrap --build to only build the packages, and then call DESTDIR=/tmp/gprbuild bootstrap --install to install the programs into a different location.

An improvement to the bootstrap program would be to make the --install option off by default to avoid silently installing files into locations outside the build directory.