Fix build with GNU Make 3.81
authorBernd Edlinger <bernd.edlinger@hotmail.de>
Fri, 13 Dec 2019 16:21:21 +0000 (17:21 +0100)
committerBernd Edlinger <bernd.edlinger@hotmail.de>
Thu, 19 Dec 2019 19:18:32 +0000 (20:18 +0100)
GNU Make 3.81 is apparently confused when the same
source file is processed by a pattern rule and an
explicit rule at the same time with different output file.
The pattern %.o: ../%.c and alloc-ipa.o: ../alloc.c
both have the source ../alloc.c but two independent
object files alloc.o and alloc-ipa.o, so
while building gdbserver I see the following message:

make[4]: Circular alloc-ipa.o <- ../alloc.c dependency dropped.
  CXX    alloc-ipa.o
g++: warning: '-x c++' after last input file has no effect
g++: fatal error: no input files
compilation terminated.

In the make debug output I see the pattern is first correct:

alloc-ipa.o: ../alloc.c | config.h build-gnulib-gdbserver/import/string.h
        $(IPAGENT_COMPILE) $(WARN_CFLAGS_NO_FORMAT) $<
        $(POSTCOMPILE)

But after the "Circular" dependency is dropped, the pattern
is changed to:

alloc-ipa.o: | config.h build-gnulib-gdbserver/import/string.h
        $(IPAGENT_COMPILE) $(WARN_CFLAGS_NO_FORMAT) $<
        $(POSTCOMPILE)

So indeed now $< is empty, and the build step fails.

This happens only when alloc.o needs to be built, when alloc.o
was already built, the build succeeds, but it takes often
several attempts until the build succeeds.
By rewriting the alloc-ipa.c: ../alloc.c rule into a pattern
rule, the problem goes away.

While already at it, this patch removes also the
$(WARN_CFLAGS_NO_FORMAT) from the build rule, which is just a
copy/paste thing that is not necessary for alloc.c at all.

gdb/gdbserver/ChangeLog
gdb/gdbserver/Makefile.in

index ecc3db53ebba20cb78c6722f71ee6389314eb56c..8ab1f07b870d2925ff9babdff5c899c91b06e202 100644 (file)
@@ -1,3 +1,7 @@
+2019-12-16  Bernd Edlinger  <bernd.edlinger@hotmail.de>
+
+       * Makefile.in: Fix build with GNU Make 3.81
+
 2019-12-16  Tom Tromey  <tromey@adacore.com>
 
        * server.c (get_exec_file): Constify result.
index 10e004039f9661964bcd1f030b6ec2baae336222..9e8c21347263155e889c87df926b3d92d81a5c44 100644 (file)
@@ -580,10 +580,6 @@ ax.o: ax.c
        $(COMPILE) $(WARN_CFLAGS_NO_FORMAT) $<
        $(POSTCOMPILE)
 
-alloc-ipa.o: ../alloc.c
-       $(IPAGENT_COMPILE) $(WARN_CFLAGS_NO_FORMAT) $<
-       $(POSTCOMPILE)
-
 # Rules for objects that go in the in-process agent.
 
 arch/%-ipa.o: ../arch/%.c
@@ -602,6 +598,10 @@ gdbsupport/%-ipa.o: ../gdbsupport/%.c
        $(IPAGENT_COMPILE) $<
        $(POSTCOMPILE)
 
+%-ipa.o: ../%.c
+       $(IPAGENT_COMPILE) $<
+       $(POSTCOMPILE)
+
 # Note: Between two matching pattern rules, GNU Make 3.81 chooses the first one.
 # Therefore, this one needs to be before "%.o: %.c" for it to be considered for
 # files such as linux-amd64-ipa.o generated from linux-amd64-ipa.c.
This page took 0.099865 seconds and 4 git commands to generate.