diff mbox

[v3,12/18] convert the Go front end to automatic dependencies

Message ID 1377007156-540-13-git-send-email-tromey@redhat.com
State New
Headers show

Commit Message

Tom Tromey Aug. 20, 2013, 1:59 p.m. UTC
This converts Go.

It renames gospec.o to go/gospec.o, for uniformity and so we can
remove an explicit rule.

It defines go_OBJS, to conform to the documented Make-lang.in
conventions, and to ensure that Go objects are given the correct
order-only dependencies on generated files.

	* Make-lang.in (gospec.o): Remove.
	(CFLAGS-go/gospec.o): New variable.
	(GCCGO_OBJS): Update to use go/gospec.o.
	(go_OBJS): Define.
	(GO_SYSTEM_H, GO_C_H, GO_LINEMAP_H, GO_LEX_H, GO_PARSE_H)
	(GO_GOGO_H, GO_TYPES_H, GO_STATEMENTS_H, GO_EXPRESSIONS_H)
	(GO_EXPORT_H, GO_IMPORT_H, GO_RUNTIME_H, GO_AST_DUMP_H)
	(go/go-backend.o, go/go-lang.o, go/go-gcc.o, go/go-linemap.o)
	(go/ast-dump.o, go/dataflow.o, go/export.o, go/expressions.o)
	(go/go.o, go/go-dump.o, go/go-optimize.o, go/gogo-tree.o)
	(go/gogo.o, go/import.o, go/import-archive.o, go/lex.o)
	(go/parse.o, go/runtime.o, go/statements.o, go/types.o)
	(go/unsafe.o): Remove.
	(CFLAGS-go/go-gcc.o, CFLAGS-go/go-linemap.o): New variables.
	(go/%.o: go/gofrontend/%.cc): Use COMPILE and POSTCOMPILE.
---
 gcc/go/Make-lang.in | 99 +++++------------------------------------------------
 1 file changed, 8 insertions(+), 91 deletions(-)

Comments

Ian Lance Taylor Aug. 24, 2013, 12:46 a.m. UTC | #1
2013/8/20 Tom Tromey <tromey@redhat.com>:
> This converts Go.
>
> It renames gospec.o to go/gospec.o, for uniformity and so we can
> remove an explicit rule.
>
> It defines go_OBJS, to conform to the documented Make-lang.in
> conventions, and to ensure that Go objects are given the correct
> order-only dependencies on generated files.
>
>         * Make-lang.in (gospec.o): Remove.
>         (CFLAGS-go/gospec.o): New variable.
>         (GCCGO_OBJS): Update to use go/gospec.o.
>         (go_OBJS): Define.
>         (GO_SYSTEM_H, GO_C_H, GO_LINEMAP_H, GO_LEX_H, GO_PARSE_H)
>         (GO_GOGO_H, GO_TYPES_H, GO_STATEMENTS_H, GO_EXPRESSIONS_H)
>         (GO_EXPORT_H, GO_IMPORT_H, GO_RUNTIME_H, GO_AST_DUMP_H)
>         (go/go-backend.o, go/go-lang.o, go/go-gcc.o, go/go-linemap.o)
>         (go/ast-dump.o, go/dataflow.o, go/export.o, go/expressions.o)
>         (go/go.o, go/go-dump.o, go/go-optimize.o, go/gogo-tree.o)
>         (go/gogo.o, go/import.o, go/import-archive.o, go/lex.o)
>         (go/parse.o, go/runtime.o, go/statements.o, go/types.o)
>         (go/unsafe.o): Remove.
>         (CFLAGS-go/go-gcc.o, CFLAGS-go/go-linemap.o): New variables.
>         (go/%.o: go/gofrontend/%.cc): Use COMPILE and POSTCOMPILE.

This is OK.

I assume that dropping $(OUTPUT_OPTION) is correct--I haven't looked
at the new definition of $(COMPILE).

Many thanks.

Ian
Tom Tromey Aug. 26, 2013, 4:09 p.m. UTC | #2
>>>>> "Ian" == Ian Lance Taylor <iant@google.com> writes:

Ian> I assume that dropping $(OUTPUT_OPTION) is correct--I haven't looked
Ian> at the new definition of $(COMPILE).

I believe the depcomp script takes care of this.

