diff mbox

Fix make 3.81 build errors

Message ID e8e46953-ddd4-9b0c-80e2-78b8d2b632a4@simark.ca
State New
Headers show

Commit Message

Simon Marchi Feb. 19, 2018, 4:16 p.m. UTC
On 2018-02-19 09:32 AM, Alan Hayward wrote:
> Make rules in make 3.81 are parsed slightly different than newer
> versions of make.
> 
> Patch b5884fa7101cc528f07fd57c3de445a3680964a6 caused build errors
> on the older 3.81:
> make[4]: *** No rule to make target `../../../binutils-gdb/gdb/gdbserver/common/btrace-common.c'.  Stop.
> 
> This is because make 3.81 was using the wrong rule to build btrace-common.c,
> causing it to look in the wrong source directory.
> 
> This fix simply re-orders the make rules in gdbserver. However, for reasons
> I am unsure of, this requires moving the corresponding ipa rule. I've tried
> many many different combinations, and this is the only one that works.
> Therefore, not pushing as obvious and asking for review first.
> 
> Tested on x86 and Ubuntu-AArch32-native-extended-gdbserver-m32 builds using
> both make 4.1 and make 3.81
> 
> gdbserver/
> 
> 2018-02-19  Alan Hayward  <alan.hayward@arm.com>
> 
> 	* Makefile.in: Switch order of make rules. 

Hi Alan,

I hit this problem with GNU Make 3.81 before, there's a comment in the gdbserver Makefile:

# 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.
#
# Later versions of GNU Make choose the rule with the shortest stem, so it would
# work in any order.

So to please Make 3.81, you need to order rules from the more specific (shorter stem)
to the more general (longer stem) if you want it to pick up the more specific rule.
That means putting "common/%.o: ../common/%.c" before "%.o: %.c".

I think there's a way to do it while keeping related rules a bit more together.  What
about the patch below?  I moved a bit more than necessary (e.g. the arch/ rule) to put
all rules for things that go into the gdbserver binary together and have a similar order
for both gdbserver and the IPA.


From ac84e284d818b3e6e58f87e5cb5ceb5152cdd8ca Mon Sep 17 00:00:00 2001
From: Alan Hayward <Alan.Hayward@arm.com>
Date: Mon, 19 Feb 2018 14:32:07 +0000
Subject: [PATCH] Fix make 3.81 build errors

Make rules in make 3.81 are parsed slightly different than newer
versions of make.

Patch b5884fa7101cc528f07fd57c3de445a3680964a6 caused build errors
on the older 3.81:
make[4]: *** No rule to make target `../../../binutils-gdb/gdb/gdbserver/common/btrace-common.c'.  Stop.

This is because make 3.81 was using the wrong rule to build btrace-common.c,
causing it to look in the wrong source directory.

This fix simply re-orders the make rules in gdbserver. However, for reasons
I am unsure of, this requires moving the corresponding ipa rule. I've tried
many many different combinations, and this is the only one that works.
Therefore, not pushing as obvious and asking for review first.

Tested on x86 and Ubuntu-AArch32-native-extended-gdbserver-m32 builds using
both make 4.1 and make 3.81

gdbserver/

2018-02-19  Alan Hayward  <alan.hayward@arm.com>

	* Makefile.in: Switch order of make rules.
---
 gdb/gdbserver/Makefile.in | 28 ++++++++++++++--------------
 1 file changed, 14 insertions(+), 14 deletions(-)
diff mbox

Patch

diff --git a/gdb/gdbserver/Makefile.in b/gdb/gdbserver/Makefile.in
index fcb6e1e817..55796ac8da 100644
--- a/gdb/gdbserver/Makefile.in
+++ b/gdb/gdbserver/Makefile.in
@@ -537,11 +537,15 @@  ax.o: ax.c
 	$(COMPILE) $(WARN_CFLAGS_NO_FORMAT) $<
 	$(POSTCOMPILE)

-arch/%.o: ../arch/%.c
-	$(COMPILE) $<
+# Rules for objects that go in the in-process agent.
+
+arch/%-ipa.o: ../arch/%.c
+	$(IPAGENT_COMPILE) $<
 	$(POSTCOMPILE)

-# Rules for objects that go in the in-process agent.
+common/%-ipa.o: ../common/%.c
+	$(IPAGENT_COMPILE) $<
+	$(POSTCOMPILE)

 %-ipa.o: %-generated.c
 	$(IPAGENT_COMPILE) $<
@@ -562,25 +566,21 @@  arch/%.o: ../arch/%.c
 	$(IPAGENT_COMPILE) $<
 	$(POSTCOMPILE)

-common/%-ipa.o: ../common/%.c
-	$(IPAGENT_COMPILE) $<
-	$(POSTCOMPILE)
-
-arch/%-ipa.o: ../arch/%.c
-	$(IPAGENT_COMPILE) $<
-	$(POSTCOMPILE)
-
 # Rules for objects that go in the gdbserver binary.

-%.o: %-generated.c
+arch/%.o: ../arch/%.c
 	$(COMPILE) $<
 	$(POSTCOMPILE)

-%.o: %.c
+common/%.o: ../common/%.c
+	$(COMPILE) $<
+	$(POSTCOMPILE)
+	
+%.o: %-generated.c
 	$(COMPILE) $<
 	$(POSTCOMPILE)

-common/%.o: ../common/%.c
+%.o: %.c
 	$(COMPILE) $<
 	$(POSTCOMPILE)