help-make
[Top][All Lists]
Advanced

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

Flag --no-builtin-rules etc. just for this makefile (no flag inheritance


From: R. Diez
Subject: Flag --no-builtin-rules etc. just for this makefile (no flag inheritance)
Date: Sat, 18 Apr 2020 15:27:22 +0200
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.7.0

Hi all:

Over the years, I have become used to specifying the following flags when 
running makefiles:

1) --no-builtin-variables  or manually-written makefiles.

That flag also disables all implicit rules.

The reasons are:

a) Makefiles run much faster if they do not have to check implicit rules.

If implicit rules are active, GNU make seems to look for many different possible source file types when trying to find a suitable rule for each target file. That can trigger many stat syscalls per target file, dramatically slowing down makefiles for large projects.


b) I usually want files to get built in a specific way. If I make a mistake, I want to know straight away, instead of wondering why another compiler has been automatically chosen.


2) Automake-generated makefiles need built-in variables, but they seem to run 
fine with --no-builtin-rules , which also helps run the makefile faster.


3) --warn-undefined-variables , because it helps catch bugs when writing and 
debugging makefiles.


In fact, I believe that the GNU Make documentation should encourage using those 
flags more explicitly.

There is a catch, though: those flags are inherited over environment variable 
MAKEFLAGS. So I have to manually filter them out when calling submakefiles.

I believe that this inheritance is the main reason why other build systems are always so much faster than GNU Make in practice. For example, the OpenWrt build system is a complex makefile. Assuming it could run with --no-builtin-rules , all submakefiles would fail. Therefore, in practice, you cannot easily use --no-builtin-rules in complex makefiles. Keep in mind that you need some inheritance, at least for the job server file descriptors.

If you are the author of a makefile, you may design it to run well with --no-builtin-variables and with --warn-undefined-variables . In fact, you may want to run it always with those flags. But you do not want to pass them to submakefiles, just in case.

Therefore, it would be nice if you could specify those flags as file-level 
directives, like this:

.NO_BUILT_IN_RULES:
.NO_BUILT_IN_VARIABLES:
.WARN_UNDEFINED_VARIABLES:

Or even better:
.ERROR_UNDEFINED_VARIABLES:

Special targets .NOTPARALLEL and .ONESHELL do not inherit either, do they?

You cannot do that with GNU Make at the moment for --no-builtin-variables and 
--warn-undefined-variables, or can you?

Regards,
  rdiez



reply via email to

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