Tom
Paolo Bonzini Sept. 16, 2013, 3:26 p.m. UTC | #3
Il 26/08/2013 18:09, Tom Tromey ha scritto:
>>>>>> "Ian" == Ian Lance Taylor <iant@google.com> writes:
> 
> Ian> I assume that dropping $(OUTPUT_OPTION) is correct--I haven't looked
> Ian> at the new definition of $(COMPILE).
> 
> I believe the depcomp script takes care of this.

I think that would be the "compile" script, not depcomp.  But I suspect
that this has been broken for a while, since the C front-end require
$(OUTPUT_OPTION).

You are listed as the author of the "compile" script in Automake, do you
remember which compilers need it?  I'm too young for that (that's
something I can say less and less :))...

Paolo
Tom Tromey Sept. 16, 2013, 4:03 p.m. UTC | #4
Paolo> You are listed as the author of the "compile" script in Automake, do you
Paolo> remember which compilers need it?  I'm too young for that (that's
Paolo> something I can say less and less :))...

I have no idea any more.

I can try a test build using a setting for CC that rejects -c -o.

Tom
Tom Tromey Sept. 16, 2013, 5:23 p.m. UTC | #5
Tom> I can try a test build using a setting for CC that rejects -c -o.

I did this and the build died pretty early on:

  /home/tromey/Space/Trunk/Git/bin/my-cc -c -DHAVE_CONFIG_H -g -g -I. -I../../gcc/libiberty/../include  -W -Wall -Wwrite-strings -Wc++-compat -Wstrict-prototypes -pedantic  -fpic ../../gcc/libiberty/regex.c -o pic/regex.o; \
else true; fi
no -c -o support
make[3]: *** [regex.o] Error 1
make[3]: Leaving directory `/home/tromey/Space/Trunk/Git/build/libiberty'
make[2]: *** [all-stage1-libiberty] Error 2


In this case the --enable-shared for libiberty was added automatically
because LTO defaults to enabled.  Adding --disable-lto lets it get
further:

/home/tromey/Space/Trunk/Git/bin/my-cc -DPACKAGE_NAME=\"\" -DPACKAGE_TARNAME=\"\" -DPACKAGE_VERSION=\"\" -DPACKAGE_STRING=\"\" -DPACKAGE_BUGREPORT=\"\" -DPACKAGE_URL=\"\" -DPACKAGE=\"zlib\" -DVERSION=\"1.1.4\" -DSTDC_HEADERS=1 -DHAVE_SYS_TYPES_H=1 -DHAVE_SYS_STAT_H=1 -DHAVE_STDLIB_H=1 -DHAVE_STRING_H=1 -DHAVE_MEMORY_H=1 -DHAVE_STRINGS_H=1 -DHAVE_INTTYPES_H=1 -DHAVE_STDINT_H=1 -DHAVE_UNISTD_H=1 -DHAVE_DLFCN_H=1 -DLT_OBJDIR=\".libs/\" -DHAVE_STDLIB_H=1 -DHAVE_UNISTD_H=1 -DHAVE_GETPAGESIZE=1 -DHAVE_MMAP=1 -DHAVE_MEMCPY=1 -DHAVE_STRERROR=1 -DHAVE_UNISTD_H=1 -I. -I../../gcc/zlib   -g  -g -c -o libz_a-adler32.o `test -f 'adler32.c' || echo '../../gcc/zlib/'`adler32.c
no -c -o support
make[3]: *** [libz_a-adler32.o] Error 1
make[3]: Leaving directory `/home/tromey/Space/Trunk/Git/build/zlib'
make[2]: *** [all-stage1-zlib] Error 2


And indeed, zlib's configure.ac does not invoke AC_PROG_CC_C_O.

So, maybe this has been broken a long time.

