On Wed, 2026-02-11 at 13:04 +0800, lijh.8 via Users list for the GNU implementation of make wrote: > When there are source and object files added or deleted the ar will > not be triggered, if U is used in ARFLAGS, unless make clean or touch > command is run. If U is not in ARFLAGS, $? is same as $^. Then it > will always be a updated archive by adding the rm -f $@ command.
This is a mis-feature of your ar, and how it was built; there's nothing GNU Make can do about it. I guess, GNU Make could warn about it. There are two options for ar, D and U. "D" is "deterministic mode". In this mode, the archive created by ar doesn't contain any timestamps (or uid/gid etc.) for the objects it holds. This allows the build to be reproducible since it doesn't contain non-reproducible values like timestamps. "U" is non-deterministic mode (e.g., the way ar always worked in the past). In this mode, the archive contains modification timestamps for each object in the archive. When you use the "D" deterministic mode with ar, then GNU Make's archive support cannot work: it doesn't have any information about the modification time of objects in the archive so it cannot determine when they are outdated and need to be updated. Unfortunately, whether you get deterministic or non-deterministic mode by default depends on how your version of ar was compiled. The binutils folks added a configure flag that allows ar to be compiled with either "D" as the default, or "U" (traditional). I think this was a bad idea, but... no one asked me. Even worse, many GNU/Linux distributions elected to build ar the "wrong" way and get the default behavior that doesn't work with GNU Make, rather than leaving the default as-is and changing their build environments to add the "D" option explicitly when they wanted it. Long story short: if you want to use GNU Make's archive support in your makefile, and you are using GNU binutils ar, you need to add the "U" option to your ARFLAGS just in case. As above, there's nothing GNU Make can do about it; you should file a bug with your GNU/Linux distribution (or wherever you get your binutils toolchain). Cheers!
