diff mbox series

[1/2] libada: Remove racy duplicate gnatlib installation

Message ID alpine.LFD.2.21.1909251907520.28360@redsun52.ssa.fujisawa.hgst.com
State Superseded
Headers show
Series libada: Installation improvements | expand

Commit Message

Maciej W. Rozycki Sept. 25, 2019, 9:23 p.m. UTC
For some reason, presumably historical, the `install-gnatlib' target for 
the default multilib is invoked twice, once via the `ada.install-common' 
target in `gcc/ada/gcc-interface/Make-lang.in' invoked from gcc/ and 
again via the `install-libada' target in libada/.

Apart from doing the same twice this is actually harmful in sufficiently 
parallelized `make' invocation, as the removal of old files performed 
within the `install-gnatlib' recipe in the former case actually races 
with the installation of new files done in the latter case, causing the 
recipe to fail and abort, however non-fatally, having not completed the 
installation of all the built files needed for the newly-built compiler 
to work correctly.

This can be observed with a native `x86_64-linux-gnu' bootstrap:

make[4]: Entering directory '.../gcc/ada'
rm -rf .../lib/gcc/x86_64-linux-gnu/10.0.0/adalib
rm: cannot remove '.../lib/gcc/x86_64-linux-gnu/10.0.0/adalib': Directory not empty
make[4]: *** [gcc-interface/Makefile:512: install-gnatlib] Error 1
make[4]: Leaving directory '.../gcc/ada'
make[3]: *** [.../gcc/ada/gcc-interface/Make-lang.in:853: install-gnatlib] Error 2
make[2]: [.../gcc/ada/gcc-interface/Make-lang.in:829: ada.install-common] Error 2 (ignored)

which then causes missing files to be reported when an attempt is made 
to use the newly-installed non-functional compiler to build a 
`riscv-linux-gnu' cross-compiler:

(cd ada/bldtools/sinfo; gnatmake -q xsinfo ; ./xsinfo sinfo.h )
error: "ada.ali" not found, "ada.ads" must be compiled
error: "s-memory.ali" not found, "s-memory.adb" must be compiled
gnatmake: *** bind failed.
/bin/sh: ./xsinfo: No such file or directory
make[2]: *** [.../gcc/ada/Make-generated.in:45: ada/sinfo.h] Error 127
make[2]: Leaving directory '.../gcc'
make[1]: *** [Makefile:4369: all-gcc] Error 2
make[1]: Leaving directory '...'
make: *** [Makefile:965: all] Error 2

Depending on timing `.../lib/gcc/x86_64-linux-gnu/10.0.0/adainclude' may
cause an installation failure instead and the resulting compiler may be 
non-functional in a different way.

Remove the extraneous `install-gnatlib' invocation from within gcc/ then 
as all the gnatlib handling ought to be done in libada/ nowadays.

	gcc/ada/
	* gcc-interface/Make-lang.in (ada.install-common): Remove 
	`install-gnatlib' invocation.
---
 gcc/ada/gcc-interface/Make-lang.in |    8 --------
 1 file changed, 8 deletions(-)

gcc-lang-no-install-gnatlib.diff

Comments

Arnaud Charlet Sept. 26, 2019, 7:42 a.m. UTC | #1
Unfortunately the Make-lang.in part is still needed when using the
--disable-libada configure switch so a more elaborate change is needed.

> Remove the extraneous `install-gnatlib' invocation from within gcc/ then 
> as all the gnatlib handling ought to be done in libada/ nowadays.
> 
> 	gcc/ada/
> 	* gcc-interface/Make-lang.in (ada.install-common): Remove 
> 	`install-gnatlib' invocation.
Maciej W. Rozycki Sept. 27, 2019, 12:37 a.m. UTC | #2
On Thu, 26 Sep 2019, Arnaud Charlet wrote:

> Unfortunately the Make-lang.in part is still needed when using the
> --disable-libada configure switch so a more elaborate change is needed.

 Hmm, I've experimented a bit and AFAICT if `--disable-libada' is given 
without my proposed change applied, then the gnatlib stuff doesn't get 
built in the first place let alone installed anyway.

 Actually the `install-gnatlib' target invocation in `ada.install-common' 
I have proposed to get removed does go ahead in that case, and then fails, 
again non-fatally (thanks to the `-' recipe line prefix in action here 
too):

make[4]: Entering directory '.../gcc/ada'
You must first build the GNAT library: make gnatlib
make[4]: *** [gcc-interface/Makefile:497: ../stamp-gnatlib-rts] Error 1
make[4]: Leaving directory '.../gcc/ada'
make[3]: *** [.../gcc/ada/gcc-interface/Make-lang.in:852: install-gnatlib] Error 2
make[2]: [.../gcc/ada/gcc-interface/Make-lang.in:828: ada.install-common] Error 2 (ignored)

so all my change effectively does in that case is to remove these 
messages.

 I went as far as to compare the installed trees with `--disable-libada' 
specified and then without and with my patch applied respectively and they 
were exactly the same.

 NB no gnattools stuff is built either when `--disable-libada' is in 
effect, due to this clause in Makefile.def:

dependencies = { module=all-gnattools; on=all-target-libada; };

leaving the resulting installation with a bare Ada compiler driver and 
backend only, e.g. with my native `x86_64-linux-gnu' setup:

$(prefix)/bin/gnatbind
$(prefix)/libexec/gcc/x86_64-linux-gnu/10.0.0/gnat1

(which is then of course incapable of building a `riscv-linux-gnu' 
cross-compiler, so that's it as far as Ada support goes).

 Therefore I maintain my change is correct and safe to apply.

 OK to go ahead with it then?  Or have I missed anything and you meant 
something else (I find "still needed" a bit vague)?

  Maciej
Arnaud Charlet Sept. 27, 2019, 7:15 a.m. UTC | #3
> > Unfortunately the Make-lang.in part is still needed when using the
> > --disable-libada configure switch so a more elaborate change is needed.
> 
>  Hmm, I've experimented a bit and AFAICT if `--disable-libada' is given 
> without my proposed change applied, then the gnatlib stuff doesn't get 
> built in the first place let alone installed anyway.

With --disable-libada you need to build gnatlib and gnattools explicitly via
e.g.

make -C gcc gnatlib gnattools

(after having done a "make" or "make bootstrap")

and then you can use "make install"

Arno
diff mbox series

Patch

Index: gcc/gcc/ada/gcc-interface/Make-lang.in
===================================================================
--- gcc.orig/gcc/ada/gcc-interface/Make-lang.in
+++ gcc/gcc/ada/gcc-interface/Make-lang.in
@@ -840,14 +840,6 @@  doc/gnat-style.pdf: ada/gnat-style.texi
 	  $(INSTALL_PROGRAM) gnatdll$(exeext) $(DESTDIR)$(bindir)/gnatdll$(exeext); \
 	fi
 
-#
-# Finally, install the library
-#
-	-if [ -f gnat1$(exeext) ] ; \
-	then \
-	  $(MAKE) $(COMMON_FLAGS_TO_PASS) $(ADA_FLAGS_TO_PASS) install-gnatlib; \
-	fi
-
 install-gnatlib:
 	$(MAKE) -C ada $(COMMON_FLAGS_TO_PASS) $(ADA_FLAGS_TO_PASS) install-gnatlib$(LIBGNAT_TARGET)