Commit 386e7c6
perf(build): resolve pkg-config once at parse time, not once per recipe
CFLAGS is a recursively-expanded variable, so "CFLAGS += $(shell pkg-config
...)" appends the shell call itself rather than its result, and make re-runs it
every time CFLAGS is expanded -- which is once per compile recipe. Three
helpers were wired up that way (gstreamer, libdrm, and GraphicsMagick++-config
on generic-Linux builds), so a build forked them several hundred times to
recompute a string that never changes.
Capture each into a simply-expanded variable and append that instead. The
resulting compile lines are unchanged token for token; only the number of forks
differs.
pkg-config invocations per build 406 -> 3
make -n over a full build, 1-core armhf 11.5s -> 0.9s
make -n over a full build, 4-core aarch64 0.8s -> 0.2s
The cost is paid on every make invocation, so it is proportionally largest on
no-op and incremental builds.
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>1 parent 1f121a3 commit 386e7c6
2 files changed
Lines changed: 17 additions & 4 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
160 | 160 | | |
161 | 161 | | |
162 | 162 | | |
| 163 | + | |
| 164 | + | |
| 165 | + | |
| 166 | + | |
| 167 | + | |
| 168 | + | |
163 | 169 | | |
164 | | - | |
165 | | - | |
| 170 | + | |
| 171 | + | |
| 172 | + | |
| 173 | + | |
166 | 174 | | |
167 | 175 | | |
168 | 176 | | |
169 | 177 | | |
170 | 178 | | |
171 | 179 | | |
172 | | - | |
| 180 | + | |
| 181 | + | |
173 | 182 | | |
174 | 183 | | |
175 | 184 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
35 | 35 | | |
36 | 36 | | |
37 | 37 | | |
38 | | - | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
39 | 43 | | |
40 | 44 | | |
41 | 45 | | |
| |||
0 commit comments