Tom
Paolo Bonzini Sept. 16, 2013, 5:26 p.m. UTC | #6
Il 16/09/2013 19:23, Tom Tromey ha scritto:
> Tom> I can try a test build using a setting for CC that rejects -c -o.
> 
> I did this and the build died pretty early on:
> 
>   /home/tromey/Space/Trunk/Git/bin/my-cc -c -DHAVE_CONFIG_H -g -g -I. -I../../gcc/libiberty/../include  -W -Wall -Wwrite-strings -Wc++-compat -Wstrict-prototypes -pedantic  -fpic ../../gcc/libiberty/regex.c -o pic/regex.o; \
> else true; fi
> no -c -o support
> make[3]: *** [regex.o] Error 1
> make[3]: Leaving directory `/home/tromey/Space/Trunk/Git/build/libiberty'
> make[2]: *** [all-stage1-libiberty] Error 2
> 
> 
> In this case the --enable-shared for libiberty was added automatically
> because LTO defaults to enabled.  Adding --disable-lto lets it get
> further:
> 
> /home/tromey/Space/Trunk/Git/bin/my-cc -DPACKAGE_NAME=\"\" -DPACKAGE_TARNAME=\"\" -DPACKAGE_VERSION=\"\" -DPACKAGE_STRING=\"\" -DPACKAGE_BUGREPORT=\"\" -DPACKAGE_URL=\"\" -DPACKAGE=\"zlib\" -DVERSION=\"1.1.4\" -DSTDC_HEADERS=1 -DHAVE_SYS_TYPES_H=1 -DHAVE_SYS_STAT_H=1 -DHAVE_STDLIB_H=1 -DHAVE_STRING_H=1 -DHAVE_MEMORY_H=1 -DHAVE_STRINGS_H=1 -DHAVE_INTTYPES_H=1 -DHAVE_STDINT_H=1 -DHAVE_UNISTD_H=1 -DHAVE_DLFCN_H=1 -DLT_OBJDIR=\".libs/\" -DHAVE_STDLIB_H=1 -DHAVE_UNISTD_H=1 -DHAVE_GETPAGESIZE=1 -DHAVE_MMAP=1 -DHAVE_MEMCPY=1 -DHAVE_STRERROR=1 -DHAVE_UNISTD_H=1 -I. -I../../gcc/zlib   -g  -g -c -o libz_a-adler32.o `test -f 'adler32.c' || echo '../../gcc/zlib/'`adler32.c
> no -c -o support
> make[3]: *** [libz_a-adler32.o] Error 1
> make[3]: Leaving directory `/home/tromey/Space/Trunk/Git/build/zlib'
> make[2]: *** [all-stage1-zlib] Error 2
> 
> 
> And indeed, zlib's configure.ac does not invoke AC_PROG_CC_C_O.
> 
> So, maybe this has been broken a long time.

Likely.  Zapping OUTPUT_OPTION sounds like the right thing to do.

Paolo
diff mbox

Patch

diff --git a/gcc/go/Make-lang.in b/gcc/go/Make-lang.in
index 015ed7a..e4bceb2 100644
--- a/gcc/go/Make-lang.in
+++ b/gcc/go/Make-lang.in
@@ -30,12 +30,9 @@  go: go1$(exeext)
 
 .PHONY: go
 
-gospec.o: $(srcdir)/go/gospec.c $(SYSTEM_H) coretypes.h $(TM_H) $(GCC_H) \
-    $(CONFIG_H) opts.h
-	$(COMPILER) -c $(ALL_COMPILERFLAGS) $(ALL_CPPFLAGS) $(DRIVER_DEFINES) \
-		$(INCLUDES) $(srcdir)/go/gospec.c
+CFLAGS-go/gospec.o += $(DRIVER_DEFINES)
 
-GCCGO_OBJS = $(GCC_OBJS) gospec.o
+GCCGO_OBJS = $(GCC_OBJS) go/gospec.o
 gccgo$(exeext): $(GCCGO_OBJS) $(EXTRA_GCC_OBJS) libcommon-target.a $(LIBDEPS)
 	+$(LINKER) $(ALL_LINKERFLAGS) $(LDFLAGS) -o $@ \
 	  $(GCCGO_OBJS) $(EXTRA_GCC_OBJS) libcommon-target.a \
@@ -74,6 +71,8 @@  GO_OBJS = \
 	go/types.o \
 	go/unsafe.o
 
+go_OBJS = $(GO_OBJS) go/gospec.o
+
 go1$(exeext): $(GO_OBJS) attribs.o $(BACKEND) $(LIBDEPS)
 	+$(LLINKER) $(ALL_LINKERFLAGS) $(LDFLAGS) -o $@ \
 	      $(GO_OBJS) attribs.o $(BACKEND) $(LIBS) $(BACKENDLIBS)
