bug-make
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Idea of triggering bugs in users' Makefiles


From: David A. Wheeler
Subject: Re: Idea of triggering bugs in users' Makefiles
Date: Fri, 4 Feb 2022 11:43:22 -0500


> On Feb 4, 2022, at 4:13 AM, Sergei Trofimovich <slyich@gmail.com> wrote:
> 
> Individual developers more often than not build large projects
> in parallel to speed the process up with 'make -j <something>'.
> 
> OS distributions would also prefer to enable parallel builds
> by default. But there is a problem of deciding if it's safe
> to build a package in general.
> 
> In small projects developers frequently forget that their
> Makefile might be used in a 'make -j' setting and don't test
> the scenario.
> 
> Recently I attempted to enable 'make -j $(nproc)' instead of
> 'make' for the whole NixOS software collection.
> 
> I found quite a few build failures. Most of them have very easy
> fixes. The good simple example is 'cramfsswap':
> 
>  https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=996964
> 
> There one of the targets uses effect of another target, but does
> not declare it. Contrived example:
> 
>    # Makefile:
>    all: a b
>    a:
>        touch a
>    b:
>        cp a b
> 
> Here 'make all' happens to work, but 'make b' alone does not.
> 
> This made me thinking: what could GNU make do to make these
> types of errors more obvious?

Instead of creating mysterious failures, it might be useful to
have an optional warning flag that enabled looking for & reporting
dependency failures. Using it could make the build run slower
but detect problems not otherwise noted.

For example: When running each recipe, enable tracing
to note when files are opened for reading/writing.
If a recipe opens a file for reading (or presence?), and
that file isn't listed as a dependency but SHOULD be, warn about it.
E.g., "Warning: Recipe for XYZ reads file ABC but
this is not listed as a dependency". My heuristic:
A file should be listed as a dependency if it's
listed as a dependency in the makefile, is in the current
directory or lower, or is in the home directory or lower AND
is not hidden (its basename does not begin with ".").
There would probably need to be some options to control
what "should be listed as a dependency" beyond the default.

If this was added to make, it's fine if the check doesn't run
on all possible architectures. You can run the check on some
widely-used system, and fix the makefile, and then run the makefile
on anything else.

Of course, someone would have to do the work :-).

--- David A. Wheeler




reply via email to

[Prev in Thread] Current Thread [Next in Thread]