On 2023-10-05 05:48, Paul Smith wrote: > On Wed, 2023-10-04 at 23:50 -0700, Kaz Kylheku wrote: >> Is there a good reason for that? The manual mentions only >> performance: > > Well, performance is a good reason. But if you're looking for other > reasons I don't know; this behavior predates me. > >> Say that I want to be able to say "make update-host-foo", such that >> Make will run some remote commands on host "foo". For any host name: > > The manual tells you how to do this:
Yes, I re-read that yesterday while looking at this. > | To always rebuild a pattern rule consider using a “force target” (see > | Rules without Recipes or Prerequisites). > >> update-host-%: >> ssh $* some command > > Rewrite as: > > update-host-%: FORCE > ssh $* some command > > FORCE: But the manual also says that it's a hacky simulation of .PHONY that works in Make implementations which don't have it. It will solve the problem that even if update-host-foo exists, "make update-host-foo" will still run the command, which is good. Yet, it's still accessing the filesystem. In the strace output I see: stat64("update-host-foo", 0xbf8e0d5c) = -1 ENOENT (No such file or directory) stat64("FORCE", 0xbf8e0d5c) = -1 ENOENT (No such file or directory) Say, could Make not optimize away useless stat() calls? I wonder what that would take. Basically, it seems that Make could evaluate the target in this order: 1. First, consider whether it's going to update a target due to some forced reason: a) it's a forced target: no prerequisites or build steps. b) the target depends on a forced target. c) it's a .PHONY target (this case is currently handled) In any of these cases, just build the target (or consider it updated, if there is no recipe) without stat(). 2. Otherwise, go ahead and stat() it to see whether it is non-existent or out-of-date. With these rules, the FORCE target trick is pretty much as good as phony, minus the optimization in that implicit rules are ignored for actually .PHONY targets.