modula2: Fix bootstrap

Message ID ZH+k9Qum+98u1vML@tucnak
State Unresolved
Headers
Series modula2: Fix bootstrap |

Checks

Context Check Description
snail/gcc-patch-check warning Git am fail log

Commit Message

Jakub Jelinek June 6, 2023, 9:28 p.m. UTC
  Hi!

internal-fn.h since yesterday includes insn-opinit.h, which is a generated
header.
One of my bootstraps today failed because some m2 sources started compiling
before insn-opinit.h has been generated.

Normally, gcc/Makefile.in has
# In order for parallel make to really start compiling the expensive
# objects from $(OBJS) as early as possible, build all their
# prerequisites strictly before all objects.
$(ALL_HOST_OBJS) : | $(generated_files)

rule which ensures that all the generated files are generated before
any $(ALL_HOST_OBJS) objects start, but use order-only dependency for
this because we don't want to rebuild most of the objects whenever one
generated header is regenerated.  After the initial build in an empty
directory we'll have .deps/ files contain the detailed dependencies.

$(ALL_HOST_OBJS) includes even some FE files, I think in the m2 case
would be m2_OBJS, but m2/Make-lang.in doesn't define those.

The following patch just adds a similar rule to m2/Make-lang.in.
Another option would be to set m2_OBJS variable in m2/Make-lang.in to
something, but not really sure to which exactly and why it isn't
done.

Bootstrapped/regtested on x86_64-linux and i686-linux, ok for trunk?

2023-06-06  Jakub Jelinek  <jakub@redhat.com>

	* Make-lang.in: Build $(generated_files) before building
	all $(GM2_C_OBJS).



	Jakub
  

Comments

Gaius Mulley June 6, 2023, 10:18 p.m. UTC | #1
Jakub Jelinek <jakub@redhat.com> writes:

> Hi!
>
> internal-fn.h since yesterday includes insn-opinit.h, which is a generated
> header.
> One of my bootstraps today failed because some m2 sources started compiling
> before insn-opinit.h has been generated.
>
> Normally, gcc/Makefile.in has
> # In order for parallel make to really start compiling the expensive
> # objects from $(OBJS) as early as possible, build all their
> # prerequisites strictly before all objects.
> $(ALL_HOST_OBJS) : | $(generated_files)
>
> rule which ensures that all the generated files are generated before
> any $(ALL_HOST_OBJS) objects start, but use order-only dependency for
> this because we don't want to rebuild most of the objects whenever one
> generated header is regenerated.  After the initial build in an empty
> directory we'll have .deps/ files contain the detailed dependencies.
>
> $(ALL_HOST_OBJS) includes even some FE files, I think in the m2 case
> would be m2_OBJS, but m2/Make-lang.in doesn't define those.
>
> The following patch just adds a similar rule to m2/Make-lang.in.
> Another option would be to set m2_OBJS variable in m2/Make-lang.in to
> something, but not really sure to which exactly and why it isn't
> done.
>
> Bootstrapped/regtested on x86_64-linux and i686-linux, ok for trunk?


> 2023-06-06  Jakub Jelinek  <jakub@redhat.com>
>
> 	* Make-lang.in: Build $(generated_files) before building
> 	all $(GM2_C_OBJS).
>
> --- gcc/m2/Make-lang.in.jj	2023-05-04 09:31:27.289948109 +0200
> +++ gcc/m2/Make-lang.in	2023-06-06 21:38:26.655336041 +0200
> @@ -511,6 +511,8 @@ GM2_LIBS_BOOT     = m2/gm2-compiler-boot
>                      m2/gm2-libs-boot/libgm2.a \
>                      $(GM2-BOOT-O)
>  
> +$(GM2_C_OBJS) : | $(generated_files)
> +
>  cc1gm2$(exeext): m2/stage1/cc1gm2$(exeext) $(m2.prev)
>  	cp -p $< $@
>  
>
>
> 	Jakub

Hi Jakub,

sure looks good to me - thanks for the patch,

regards,
Gaius
  
