[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: GNU make troubleshooting
From: |
Dmitry Goncharov |
Subject: |
Re: GNU make troubleshooting |
Date: |
Sat, 15 Jul 2023 11:28:22 -0400 |
On Mon, Jul 10, 2023 at 2:32 PM Bruno Haible <bruno@clisp.org> wrote:
> I tried -d a couple of times, and it produced a ton of output, that
> was too much for me to make sense of. Probably 10% to 20% of the
> developers in general have trace filtering skills, that is, know how
> to extract the essential information from a heap of output. It's not
> part of my skills.
i added a patch here https://savannah.gnu.org/bugs/index.php?64428
which hopefully clarifies how to extract essential information from
this output.
i'll copy the contents of the patch here, in case there are questions
or suggestions.
regards, Dmitry
Appendix A Debug Output.
This section demonstrates how to simplify make debug output.
Let us consider this very simple makefile.
$ ls
hello.c makefile
$ cat makefile
all: hello
$ make
cc hello.c -o hello
This project consists of one .c file, no headers files a one line makefile.
$ make -d |wc
1338 7558 63584
$
1338 lines of debug output just for this makefile which compiled one
source file. Of course, with multiple source code files this debug
output increases tremendously. This makes reading make debug output
difficult.
There are simple techniques that we can utilize to simplify this
output and extract useful information out of it.
Let us see what this output contains.
$ make -d |head
GNU Make 4.4.90
Built for x86_64-pc-linux-gnu
Copyright (C) 1988-2023 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <https://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.
Reading makefiles...
Reading makefile 'makefile'...
Updating makefiles....
Considering target file 'makefile'.
$
This copyright header can be eliminated with tail +7.
$ make -d |tail +7 |head
Reading makefiles...
Reading makefile 'makefile'...
Updating makefiles....
Considering target file 'makefile'.
Looking for an implicit rule for 'makefile'.
Trying pattern rule '%: %.o' with stem 'makefile'.
Trying implicit prerequisite 'makefile.o'.
Not found 'makefile.o'.
Trying pattern rule '%: %.c' with stem 'makefile'.
Trying implicit prerequisite 'makefile.c'.
$
Upon startup make looks for a rule to update the makefile. (see How
Makefiles Are Remade). This is what the initial portion of this debug
output is about. If we don’t need your makefile to be remade, we can
instruct make to skip this update process.
$ cat makefile
all: hello
makefile::;
$ make -d |tail +7 |wc
730 4101 32848
Note, we added rule
makefile::;
This addition cut the debug output from 1338 to 730 lines.
Let us update this makefile to track dependencies.
$ cat makefile
all: hello
hello: hello.o; $(CC) -o $ $<
hello.o: hello.c hello.d; $(CC) -MMD -MFhello.d -o $ -c $<
hello.d:
include hello.d
makefile::;
$ make -d |tail +7 |wc
1341 7572 63293
We can see tracking of dependencies causes additional work and debug
output. We can simplify this output by providing a recipe for the
’hello.d:’ rule.
$ cat makefile
all: hello
hello: hello.o; $(CC) -o $ $<
hello.o: hello.c hello.d; $(CC) -MMD -MFhello.d -o $ -c $<
hello.d:;
include hello.d
makefile::;
$ make -d |tail +7 |wc
741 4168 33471
Note, we added a semicolon after hello.d:. This empty recipe causes
make to skip implicit search for a rule to build hello.d. This
relieves make from doing redundant work and simplifies debug output.
Finally, we can disable built-in rules Catalogue of Built-In Rules.
$ cat makefile
MAKEFLAGS:=-r
all: hello
hello: hello.o; $(CC) -o $ $<
hello.o: hello.c hello.d; $(CC) -MMD -MFhello.d -o $ -c $<
hello.d:;
include hello.d
makefile::;
$ make -d |tail +7 |wc
47 259 1931
These 47 lines are the ones that we were looking for.
- Re: GNU make troubleshooting, (continued)
- Re: GNU make troubleshooting, Jeffrey Walton, 2023/07/10
- Re: GNU make troubleshooting, Paul Smith, 2023/07/10
- Re: GNU make troubleshooting, Jeffrey Walton, 2023/07/10
- Re: GNU make troubleshooting, Paul Smith, 2023/07/11
- Re: GNU make troubleshooting, Jeffrey Walton, 2023/07/11
- Re: GNU make troubleshooting, Alejandro Colomar, 2023/07/11
- Re: GNU make troubleshooting, Paul Smith, 2023/07/11
Re: GNU make troubleshooting, Eli Zaretskii, 2023/07/10
Re: GNU make troubleshooting,
Dmitry Goncharov <=
- Re: GNU make troubleshooting, Bruno Haible, 2023/07/15
- Re: GNU make troubleshooting, Dmitry Goncharov, 2023/07/15
- Re: GNU make troubleshooting, Bruno Haible, 2023/07/15
- Re: GNU make troubleshooting, David Boyce, 2023/07/15
- Re: GNU make troubleshooting, Dmitry Goncharov, 2023/07/16
- Re: GNU make troubleshooting, Bruno Haible, 2023/07/17
Re: MAKEFLAGS=-r, Bruno Haible, 2023/07/17
Re: MAKEFLAGS=-r, David Boyce, 2023/07/17
Re: MAKEFLAGS=-r, Bruno Haible, 2023/07/17
Re: MAKEFLAGS=-r, David Boyce, 2023/07/17