Bug 2587 - Failed to build gprof under gmake patched by Apple.
Summary: Failed to build gprof under gmake patched by Apple.
Status: REOPENED
Alias: None
Product: binutils
Classification: Unclassified
Component: gprof (show other bugs)
Version: 2.18
: P2 normal
Target Milestone: ---
Assignee: unassigned
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2006-04-20 06:40 UTC by Masaki MURANAKA
Modified: 2019-11-15 11:53 UTC (History)
5 users (show)

See Also:
Host: powerpc-apple-darwin8
Target: sh-unknown-elf
Build:
Last reconfirmed:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Masaki MURANAKA 2006-04-20 06:40:37 UTC
Building gprof was failed because of patched gmake (bundled with OSX).
Follow is a patch to disable a builtin suffix rule.

Index: Makefile.am
===============================================================
====
RCS file: /cvs/src/src/gprof/Makefile.am,v
retrieving revision 1.26
diff -u -p -r1.26 Makefile.am
--- Makefile.am 6 Apr 2006 21:49:33 -0000       1.26
+++ Makefile.am 20 Apr 2006 06:23:23 -0000
@@ -39,6 +39,9 @@ EXTRA_DIST    = $(BUILT_SOURCES) bbconv.
 
 diststuff: $(BUILT_SOURCES) info $(man_MANS)
 
+# this empry rule is a hack against gmake patched by Apple.
+%.o:%.m
+
 .m.c:
        awk -f $(srcdir)/gen-c-prog.awk > ./$*.c ?
            FUNCTION=`(echo $*|sed -e 's,.*/,,g' -e 's/_bl//')`_blurb ?
Comment 1 Nick Clifton 2006-04-25 16:22:54 UTC
Subject: Re:  New: Failed to build gprof under gmake patched
 by	Apple.

Hi Masaki,

> Building gprof was failed because of patched gmake (bundled with OSX).
> Follow is a patch to disable a builtin suffix rule.

>  diststuff: $(BUILT_SOURCES) info $(man_MANS)
>  
> +# this empry rule is a hack against gmake patched by Apple.
> +%.o:%.m
> +
>  .m.c:
>         awk -f $(srcdir)/gen-c-prog.awk > ./$*.c ?
>             FUNCTION=`(echo $*|sed -e 's,.*/,,g' -e 's/_bl//')`_blurb ?

I have applied this patch, although obviously we hope that Apple will 
fix their version of gmake as well.

Cheers
   Nick


Comment 2 Nick Clifton 2006-04-25 16:23:09 UTC
Patch applied
Comment 3 parakleta 2019-11-13 00:50:55 UTC
I don't know how the Apple specific variant of `gmake` was at the time this bug was resolved, but the relevant build rules are now part of mainline gmake http://git.savannah.gnu.org/cgit/make.git/commit/default.c?id=eda0e24ccdae279a2c12059242ef89a22c274047 but it was added as an old-style suffix rule, so this patch now does nothing (since it is not a builtin pattern rule).

The two options to resolve it appear to be either disabling all builtin rules (can be done with `.MAKEFLAGS: -r`) or else change the suffix order so that '.c' comes before '.m'.

The suffix order was correct before 6bf9431b7430d0c30268c62f78a940657c8d6fbe rebuilt the `makefile.in` file (maybe this was a change in the behaviour of automake?).
Comment 4 cvs-commit@gcc.gnu.org 2019-11-13 11:22:50 UTC
The master branch has been updated by Nick Clifton <nickc@sourceware.org>:

https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=415ed2a17588f855397cc2d03aa68a79e84f77f7

commit 415ed2a17588f855397cc2d03aa68a79e84f77f7
Author: Nick Clifton <nickc@redhat.com>
Date:   Wed Nov 13 11:21:39 2019 +0000

    Fix the rule for building C files in the gprof makefile.
    
    	PR 2587
    	* Makefile.am: Fix rule to build .c files from .m files.
