Skip to content

build: disable all built-in implicit make rules #5864

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

Merged
merged 3 commits into from
Jun 21, 2023

Conversation

kmk3
Copy link
Collaborator

@kmk3 kmk3 commented Jun 20, 2023

To reduce unnecessary filesystem lookups.

Overall, this appears to reduce the amount of implicit rule searches by ~97.5%
for the default build and by ~99.3% for the "man" target (as an example):

$ git show --pretty='%h %ai %s' -s
a8f01a383 2023-06-20 05:26:23 +0000 Merge pull request #5859 from kmk3/build-remove-retpoline
$ ./configure >/dev/null
$ make clean >/dev/null && make --debug=i -j 4     | grep -F 'Trying implicit' | wc -l
6798
$ make clean >/dev/null && make --debug=i -j 4 man | grep -F 'Trying implicit' | wc -l
1085
# (with the second commit applied)
$ make clean >/dev/null && make --debug=i -j 4     | grep -F 'Trying implicit' | wc -l
2535
$ make clean >/dev/null && make --debug=i -j 4 man | grep -F 'Trying implicit' | wc -l
42
# (with the third commit applied)
$ make clean >/dev/null && make --debug=i -j 4     | grep -F 'Trying implicit' | wc -l
170
$ make clean >/dev/null && make --debug=i -j 4 man | grep -F 'Trying implicit' | wc -l
7

Environment: GNU make 4.4.1-2 on Artix Linux.

Note: According to make(1p) in POSIX.1-2017, "If .SUFFIXES does not have
any prerequisites, the list of known suffixes shall be cleared.", while
"The result of setting MAKEFLAGS in the Makefile is unspecified."

See also commit f48886f ("build: mark most phony targets as such",
2023-02-01) / PR #5637.

Copy link
Collaborator

@glitsj16 glitsj16 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

kmk3 added 2 commits June 21, 2023 12:22
To make the makefiles look more similar.
Clear `.SUFFIXES:` to reduce unnecessary filesystem lookups.

Overall, this appears to reduce the amount of implicit rule searches by
~62% for the default build and by ~96% for the "man" target (as an
example):

    $ git checkout master >/dev/null 2>&1
    $ git show --pretty='%h %ai %s' -s
    a8f01a3 2023-06-20 05:26:23 +0000 Merge pull request netblue30#5859 from kmk3/build-remove-retpoline
    $ ./configure >/dev/null
    $ make clean >/dev/null && make --debug=i -j 4     | grep -F 'Trying implicit' | wc -l
    6798
    $ make clean >/dev/null && make --debug=i -j 4 man | grep -F 'Trying implicit' | wc -l
    1085
    # (with this commit applied)
    $ make clean >/dev/null && make --debug=i -j 4     | grep -F 'Trying implicit' | wc -l
    2535
    $ make clean >/dev/null && make --debug=i -j 4 man | grep -F 'Trying implicit' | wc -l
    42

Environment: GNU make 4.4.1-2 on Artix Linux.

Commands used to search and replace:

    $ git ls-files -z -- '*Makefile*' | xargs -0 -I '{}' sh -c \
      "printf '%s\n' \"\$(sed '1s/^/.SUFFIXES:\n/' '{}')\" >'{}'"

See also commit f48886f ("build: mark most phony targets as such",
2023-02-01) / PR netblue30#5637.
@kmk3 kmk3 force-pushed the build-reduce-implicit branch from 331a434 to cab6811 Compare June 21, 2023 17:08
@kmk3 kmk3 changed the title build: disable most implicit make rules (.SUFFIXES) build: disable all built-in implicit make rules Jun 21, 2023
Use `make -r` to reduce unnecessary filesystem lookups.

Overall, this appears to reduce the amount of implicit rule searches by
~93.3% (~97.5% compared to a8f01a3) for the default build and by
~83.3% (~99.3% compared to a8f01a3) for the "man" target (as an
example):

    $ git show --pretty='%h %ai %s' -s
    a8f01a3 2023-06-20 05:26:23 +0000 Merge pull request netblue30#5859 from kmk3/build-remove-retpoline
    $ ./configure >/dev/null
    $ make clean >/dev/null && make --debug=i -j 4     | grep -F 'Trying implicit' | wc -l
    6798
    $ make clean >/dev/null && make --debug=i -j 4 man | grep -F 'Trying implicit' | wc -l
    1085
    # (in the previous commit)
    $ make clean >/dev/null && make --debug=i -j 4     | grep -F 'Trying implicit' | wc -l
    2535
    $ make clean >/dev/null && make --debug=i -j 4 man | grep -F 'Trying implicit' | wc -l
    42
    # (with this commit applied)
    $ make clean >/dev/null && make --debug=i -j 4     | grep -F 'Trying implicit' | wc -l
    170
    $ make clean >/dev/null && make --debug=i -j 4 man | grep -F 'Trying implicit' | wc -l
    7

Environment: GNU make 4.4.1-2 on Artix Linux.

Note: According to make(1p) in POSIX.1-2017, "If .SUFFIXES does not have
any prerequisites, the list of known suffixes shall be cleared.", while
"The result of setting MAKEFLAGS in the Makefile is unspecified."

Commands used to search and replace:

    $ git ls-files -z -- '*Makefile*' | xargs -0 -I '{}' sh -c \
      "printf '%s\n' \"\$(sed -E \
        's/^(.SUFFIXES:)/\1\nMAKEFLAGS += -r\n/' '{}')\" >'{}'"
@kmk3 kmk3 force-pushed the build-reduce-implicit branch from cab6811 to 9789c26 Compare June 21, 2023 17:21
@kmk3 kmk3 merged commit 1003dee into netblue30:master Jun 21, 2023
@kmk3 kmk3 deleted the build-reduce-implicit branch June 21, 2023 18:46
kmk3 added a commit that referenced this pull request Jun 24, 2023
To reduce the amount of boilerplate in the makefiles.

This amends commit 9789c26 ("build: disable all built-in implicit make
rules", 2023-06-21) / PR #5864.
kmk3 added a commit that referenced this pull request Jun 27, 2023
@kmk3 kmk3 added the enhancement New feature request label Dec 29, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature request
Projects
Status: Done (on RELNOTES)
Development

Successfully merging this pull request may close these issues.

2 participants