PowerPC: Fix rs6000-gen-builtins with build != host [PR102353]

Message ID 6b051c9b-f538-35fd-2bd5-1555f8ce625f@codesourcery.com
State New
Headers
Series PowerPC: Fix rs6000-gen-builtins with build != host [PR102353] |

Commit Message

Tobias Burnus Sept. 16, 2021, 9:07 a.m. UTC
  As mentioned in https://gcc.gnu.org/PR102353 and in the patch,
rs6000-gen-builtins was build to be run on "host" – and then linked and
on on "build".

That caused bootstrap fails at link time.

The patch now does the same as Makefile.in for 'gen*', i.e. build under
build/ (using the Makefile.in rule), the linking is already the same as
for 'build/gen%' and for running, it runs it with valgrind if configured
(as gen* do). additionally, I added the exe extension var, in case it is
needed, following the gen* rules.

Tested with a x86_64-gnu-linux (build) → powerpc64le-linux-gnu (host,
target) build.

OK?

Tobias

-----------------
Siemens Electronic Design Automation GmbH; Anschrift: Arnulfstraße 201, 80634 München; Gesellschaft mit beschränkter Haftung; Geschäftsführer: Thomas Heurung, Frank Thürauf; Sitz der Gesellschaft: München; Registergericht München, HRB 106955
  

Comments

