If ccache and GCC are used to compile dwm (and seemingly any other suckless software - I tested st), then, if
config.h is modified, the cached version of it appears to still be used in subsequent compilations.
- Install and configure ccache as per ccache#Enable for command line.
- Set GCC as the default C compiler - This issue doesn't appear to occur with clang.
- Clone dwm.
git clone https://git.suckless.org/dwm
- Compile normally, once.
- Reset the state of the repo.
$ git checkout . && git clean -fd
- For argument's sake, create an invalid
$ cp config.def.h config.h $ echo "#error This should cause compilation to fail!" >> config.h
- Compile again.
For me, this is the point at which it succeeds, when it shouldn't. If I add a similar error to, say,
dwm.c, only then does it recognize the change made to
The ccache documentation offers a possible explanation for this behavior:
"There is a catch with the direct mode: header files that were used by the compiler are recorded, but header files that were not used, but would have been used if they existed, are not. So, when ccache checks if a result can be taken from the cache, it currently can’t check if the existence of a new header file should invalidate the result. In practice, the direct mode is safe to use in the absolute majority of cases."
Some action should be taken to protect users from this, such as:
- Resolving this somehow upstream (the issue may be resolvable with a patch to the
- Documenting this pitfall on all of the relevant Suckless pages.
- Disabling ccache in all of the relevant PKGBUILDs.
- To me this seems more like an issue of ccache and not so much of dwm. I am not familiar with ccache, but the documentation seems to suggest some ways of handling these cases within ccache, i.e. setting the sloppiness or create the headerfiles earlier. In general I think it would be better to resolve this isssue for ccache in general and not for every single project that uses a config.h . Maybe mention these issues on the ccache page to avoid bloating the suckless pages.
- --Ritka (talk) 12:22, 13 September 2021 (UTC)