Andre Vieira (lists) June 7, 2023, 8:42 a.m. UTC | #2
Thanks Jakub!

I do need those includes and sorry I broke your bootstrap it didn't show 
up on my aarch64-unknown-linux-gnu bootstrap, I'm guessing the rules 
there were just run in a different order. Glad you were able to fix it :)

On 06/06/2023 22:28, Jakub Jelinek wrote:
> Hi!
> 
> internal-fn.h since yesterday includes insn-opinit.h, which is a generated
> header.
> One of my bootstraps today failed because some m2 sources started compiling
> before insn-opinit.h has been generated.
> 
> Normally, gcc/Makefile.in has
> # In order for parallel make to really start compiling the expensive
> # objects from $(OBJS) as early as possible, build all their
> # prerequisites strictly before all objects.
> $(ALL_HOST_OBJS) : | $(generated_files)
> 
> rule which ensures that all the generated files are generated before
> any $(ALL_HOST_OBJS) objects start, but use order-only dependency for
> this because we don't want to rebuild most of the objects whenever one
> generated header is regenerated.  After the initial build in an empty
> directory we'll have .deps/ files contain the detailed dependencies.
> 
> $(ALL_HOST_OBJS) includes even some FE files, I think in the m2 case
> would be m2_OBJS, but m2/Make-lang.in doesn't define those.
> 
> The following patch just adds a similar rule to m2/Make-lang.in.
> Another option would be to set m2_OBJS variable in m2/Make-lang.in to
> something, but not really sure to which exactly and why it isn't
> done.
> 
> Bootstrapped/regtested on x86_64-linux and i686-linux, ok for trunk?
> 
> 2023-06-06  Jakub Jelinek  <jakub@redhat.com>
> 
> 	* Make-lang.in: Build $(generated_files) before building
> 	all $(GM2_C_OBJS).
> 
> --- gcc/m2/Make-lang.in.jj	2023-05-04 09:31:27.289948109 +0200
> +++ gcc/m2/Make-lang.in	2023-06-06 21:38:26.655336041 +0200
> @@ -511,6 +511,8 @@ GM2_LIBS_BOOT     = m2/gm2-compiler-boot
>                       m2/gm2-libs-boot/libgm2.a \
>                       $(GM2-BOOT-O)
>   
> +$(GM2_C_OBJS) : | $(generated_files)
> +
>   cc1gm2$(exeext): m2/stage1/cc1gm2$(exeext) $(m2.prev)
>   	cp -p $< $@
>   
> 
> 
> 	Jakub
>
  
Jakub Jelinek June 13, 2023, 2:48 p.m. UTC | #3
On Wed, Jun 07, 2023 at 09:42:22AM +0100, Andre Vieira (lists) wrote:
> I do need those includes and sorry I broke your bootstrap it didn't show up
> on my aarch64-unknown-linux-gnu bootstrap, I'm guessing the rules there were
> just run in a different order. Glad you were able to fix it :)

Unfortunately, it doesn't really work.
My x86_64-linux bootstrap today died again with:
In file included from ../../gcc/m2/gm2-gcc/gcc-consolidation.h:74,
                 from ../../gcc/m2/gm2-lang.cc:24:
../../gcc/internal-fn.h:24:10: fatal error: insn-opinit.h: No such file or directory
   24 | #include "insn-opinit.h"
      |          ^~~~~~~~~~~~~~~
