See discussion in #1221.
include(CheckFunctionExists)
set(functions
asctime_r
- geteuid
getopt_long
getpwuid
posix_fallocate
// Define if your compiler supports AVX2.
#cmakedefine HAVE_AVX2
-// Define if you have the "geteuid" function.
-#cmakedefine HAVE_GETEUID
-
// Define if you have the "getopt_long" function.
#cmakedefine HAVE_GETOPT_LONG
*temporary_dir* (*CCACHE_TEMPDIR*)::
This option specifies where ccache will put temporary files. The default is
- `/run/user/<UID>/ccache-tmp` if `/run/user/<UID>` exists, otherwise
+ `$XDG_RUNTIME_DIR/ccache-tmp` (typically `/run/user/<UID>/ccache-tmp`) if
+ `XDG_RUNTIME_DIR` is set and the directory exists, otherwise
`<cache_dir>/tmp`.
+
NOTE: In previous versions of ccache, *CCACHE_TEMPDIR* had to be on the same
Config::default_temporary_dir() const
{
static const std::string run_user_tmp_dir = [] {
-#ifdef HAVE_GETEUID
- if (Stat::stat("/run").is_directory()) {
- auto dir = FMT("/run/user/{}/ccache-tmp", geteuid());
+#ifndef _WIN32
+ const char* const xdg_runtime_dir = getenv("XDG_RUNTIME_DIR");
+ if (xdg_runtime_dir && Stat::stat(xdg_runtime_dir).is_directory()) {
+ auto dir = FMT("{}/ccache-tmp", xdg_runtime_dir);
if (Util::create_dir(dir) && access(dir.c_str(), W_OK) == 0) {
return dir;
}