-
Notifications
You must be signed in to change notification settings - Fork 37.7k
build: Disable make builtin rules. #22126
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
Tested on linux. |
With this change applied the output of make -d in regards to target 'all' is the following. Considering target file 'all'. |
What about the dependencies? |
Indeed. This wont work for at least miniupnpc: Building miniupnpc...
make[1]: Entering directory '/tmp/cirrus-ci-build/depends/work/build/x86_64-apple-darwin18/miniupnpc/2.2.2-19f39f7d911'
/bin/sh updateminiupnpcstrings.sh
make[1]: *** No rule to make target 'addr_is_reserved.o', needed by 'libminiupnpc.a'. Stop.
make[1]: *** Waiting for unfinished jobs.... Note that there is also some related discussion in #18821. |
Indeed. |
One thing to consider about unexport of MAKEFLAGS is that it will prevent any flag to be propagated.
This should let the options specified by the user on the command line to propagate. |
Is this related to #22134? |
Sorry, but I'm not convinced this is a worthwhile change. It adds extra settings for a very small gain. Can you at least quantify the performance win? I would not expect much of the build time to be spent in |
I think the potential win here is not w/re performance, but w/re explicitness. I remember struggling with builtin variables and target definitions while working on 3d6603e, and I think being explicit about where we expect to use the builtin vars and targets is a good thing (also for debugging purposes) if it can be done right. |
Performance wise -r helps when there is nothing to be built and your program needs to link a lot of libraries. -r helps each library a little bit. -r helps troubleshooting a lot. E.g. this is the difference in debugging output.
It has been my experience that people get buried in this output and do not realize they can drastically simplify it. |
Not related. |
The following sections might be updated with supplementary metadata relevant to reviewers and maintainers. ConflictsReviewers, this pull request conflicts with the following ones:
If you consider this pull request important, please also help to review the conflicting pull requests. Ideally, start with the one that should be merged first. |
GNU Make says Won't this break that? |
Options specified by the user on the command line are all exported to make's children. |
Concept ACK
@dgoncharov Would be nice to include some illustrative examples in your comments in |
i added a test package here https://github.com/dgoncharov/bitcoin/tree/test_package.
You can then pass various flags and see the output. |
When there is no rule to build a target in the makefile, make looks for a builtin rule. When -r is specified make no longer performs this lookup. E.g. the following in an excerpt from make -d output. Here, make looks for a rule to build 'all'. Considering target file 'all'. File 'all' does not exist. Looking for an implicit rule for 'all'. Trying pattern rule with stem 'all'. Trying implicit prerequisite 'all.o'. Trying pattern rule with stem 'all'. Trying implicit prerequisite 'all.c'. Trying pattern rule with stem 'all'. Trying implicit prerequisite 'all.cc'. Trying pattern rule with stem 'all'. Trying implicit prerequisite 'all.C'. Trying pattern rule with stem 'all'. Trying implicit prerequisite 'all.cpp'. Trying pattern rule with stem 'all'. Trying implicit prerequisite 'all.p'. Trying pattern rule with stem 'all'. Trying implicit prerequisite 'all.f'. ... Many more lines like this are omitted. Because this build system does not use make builtin rules or suffixes, there is no benefit in having builtin rules enabled. There are 2 benefits in having builtin rules disabled. 1. Improves performance by eliminating redundant lookups. 2. Simplifies troubleshooting by reducing the output of make -d or make -p. Implementation notes: Construct mflags to ensure -r is not passed down to children. Some packages use builtin rules. There is no need to handle $ make MAKEFLAGS=<value> use case, because this makefile filters out everything from MAKEOVERRIDES, aside from V=%. If the filtering of MAKEOVERRIDES is removed, then the code which modifies MAKEFLAGS and sets mflags should be conditional e.g. ifeq (,$(filter MAKEFLAGS=%,$(MAKEOVERRIDES))) endif
62ff4c3
to
16f46df
Compare
🐙 This pull request conflicts with the target branch and needs rebase. Want to unsubscribe from rebase notifications on this pull request? Just convert this pull request to a "draft". |
Closing this as it has not had any activity in a while. If you are interested in continuing work on this, please leave a comment so that it can be reopened. |
cc @dongcarl |
Picked up in #33045. |
Disable make builtin rules.
When there is no rule to build a target in the makefile, make looks
for a builtin rule.
When -r is specified make no longer performs this lookup.
E.g. the following in an excerpt from make -d output.
Here, make looks for a rule to build 'all'.
Considering target file 'all'.
File 'all' does not exist.
Looking for an implicit rule for 'all'.
Trying pattern rule with stem 'all'.
Trying implicit prerequisite 'all.o'.
Trying pattern rule with stem 'all'.
Trying implicit prerequisite 'all.c'.
Trying pattern rule with stem 'all'.
Trying implicit prerequisite 'all.cc'.
Trying pattern rule with stem 'all'.
Trying implicit prerequisite 'all.C'.
Trying pattern rule with stem 'all'.
Trying implicit prerequisite 'all.cpp'.
Trying pattern rule with stem 'all'.
Trying implicit prerequisite 'all.p'.
Trying pattern rule with stem 'all'.
Trying implicit prerequisite 'all.f'.
...
Many more lines like this are omitted.
Because this build system does not use make builtin rules or suffixes,
there is no benefit in having builtin rules enabled.
There are 2 benefits in having builtin rules disabled.
make -p.