Comment 5 Nick Clifton 2019-11-13 11:30:34 UTC
(In reply to parakleta from comment #3)
 
> The two options to resolve it appear to be either disabling all builtin
> rules (can be done with `.MAKEFLAGS: -r`) or else change the suffix order so
> that '.c' comes before '.m'.

Thanks for the suggestion.  I have gone ahead with the second option as this makes more sense to me.

Cheers
  Nick
Comment 6 parakleta 2019-11-13 21:05:52 UTC
Sorry, by suffix rule order this means the order of suffixes in the `.SUFFIXES:` target which is autogenerated by the `SUFFIXES` variable in the "makefile.am" file.  Your change will attempt to build '.c' files from '.m' files.

I'm not familiar with automake but I believe you should change the relevant line to `SUFFIXES = .c .m` and then need to rebuild the "makefile.in" file using automake.
Comment 7 parakleta 2019-11-13 21:18:03 UTC
I've just realised that changing the order of rules may not work.

We want to have '.m -> .c -> .o' as the sequence without triggering '.m -> .o', and by setting '.c' before '.m' we're saying if '.c -> .o' is possible then use that, but I suspect if the '.c' file is missing or out of date the it will try the '.m -> .o' rule before trying to build the intermediate.

I think this means that either the '.c' files need to be listed as explicit dependencies of the '.o' files in the case that a '.m' file exists (so bypassing the pattern and forcing the explicit sequence '.m -> .c => .o') or else disabling the rules as per my first suggestion.
Comment 8 parakleta 2019-11-13 21:47:43 UTC
(In reply to parakleta from comment #7)

> I've just realised that changing the order of rules may not work.

Ignore this.  There is an explicit dependency on the "BUILT_SOURCES" existing which forces the '.m -> .c' step to occur before other dependency checking is performed so long as the 'all' target is used, so this is good enough.

I think just changing the 'SUFFIXES = .m' to 'SUFFIXES = .c .m' and rebuilding the "makefile.in" should do it.
Comment 9 cvs-commit@gcc.gnu.org 2019-11-14 12:13:24 UTC
The master branch has been updated by Nick Clifton <nickc@sourceware.org>:

https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=63442f6a2eff9f4c5c67099565f59c0f135aff94

commit 63442f6a2eff9f4c5c67099565f59c0f135aff94
Author: Nick Clifton <nickc@redhat.com>
Date:   Thu Nov 14 12:11:43 2019 +0000

    Another attempt at fixing building gprof with gmake.
    
    	PR 2587
    	* Makefile.am (SUFFIXES): Add .c.
    	* Makefile.in: Regenerate.
Comment 10 Nick Clifton 2019-11-14 12:15:03 UTC
(In reply to parakleta from comment #8)
> I think just changing the 'SUFFIXES = .m' to 'SUFFIXES = .c .m' and
> rebuilding the "makefile.in" should do it.

OK, done.  Plus this time I actually rebuilt Makefile.in, which I forgot
last time.  Doh.

I have also REOPENED this PR, so that it will remain active until you
can confirm that the changes are working.

Cheers
  Nick
Comment 11 parakleta 2019-11-15 02:19:19 UTC
(In reply to cvs-commit@gcc.gnu.org from comment #4)
> The master branch has been updated by Nick Clifton <nickc@sourceware.org>:
> 
> https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;
> h=415ed2a17588f855397cc2d03aa68a79e84f77f7
> 
> commit 415ed2a17588f855397cc2d03aa68a79e84f77f7
> Author: Nick Clifton <nickc@redhat.com>
> Date:   Wed Nov 13 11:21:39 2019 +0000
> 
>     Fix the rule for building C files in the gprof makefile.
>     
>     	PR 2587
>     	* Makefile.am: Fix rule to build .c files from .m files.

You still need to revert this change.
Comment 12 Hans-Peter Nilsson 2019-11-15 02:41:11 UTC
(In reply to Nick Clifton from comment #10)
> (In reply to parakleta from comment #8)
> > I think just changing the 'SUFFIXES = .m' to 'SUFFIXES = .c .m' and
> > rebuilding the "makefile.in" should do it.
> 
> OK, done.  Plus this time I actually rebuilt Makefile.in, which I forgot
> last time.  Doh.
> 
> I have also REOPENED this PR, so that it will remain active until you
> can confirm that the changes are working.
> 
> Cheers
>   Nick

My autotester for mmix-knuth-mmixware cris-axis-linux-gnu cris-axis-elf
running on Debian 9 x86_64 (GNU make 4.1) screams at 63442f6:
...
Setting warning flags = -W -Wall -Wstrict-prototypes -Wmissing-prototypes -Wshadow -Wstack-usage=262144 -Werror
configure: updating cache ./config.cache
checking that generated files are newer than configure... done
configure: creating ./config.status
config.status: creating Makefile
config.status: creating po/Makefile.in
config.status: creating gconfig.h
config.status: executing depfiles commands
config.status: executing libtool commands
config.status: executing default-1 commands
config.status: creating po/POTFILES
config.status: creating po/Makefile
make[2]: *** No rule to make target 'flat_bl.c', needed by 'all'.  Stop.
make[2]: Entering directory '/tmp/hpautotest-binutils/cris-axis-elf/gprof'
make[2]: Leaving directory '/tmp/hpautotest-binutils/cris-axis-elf/gprof'
make[1]: *** [all-gprof] Error 2
Makefile:6185: recipe for target 'all-gprof' failed
make[1]: Leaving directory '/tmp/hpautotest-binutils/cris-axis-elf'
make: *** [all] Error 2
Makefile:850: recipe for target 'all' failed
Comment 13 Szabolcs Nagy 2019-11-15 09:24:14 UTC
i see failures on aarch64* too.

make[1]: Entering directory `/B/gprof'
make[1]: *** No rule to make target `flat_bl.c', needed by `all'.  Stop.
make[1]: Leaving directory `/B/gprof'
make: *** [all-gprof] Error 2
Comment 14 cvs-commit@gcc.gnu.org 2019-11-15 11:53:54 UTC
The master branch has been updated by Nick Clifton <nickc@sourceware.org>:

https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=71d3dc74309599cd9bbdfa17dcfdfd8c406a1093

commit 71d3dc74309599cd9bbdfa17dcfdfd8c406a1093
Author: Nick Clifton <nickc@redhat.com>
Date:   Fri Nov 15 11:52:50 2019 +0000

    Revert previous delta.
    
    	PR 2587
    	* Makefile.am: Revert change from 2019-11-13.
    	* Makefile.in: Regenerate.