@@ -222,96 +221,14 @@  go.stageprofile: stageprofile-start
 go.stagefeedback: stagefeedback-start
 	-mv go/*$(objext) stagefeedback/go
 
-GO_SYSTEM_H = go/go-system.h $(CONFIG_H) $(SYSTEM_H) coretypes.h \
-	$(DIAGNOSTIC_CORE_H) $(INPUT_H) intl.h
-
-GO_C_H = go/go-c.h $(MACHMODE_H)
-GO_LINEMAP_H = go/gofrontend/go-linemap.h $(GO_SYSTEM_H) go/go-location.h
-GO_LEX_H = go/gofrontend/lex.h go/gofrontend/operator.h $(GO_LINEMAP_H)
-GO_PARSE_H = go/gofrontend/parse.h
-GO_GOGO_H = go/gofrontend/gogo.h $(GO_LINEMAP_H)
-GO_TYPES_H = go/gofrontend/types.h $(GO_LINEMAP_H)
-GO_STATEMENTS_H = go/gofrontend/statements.h go/gofrontend/operator.h
-GO_EXPRESSIONS_H = go/gofrontend/expressions.h go/gofrontend/operator.h
-GO_EXPORT_H = go/gofrontend/export.h go/gofrontend/string-dump.h
-GO_IMPORT_H = go/gofrontend/import.h $(GO_EXPORT_H) $(GO_LINEMAP_H)
-GO_RUNTIME_H = go/gofrontend/runtime.h go/gofrontend/runtime.def
-GO_AST_DUMP_H = go/gofrontend/ast-dump.h go/gofrontend/string-dump.h
-
-go/go-backend.o: go/go-backend.c $(CONFIG_H) $(SYSTEM_H) coretypes.h \
-	$(TM_H) $(TREE_H) $(TM_P_H) output.h $(TARGET_H) \
-	$(COMMON_TARGET_H)
-
 CFLAGS-go/go-lang.o += -DDEFAULT_TARGET_VERSION=\"$(version)\" \
 	-DDEFAULT_TARGET_MACHINE=\"$(target_noncanonical)\"
-go/go-lang.o: go/go-lang.c $(CONFIG_H) $(SYSTEM_H) coretypes.h $(OPTS_H) \
-		$(TREE_H) $(GIMPLE_H) $(GGC_H) $(TOPLEV_H) debug.h options.h \
-		$(FLAGS_H) convert.h $(DIAGNOSTIC_H) langhooks.h \
-		$(LANGHOOKS_DEF_H) $(TARGET_H) $(GO_C_H) \
-		gt-go-go-lang.h gtype-go.h $(COMMON_TARGET_H)
 
 GOINCLUDES = -I $(srcdir)/go -I $(srcdir)/go/gofrontend
 
-go/go-gcc.o: go/go-gcc.cc $(GO_SYSTEM_H) $(TREE_H) tree-iterator.h \
-		$(GIMPLE_H) toplev.h output.h $(GO_C_H) $(GO_GOGO_H) \
-		go/gofrontend/backend.h
-	$(CXX) -c $(GOINCLUDES) $(ALL_CPPFLAGS) $(ALL_CXXFLAGS) $< $(OUTPUT_OPTION)
-
-go/go-linemap.o: go/go-linemap.cc $(GO_SYSTEM_H) $(GO_LINEMAP_H)
-	$(CXX) -c $(GOINCLUDES) $(ALL_CPPFLAGS) $(ALL_CXXFLAGS) $< $(OUTPUT_OPTION)
+CFLAGS-go/go-gcc.o += $(GOINCLUDES)
+CFLAGS-go/go-linemap.o += $(GOINCLUDES)
 
 go/%.o: go/gofrontend/%.cc
-	$(CXX) -c $(GOINCLUDES) $(ALL_CPPFLAGS) $(ALL_CXXFLAGS) $< $(OUTPUT_OPTION)
-
-go/ast-dump.o: go/gofrontend/ast-dump.cc $(GO_SYSTME_H) $(GO_GOGO_H) \
-	$(GO_EXPRESSIONS_H) $(GO_STATEMENTS_H) $(GO_TYPES_H) \
-	$(GO_AST_DUMP_H) $(GO_C_H) go/gofrontend/go-dump.h
-go/dataflow.o: go/gofrontend/dataflow.cc $(GO_SYSTEM_H) $(GO_GOGO_H) \
-	$(GO_EXPRESSIONS_H) $(GO_STATEMENTS_H) go/gofrontend/dataflow.h
-go/export.o: go/gofrontend/export.cc $(GO_SYSTEM_H) \
-	$(srcdir)/../include/sha1.h $(GO_C_H) $(GO_GOGO_H) $(GO_TYPES_H) \
-	$(GO_STATEMENTS_H) $(GO_EXPORT_H)
-go/expressions.o: go/gofrontend/expressions.cc $(GO_SYSTEM_H) $(TOPLEV_H) \
-	intl.h $(TREE_H) $(GIMPLE_H) tree-iterator.h convert.h $(REAL_H) \
-	realmpfr.h $(GO_C_H) $(GO_GOGO_H) $(GO_TYPES_H) \
-	$(GO_EXPORT_H) $(GO_IMPORT_H) $(GO_STATEMENTS_H) $(GO_LEX_H) \
-	$(GO_RUNTIME_H) go/gofrontend/backend.h $(GO_EXPRESSIONS_H) \
-	$(GO_AST_DUMP_H)
-go/go.o: go/gofrontend/go.cc $(GO_SYSTEM_H) $(GO_C_H) $(GO_LEX_H) \
-	$(GO_PARSE_H) go/gofrontend/backend.h $(GO_GOGO_H)
-go/go-dump.o: go/gofrontend/go-dump.cc $(GO_SYSTEM_H) $(GO_C_H) \
-	go/gofrontend/go-dump.h
-go/go-optimize.o: go/gofrontend/go-optimize.cc $(GO_SYSTEM_H) $(GO_C_H) \
-	go/gofrontend/go-optimize.h
-go/gogo-tree.o: go/gofrontend/gogo-tree.cc $(GO_SYSTEM_H) $(TOPLEV_H) \
-	$(TREE_H) $(GIMPLE_H) tree-iterator.h $(CGRAPH_H) langhooks.h \
-	convert.h output.h $(DIAGNOSTIC_H) $(GO_TYPES_H) \
-	$(GO_EXPRESSIONS_H) $(GO_STATEMENTS_H) $(GO_RUNTIME_H) \
-	go/gofrontend/backend.h $(GO_GOGO_H)
-go/gogo.o: go/gofrontend/gogo.cc $(GO_SYSTEM_H) \
-	$(srcdir)/../include/filenames.h $(GO_C_H) go/gofrontend/go-dump.h \
-	$(GO_LEX_H) $(GO_TYPES_H) $(GO_STATEMENTS_H) $(GO_EXPRESSIONS_H) \
-	go/gofrontend/dataflow.h $(GO_RUNTIME_H) $(GO_IMPORT_H) \
-	$(GO_EXPORT_H) go/gofrontend/backend.h $(GO_GOGO_H)
-go/import.o: go/gofrontend/import.cc $(GO_SYSTEM_H) \
-	$(srcdir)/../include/filenames.h $(srcdir)/../include/simple-object.h \
-	$(GO_C_H) $(GO_GOGO_H) $(GO_LEX_H) $(GO_TYPES_H) $(GO_EXPORT_H) \
-	$(GO_IMPORT_H)
-go/import-archive.o: go/gofrontend/import-archive.cc $(GO_SYSTEM_H) \
-	$(GO_IMPORT_H)
-go/lex.o: go/gofrontend/lex.cc $(GO_LEX_H) $(GO_SYSTEM_H)
-go/parse.o: go/gofrontend/parse.cc $(GO_SYSTEM_H) $(GO_LEX_H) $(GO_GOGO_H) \
-	$(GO_TYPES_H) $(GO_STATEMENTS_H) $(GO_EXPRESSIONS_H) $(GO_PARSE_H)
-go/runtime.o: go/gofrontend/runtime.cc $(GO_SYSTEM_H) $(GO_GOGO_H) \
-	$(GO_TYPES_H) $(GO_EXPRESSIONS_H) $(GO_RUNTIME_H) \
-	go/gofrontend/runtime.def
-go/statements.o: go/gofrontend/statements.cc $(GO_SYSTEM_H) \
-	$(GO_C_H) $(GO_TYPES_H) $(GO_EXPRESSIONS_H) $(GO_GOGO_H) \
-	$(GO_RUNTIME_H) go/gofrontend/backend.h $(GO_STATEMENTS_H) \
-	$(GO_AST_DUMP_H)
-go/types.o: go/gofrontend/types.cc $(GO_SYSTEM_H) $(TOPLEV_H) intl.h $(TREE_H) \
-	$(GIMPLE_H) $(REAL_H) convert.h $(GO_C_H) $(GO_GOGO_H) \
-	go/gofrontend/operator.h $(GO_EXPRESSIONS_H) $(GO_STATEMENTS_H) \
-	$(GO_EXPORT_H) $(GO_IMPORT_H) go/gofrontend/backend.h $(GO_TYPES_H)
-go/unsafe.o: go/gofrontend/unsafe.cc $(GO_SYSTEM_H) $(GO_C_H) $(GO_TYPES_H) \
-	$(GO_GOGO_H)
+	$(COMPILE) $(GOINCLUDES) $<
+	$(POSTCOMPILE)