Li, Pan2 via Gcc-patches Sept. 16, 2021, 1:12 p.m. UTC | #1
Thank you, Tobias!  This looks good to me and doesn't break 
host=target=build bootstrap.  I appreciate the patch very much.  (I 
can't approve it, so please wait for Segher/David to weigh in.)

Bill

On 9/16/21 4:07 AM, Tobias Burnus wrote:
> As mentioned in https://gcc.gnu.org/PR102353 and in the patch,
> rs6000-gen-builtins was build to be run on "host" – and then linked and
> on on "build".
>
> That caused bootstrap fails at link time.
>
> The patch now does the same as Makefile.in for 'gen*', i.e. build under
> build/ (using the Makefile.in rule), the linking is already the same as
> for 'build/gen%' and for running, it runs it with valgrind if configured
> (as gen* do). additionally, I added the exe extension var, in case it is
> needed, following the gen* rules.
>
> Tested with a x86_64-gnu-linux (build) → powerpc64le-linux-gnu (host,
> target) build.
>
> OK?
>
> Tobias
>
> -----------------
> Siemens Electronic Design Automation GmbH; Anschrift: Arnulfstraße 201, 80634 München; Gesellschaft mit beschränkter Haftung; Geschäftsführer: Thomas Heurung, Frank Thürauf; Sitz der Gesellschaft: München; Registergericht München, HRB 106955
  
Segher Boessenkool Sept. 16, 2021, 3:31 p.m. UTC | #2
Hi!

On Thu, Sep 16, 2021 at 11:07:25AM +0200, Tobias Burnus wrote:
> As mentioned in https://gcc.gnu.org/PR102353 and in the patch,
> rs6000-gen-builtins was build to be run on "host" – and then linked and
> on on "build".
> 
> That caused bootstrap fails at link time.

> Tested with a x86_64-gnu-linux (build) → powerpc64le-linux-gnu (host,
> target) build.

Needs a native build, too, but Bill did that.  Okay.

> PowerPC: Fix rs6000-gen-builtins with build != host [PR102353]

> 
> This mimics what the main Makefile.in does: compile the generator
> files under build (with Makefile.in's 'build/%.o' rule for compilation).
> It also adds $(RUN_GEN) to optionally run it with valgrind and
> the $(build_exeext) suffix.
> 
> Before, the .o files were compiled with $(COMPILE), causing link
> error with $(LINKER_FOR_BUILD) for build != host.
> 
> gcc/
> 	PR target/102353
> 	* config/rs6000/t-rs6000 (build/rs6000-gen-builtins.o,
> 	build/rbtree.o): Added 'build/' to target, use build/%.o rule.

You can break the line after the ":" fwiw.

> 	(build/rs6000-gen-builtins$(build_exeext)): Add 'build/' and
> 	'$(build_exeext)' to target and 'build/' for the *.o files.
> 	(rs6000-builtins.c): Update for those changes; run
> 	rs6000-gen-builtins with $(RUN_GEN).

The margin is at 80 chars for changelogs.

> -rs6000-gen-builtins: rs6000-gen-builtins.o rbtree.o
> +build/rs6000-gen-builtins$(build_exeext): build/rs6000-gen-builtins.o build/rbtree.o $(BUILD_LIBDEPS)

Maybe break the prerequisites here (with "\"), the line is very long now?

Okay for trunk.  Thanks!


Segher
  

Patch

PowerPC: Fix rs6000-gen-builtins with build != host [PR102353]

This mimics what the main Makefile.in does: compile the generator
files under build (with Makefile.in's 'build/%.o' rule for compilation).
It also adds $(RUN_GEN) to optionally run it with valgrind and
the $(build_exeext) suffix.

Before, the .o files were compiled with $(COMPILE), causing link
error with $(LINKER_FOR_BUILD) for build != host.

gcc/
	PR target/102353
	* config/rs6000/t-rs6000 (build/rs6000-gen-builtins.o,
	build/rbtree.o): Added 'build/' to target, use build/%.o rule.
	(build/rs6000-gen-builtins$(build_exeext)): Add 'build/' and
	'$(build_exeext)' to target and 'build/' for the *.o files.
	(rs6000-builtins.c): Update for those changes; run
	rs6000-gen-builtins with $(RUN_GEN).

diff --git a/gcc/config/rs6000/t-rs6000 b/gcc/config/rs6000/t-rs6000
index 92766d8..7752e16 100644
--- a/gcc/config/rs6000/t-rs6000
+++ b/gcc/config/rs6000/t-rs6000
@@ -44,15 +44,10 @@  rs6000-logue.o: $(srcdir)/config/rs6000/rs6000-logue.c
 	$(COMPILE) $<
 	$(POSTCOMPILE)
 
-rs6000-gen-builtins.o: $(srcdir)/config/rs6000/rs6000-gen-builtins.c
-	$(COMPILE) $<
-	$(POSTCOMPILE)
-
-rbtree.o: $(srcdir)/config/rs6000/rbtree.c
-	$(COMPILE) $<
-	$(POSTCOMPILE)
+build/rs6000-gen-builtins.o: $(srcdir)/config/rs6000/rs6000-gen-builtins.c
+build/rbtree.o: $(srcdir)/config/rs6000/rbtree.c
 
-rs6000-gen-builtins: rs6000-gen-builtins.o rbtree.o
+build/rs6000-gen-builtins$(build_exeext): build/rs6000-gen-builtins.o build/rbtree.o $(BUILD_LIBDEPS)
 	$(LINKER_FOR_BUILD) $(BUILD_LINKERFLAGS) $(BUILD_LDFLAGS) -o $@ \
 	    $(filter-out $(BUILD_LIBDEPS), $^) $(BUILD_LIBS)
 
@@ -62,10 +57,11 @@  rs6000-gen-builtins: rs6000-gen-builtins.o rbtree.o
 #       <recipe>
 # For now, the header files depend on rs6000-builtins.c, which avoids
 # races because the .c file is closed last in rs6000-gen-builtins.c.
-rs6000-builtins.c: rs6000-gen-builtins \
+rs6000-builtins.c: build/rs6000-gen-builtins$(build_exeext) \
 		   $(srcdir)/config/rs6000/rs6000-builtin-new.def \
 		   $(srcdir)/config/rs6000/rs6000-overload.def
-	./rs6000-gen-builtins $(srcdir)/config/rs6000/rs6000-builtin-new.def \
+	$(RUN_GEN) ./build/rs6000-gen-builtins$(build_exeext) \
+		$(srcdir)/config/rs6000/rs6000-builtin-new.def \
 		$(srcdir)/config/rs6000/rs6000-overload.def rs6000-builtins.h \
 		rs6000-builtins.c rs6000-vecdefines.h