compilation terminated.
/home/jakub/src/gcc/obj36/./prev-gcc/xg++ -B/home/jakub/src/gcc/obj36/./prev-gcc/ -B/usr/local/x86_64-pc-linux-gnu/bin/ -nostdinc++ -B/home/jakub/src/gcc/obj36/prev-x86_64-pc-linux-gnu/libstdc++-v3/src/.libs -B/home/jakub/src/gcc/obj36/prev-x86_64-pc-linux-gnu/libstdc++-v3/libsupc++/.libs  -I/home/jakub/src/gcc/obj36/prev-x86_64-pc-linux-gnu/libstdc++-v3/include/x86_64-pc-linux-gnu  -I/home/jakub/src/gcc/obj36/prev-x86_64-pc-linux-gnu/libstdc++-v3/include  -I/home/jakub/src/gcc/libstdc++-v3/libsupc++ -L/home/jakub/src/gcc/obj36/prev-x86_64-pc-linux-gnu/libstdc++-v3/src/.libs -L/home/jakub/src/gcc/obj36/prev-x86_64-pc-linux-gnu/libstdc++-v3/libsupc++/.libs  -fno-PIE -c -g   -g -O2 -fchecking=1 -DIN_GCC     -fno-exceptions -fno-rtti -fasynchronous-unwind-tables -W -Wall -Wno-narrowing -Wwrite-strings -Wcast-qual  -fno-common  -DHAVE_CONFIG_H \
             -I. -Im2/gm2-gcc -I../../gcc -I../../gcc/m2/gm2-gcc -I../../gcc/../include  -I../../gcc/../libcpp/include -I../../gcc/../libcody  -I../../gcc/../libdecnumber -I../../gcc/../libdecnumber/bid -I../libdecnumber -I../../gcc/../libbacktrace   -I. -Im2/gm2-gcc -I../../gcc -I../../gcc/m2/gm2-gcc -I../../gcc/../include  -I../../gcc/../libcpp/include -I../../gcc/../libcody  -I../../gcc/../libdecnumber -I../../gcc/../libdecnumber/bid -I../libdecnumber -I../../gcc/../libbacktrace  ../../gcc/m2/gm2-gcc/m2type.cc -o m2/gm2-gcc/m2type.o
make[3]: *** [../../gcc/m2/Make-lang.in:570: m2/gm2-lang.o] Error 1
make[3]: *** Waiting for unfinished jobs....
errors.  Dunno what is going on.
I've tried
--- gcc/m2/Make-lang.in.jj	2023-06-07 15:56:07.112684198 +0200
+++ gcc/m2/Make-lang.in	2023-06-13 16:08:55.409364765 +0200
@@ -511,7 +511,7 @@ GM2_LIBS_BOOT     = m2/gm2-compiler-boot
                     m2/gm2-libs-boot/libgm2.a \
                     $(GM2-BOOT-O)
 
-$(GM2_C_OBJS) : | $(generated_files)
+m2_OBJS = $(GM2_C_OBJS)
 
 cc1gm2$(exeext): m2/stage1/cc1gm2$(exeext) $(m2.prev)
 	cp -p $< $@

but that doesn't really work either, this time not just random bootstrap
breakages from time to time, but all the time.
Including GM2_C_OBJS in m2_OBJS is I think the right thing, but that
results in predefining IN_GCC_FRONTEND macro and we have e.g.

/* Front ends should never have to include middle-end headers.  Enforce
   this by poisoning the header double-include protection defines.  */
#ifdef IN_GCC_FRONTEND
#pragma GCC poison GCC_RTL_H GCC_EXCEPT_H GCC_EXPR_H
#endif

in system.h to make sure that FE sources don't include rtl.h, except.h,
expr.h.  But m2/gm2-gcc/gcc-consolidation.h includes tons of the RTL
headers, rtl.h, df.h (twice), except.h; why?
Also, seems one of GM2_C_OBJS is some special copy of stor-layout.cc
which really isn't a FE file and so needs the RTL-ish headers.

	Jakub
  

Patch

--- gcc/m2/Make-lang.in.jj	2023-05-04 09:31:27.289948109 +0200
+++ gcc/m2/Make-lang.in	2023-06-06 21:38:26.655336041 +0200
@@ -511,6 +511,8 @@  GM2_LIBS_BOOT     = m2/gm2-compiler-boot
                     m2/gm2-libs-boot/libgm2.a \
                     $(GM2-BOOT-O)
 
+$(GM2_C_OBJS) : | $(generated_files)
+
 cc1gm2$(exeext): m2/stage1/cc1gm2$(exeext) $(m2.prev)
 	cp -p $< $@