Talk:Dwm

From ArchWiki
Jump to navigation Jump to search

ccache issues

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.

To reproduce:

git clone https://git.suckless.org/dwm
  • Compile normally, once.
$ make
  • Reset the state of the repo.
$ git checkout . && git clean -fd
  • For argument's sake, create an invalid config.h.
$ cp config.def.h config.h
$ echo "#error This should cause compilation to fail!" >> config.h
  • Compile again.
$ make

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 config.h.

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 Makefile).
  • Documenting this pitfall on all of the relevant Suckless pages.
  • Disabling ccache in all of the relevant PKGBUILDs.

CodingKoopa (talk) 18:26, 10 September 2021 (UTC)

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)
This seems like a reasonable conclusion. I will look into improving Arch's documentation of ccache - to put up some warnings as to what the repercussions of enabling it systemwide can be, and/or how to fix it when it misbehaves. - CodingKoopa (talk) 13:21, 13 September 2021 (UTC)