* [Buildroot] [PATCH] package/host-ccache: force use of BR_CACHE_DIR instead of user directories
@ 2026-03-13 11:07 Shubham Chakraborty
2026-03-13 11:07 ` [Buildroot] [PATCH] DEVELOPERS: add Shubham Chakraborty as ccache maintainer Shubham Chakraborty
2026-03-13 17:06 ` [Buildroot] [PATCH] package/host-ccache: force use of BR_CACHE_DIR instead of user directories Fiona Klute via buildroot
0 siblings, 2 replies; 6+ messages in thread
From: Shubham Chakraborty @ 2026-03-13 11:07 UTC (permalink / raw)
To: buildroot; +Cc: Shubham Chakraborty
Override ccache's default cache directory paths to use Buildroot's
BR_CACHE_DIR environment variable instead of CCACHE_DIR and XDG
standard directories.
By default, ccache stores its cache in user home directories
(~/.ccache, ~/.cache/ccache, ~/.config/ccache) based on XDG_CACHE_HOME
and XDG_CONFIG_HOME environment variables. This causes issues in
Buildroot because:
- Pollutes user home directories during builds
- Breaks reproducibility across different build environments
- Complicates cache management in CI/CD systems
- May cause permission issues in shared build systems
This patch modifies ccache source to:
- Replace util::getenv_path("CCACHE_DIR") with "BR_CACHE_DIR"
- Replace hardcoded paths (.ccache, .cache/ccache, .config/ccache)
with Buildroot's HOST_CCACHE_DEFAULT_CCACHE_DIR
- Disable XDG_CACHE_HOME, XDG_CONFIG_HOME, and XDG_RUNTIME_DIR lookups
- Update command-line option handling to use BR_CACHE_DIR
This ensures ccache respects Buildroot's cache directory configuration
and avoids user home directory pollution.
Signed-off-by: Shubham Chakraborty <chakrabortyshubham66@gmail.com>
---
...ost-ccache-force-use-of-BR_CACHE_DIR.patch | 108 ++++++++++++++++++
package/ccache/ccache.mk | 11 +-
2 files changed, 110 insertions(+), 9 deletions(-)
create mode 100644 package/ccache/0001-package-host-ccache-force-use-of-BR_CACHE_DIR.patch
diff --git a/package/ccache/0001-package-host-ccache-force-use-of-BR_CACHE_DIR.patch b/package/ccache/0001-package-host-ccache-force-use-of-BR_CACHE_DIR.patch
new file mode 100644
index 0000000000..a990c43dd2
--- /dev/null
+++ b/package/ccache/0001-package-host-ccache-force-use-of-BR_CACHE_DIR.patch
@@ -0,0 +1,108 @@
+From 5140c64cdd2d469ff5be7f94cc11de928cbe585a Mon Sep 17 00:00:00 2001
+From: Shubham Chakraborty <chakrabortyshubham66@gmail.com>
+Date: Fri, 13 Mar 2026 15:38:53 +0530
+Subject: [PATCH] package/host-ccache: force use of BR_CACHE_DIR.
+
+Override ccache's default cache directory paths to use Buildroot's
+BR_CACHE_DIR environment variable instead of CCACHE_DIR and XDG
+standard directories.
+
+By default, ccache stores its cache in user home directories
+(~/.ccache, ~/.cache/ccache, ~/.config/ccache) based on XDG_CACHE_HOME
+and XDG_CONFIG_HOME environment variables. This causes issues in
+Buildroot because:
+
+ - Pollutes user home directories during builds
+ - Breaks reproducibility across different build environments
+ - Complicates cache management in CI/CD systems
+ - May cause permission issues in shared build systems
+
+This patch modifies ccache source to:
+ - Replace util::getenv_path("CCACHE_DIR") with "BR_CACHE_DIR"
+ - Replace hardcoded paths (.ccache, .cache/ccache, .config/ccache)
+ with Buildroot's HOST_CCACHE_DEFAULT_CCACHE_DIR
+ - Disable XDG_CACHE_HOME, XDG_CONFIG_HOME, and XDG_RUNTIME_DIR lookups
+ - Update command-line option handling to use BR_CACHE_DIR
+
+This ensures ccache respects Buildroot's cache directory configuration
+and avoids user home directory pollution.
+
+Signed-off-by: Shubham Chakraborty <chakrabortyshubham66@gmail.com>
+---
+ src/ccache/config.cpp | 14 +++++++-------
+ src/ccache/core/mainoptions.cpp | 2 +-
+ 2 files changed, 8 insertions(+), 8 deletions(-)
+
+diff --git a/src/ccache/config.cpp b/src/ccache/config.cpp
+index a4f67d8..1a6e130 100644
+--- a/src/ccache/config.cpp
++++ b/src/ccache/config.cpp
+@@ -500,7 +500,7 @@ default_cache_dir(const fs::path& home_dir)
+ # ifdef __APPLE__
+ return home_dir / "Library/Caches/ccache";
+ # else
+- return home_dir / ".cache/ccache";
++ return home_dir / HOST_CCACHE_DEFAULT_CCACHE_DIR;
+ # endif
+ }
+
+@@ -510,7 +510,7 @@ default_config_dir(const fs::path& home_dir)
+ # ifdef __APPLE__
+ return home_dir / "Library/Preferences/ccache";
+ # else
+- return home_dir / ".config/ccache";
++ return home_dir / HOST_CCACHE_DEFAULT_CCACHE_DIR;
+ # endif
+ }
+
+@@ -598,13 +598,13 @@ Config::read(const std::vector<std::string>& cmdline_config_settings)
+ create_cmdline_settings_map(cmdline_config_settings);
+
+ const fs::path home_dir = home_directory();
+- const util::DirEntry legacy_ccache_dir = home_dir / ".ccache";
++ const util::DirEntry legacy_ccache_dir = home_dir / HOST_CCACHE_DEFAULT_CCACHE_DIR;
+ #ifdef _WIN32
+ auto env_appdata = util::getenv_path("APPDATA");
+ auto env_local_appdata = util::getenv_path("LOCALAPPDATA");
+ #else
+- auto env_xdg_cache_home = util::getenv_path("XDG_CACHE_HOME");
+- auto env_xdg_config_home = util::getenv_path("XDG_CONFIG_HOME");
++ auto env_xdg_cache_home = std::optional<fs::path>(std::nullopt);
++ auto env_xdg_config_home = std::optional<fs::path>(std::nullopt);
+ #endif
+
+ auto env_ccache_configpath = util::getenv_path("CCACHE_CONFIGPATH");
+@@ -627,7 +627,7 @@ Config::read(const std::vector<std::string>& cmdline_config_settings)
+ // A missing config file in SYSCONFDIR is OK so don't check return value.
+ update_from_file(system_config_path());
+
+- auto env_ccache_dir = util::getenv_path("CCACHE_DIR");
++ auto env_ccache_dir = util::getenv_path("BR_CACHE_DIR");
+ auto cmdline_cache_dir = cmdline_settings_map.find("cache_dir");
+
+ fs::path config_dir;
+@@ -1232,7 +1232,7 @@ Config::default_temporary_dir() const
+ {
+ static const fs::path run_user_tmp_dir = [] {
+ #ifndef _WIN32
+- const char* const xdg_runtime_dir = getenv("XDG_RUNTIME_DIR");
++ const char* const xdg_runtime_dir = nullptr;
+ if (xdg_runtime_dir && DirEntry(xdg_runtime_dir).is_directory()) {
+ fs::path dir = FMT("{}/ccache-tmp", xdg_runtime_dir);
+ if (fs::create_directories(dir) && access(dir.c_str(), W_OK) == 0) {
+diff --git a/src/ccache/core/mainoptions.cpp b/src/ccache/core/mainoptions.cpp
+index d253ebc..9ad2824 100644
+--- a/src/ccache/core/mainoptions.cpp
++++ b/src/ccache/core/mainoptions.cpp
+@@ -527,7 +527,7 @@ process_main_options(int argc, const char* const* argv)
+
+ switch (c) {
+ case 'd': // --dir
+- util::setenv("CCACHE_DIR", arg);
++ util::setenv("BR_CACHE_DIR", arg);
+ break;
+ case FORMAT:
+ if (arg == "tab") {
+--
+2.53.0
+
diff --git a/package/ccache/ccache.mk b/package/ccache/ccache.mk
index 30f87f7d90..f2f73a115d 100644
--- a/package/ccache/ccache.mk
+++ b/package/ccache/ccache.mk
@@ -42,16 +42,9 @@ HOST_CCACHE_CONF_OPTS += \
# so rewrite BR_CACHE_DIR to take that into consideration for SDK purpose
HOST_CCACHE_DEFAULT_CCACHE_DIR = $(patsubst $(HOME)/%,%,$(BR_CACHE_DIR))
-define HOST_CCACHE_PATCH_CONFIGURATION
- sed -i 's,getenv("CCACHE_DIR"),getenv("BR_CACHE_DIR"),' $(@D)/src/ccache/config.cpp
- sed -i 's,".ccache","$(HOST_CCACHE_DEFAULT_CCACHE_DIR)",' $(@D)/src/ccache/config.cpp
- sed -i 's,"/.cache/ccache","/$(HOST_CCACHE_DEFAULT_CCACHE_DIR)",' $(@D)/src/ccache/config.cpp
- sed -i 's,"/.config/ccache","/$(HOST_CCACHE_DEFAULT_CCACHE_DIR)",' $(@D)/src/ccache/config.cpp
- sed -i 's,getenv("XDG_CACHE_HOME"),nullptr,' $(@D)/src/ccache/config.cpp
- sed -i 's,getenv("XDG_CONFIG_HOME"),nullptr,' $(@D)/src/ccache/config.cpp
-endef
+HOST_CCACHE_CONF_OPTS += \
+ -DCMAKE_CXX_FLAGS='$(HOST_CXXFLAGS) -DHOST_CCACHE_DEFAULT_CCACHE_DIR=\"$(HOST_CCACHE_DEFAULT_CCACHE_DIR)\"'
-HOST_CCACHE_POST_PATCH_HOOKS += HOST_CCACHE_PATCH_CONFIGURATION
define HOST_CCACHE_MAKE_CACHE_DIR
mkdir -p $(BR_CACHE_DIR)
--
2.53.0
_______________________________________________
buildroot mailing list
buildroot@buildroot.org
https://lists.buildroot.org/mailman/listinfo/buildroot
^ permalink raw reply related [flat|nested] 6+ messages in thread* [Buildroot] [PATCH] DEVELOPERS: add Shubham Chakraborty as ccache maintainer 2026-03-13 11:07 [Buildroot] [PATCH] package/host-ccache: force use of BR_CACHE_DIR instead of user directories Shubham Chakraborty @ 2026-03-13 11:07 ` Shubham Chakraborty 2026-03-27 20:33 ` Julien Olivain via buildroot 2026-04-03 10:28 ` Thomas Perale via buildroot 2026-03-13 17:06 ` [Buildroot] [PATCH] package/host-ccache: force use of BR_CACHE_DIR instead of user directories Fiona Klute via buildroot 1 sibling, 2 replies; 6+ messages in thread From: Shubham Chakraborty @ 2026-03-13 11:07 UTC (permalink / raw) To: buildroot; +Cc: Shubham Chakraborty Signed-off-by: Shubham Chakraborty <chakrabortyshubham66@gmail.com> --- DEVELOPERS | 3 +++ 1 file changed, 3 insertions(+) diff --git a/DEVELOPERS b/DEVELOPERS index ba6ba6b221..124f5dca4e 100644 --- a/DEVELOPERS +++ b/DEVELOPERS @@ -3025,6 +3025,9 @@ F: package/tunctl/ F: package/ubus/ F: package/wolfssl/ +N: Shubham Chakraborty <chakrabortyshubham66@gmail.com> +F: package/ccache + N: Simon Dawson <spdawson@gmail.com> F: boot/at91bootstrap3/ F: package/cppzmq/ -- 2.53.0 _______________________________________________ buildroot mailing list buildroot@buildroot.org https://lists.buildroot.org/mailman/listinfo/buildroot ^ permalink raw reply related [flat|nested] 6+ messages in thread
* Re: [Buildroot] [PATCH] DEVELOPERS: add Shubham Chakraborty as ccache maintainer 2026-03-13 11:07 ` [Buildroot] [PATCH] DEVELOPERS: add Shubham Chakraborty as ccache maintainer Shubham Chakraborty @ 2026-03-27 20:33 ` Julien Olivain via buildroot 2026-04-03 10:28 ` Thomas Perale via buildroot 1 sibling, 0 replies; 6+ messages in thread From: Julien Olivain via buildroot @ 2026-03-27 20:33 UTC (permalink / raw) To: Shubham Chakraborty; +Cc: buildroot On 13/03/2026 12:07, Shubham Chakraborty wrote: > Signed-off-by: Shubham Chakraborty <chakrabortyshubham66@gmail.com> Applied to master, thanks. _______________________________________________ buildroot mailing list buildroot@buildroot.org https://lists.buildroot.org/mailman/listinfo/buildroot ^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [Buildroot] [PATCH] DEVELOPERS: add Shubham Chakraborty as ccache maintainer 2026-03-13 11:07 ` [Buildroot] [PATCH] DEVELOPERS: add Shubham Chakraborty as ccache maintainer Shubham Chakraborty 2026-03-27 20:33 ` Julien Olivain via buildroot @ 2026-04-03 10:28 ` Thomas Perale via buildroot 1 sibling, 0 replies; 6+ messages in thread From: Thomas Perale via buildroot @ 2026-04-03 10:28 UTC (permalink / raw) To: Shubham Chakraborty; +Cc: Thomas Perale, buildroot In reply of: > Signed-off-by: Shubham Chakraborty <chakrabortyshubham66@gmail.com> Applied to 2025.02.x & 2026.02.x. Thanks > --- > DEVELOPERS | 3 +++ > 1 file changed, 3 insertions(+) > > diff --git a/DEVELOPERS b/DEVELOPERS > index ba6ba6b221..124f5dca4e 100644 > --- a/DEVELOPERS > +++ b/DEVELOPERS > @@ -3025,6 +3025,9 @@ F: package/tunctl/ > F: package/ubus/ > F: package/wolfssl/ > > +N: Shubham Chakraborty <chakrabortyshubham66@gmail.com> > +F: package/ccache > + > N: Simon Dawson <spdawson@gmail.com> > F: boot/at91bootstrap3/ > F: package/cppzmq/ > -- > 2.53.0 > > _______________________________________________ > buildroot mailing list > buildroot@buildroot.org > https://lists.buildroot.org/mailman/listinfo/buildroot _______________________________________________ buildroot mailing list buildroot@buildroot.org https://lists.buildroot.org/mailman/listinfo/buildroot ^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [Buildroot] [PATCH] package/host-ccache: force use of BR_CACHE_DIR instead of user directories 2026-03-13 11:07 [Buildroot] [PATCH] package/host-ccache: force use of BR_CACHE_DIR instead of user directories Shubham Chakraborty 2026-03-13 11:07 ` [Buildroot] [PATCH] DEVELOPERS: add Shubham Chakraborty as ccache maintainer Shubham Chakraborty @ 2026-03-13 17:06 ` Fiona Klute via buildroot 2026-03-13 17:21 ` Shubham Chakraborty 1 sibling, 1 reply; 6+ messages in thread From: Fiona Klute via buildroot @ 2026-03-13 17:06 UTC (permalink / raw) To: Shubham Chakraborty, buildroot Am 13.03.26 um 13:07 schrieb Shubham Chakraborty: > Override ccache's default cache directory paths to use Buildroot's > BR_CACHE_DIR environment variable instead of CCACHE_DIR and XDG > standard directories. > > By default, ccache stores its cache in user home directories > (~/.ccache, ~/.cache/ccache, ~/.config/ccache) based on XDG_CACHE_HOME > and XDG_CONFIG_HOME environment variables. This causes issues in > Buildroot because: > > - Pollutes user home directories during builds > - Breaks reproducibility across different build environments > - Complicates cache management in CI/CD systems > - May cause permission issues in shared build systems Under what circumstances can these issues appear? I've done many Buildroot builds with CCache enabled and haven't encountered any of them. HOST_CCACHE_PATCH_CONFIGURATION should already be doing what you describe as the purpose of the new patch, if that's not working understanding why seems important. Best regards, Fiona > This patch modifies ccache source to: > - Replace util::getenv_path("CCACHE_DIR") with "BR_CACHE_DIR" > - Replace hardcoded paths (.ccache, .cache/ccache, .config/ccache) > with Buildroot's HOST_CCACHE_DEFAULT_CCACHE_DIR > - Disable XDG_CACHE_HOME, XDG_CONFIG_HOME, and XDG_RUNTIME_DIR lookups > - Update command-line option handling to use BR_CACHE_DIR > > This ensures ccache respects Buildroot's cache directory configuration > and avoids user home directory pollution. > > Signed-off-by: Shubham Chakraborty <chakrabortyshubham66@gmail.com> > --- > ...ost-ccache-force-use-of-BR_CACHE_DIR.patch | 108 ++++++++++++++++++ > package/ccache/ccache.mk | 11 +- > 2 files changed, 110 insertions(+), 9 deletions(-) > create mode 100644 package/ccache/0001-package-host-ccache-force-use-of-BR_CACHE_DIR.patch > > diff --git a/package/ccache/0001-package-host-ccache-force-use-of-BR_CACHE_DIR.patch b/package/ccache/0001-package-host-ccache-force-use-of-BR_CACHE_DIR.patch > new file mode 100644 > index 0000000000..a990c43dd2 > --- /dev/null > +++ b/package/ccache/0001-package-host-ccache-force-use-of-BR_CACHE_DIR.patch > @@ -0,0 +1,108 @@ > +From 5140c64cdd2d469ff5be7f94cc11de928cbe585a Mon Sep 17 00:00:00 2001 > +From: Shubham Chakraborty <chakrabortyshubham66@gmail.com> > +Date: Fri, 13 Mar 2026 15:38:53 +0530 > +Subject: [PATCH] package/host-ccache: force use of BR_CACHE_DIR. > + > +Override ccache's default cache directory paths to use Buildroot's > +BR_CACHE_DIR environment variable instead of CCACHE_DIR and XDG > +standard directories. > + > +By default, ccache stores its cache in user home directories > +(~/.ccache, ~/.cache/ccache, ~/.config/ccache) based on XDG_CACHE_HOME > +and XDG_CONFIG_HOME environment variables. This causes issues in > +Buildroot because: > + > + - Pollutes user home directories during builds > + - Breaks reproducibility across different build environments > + - Complicates cache management in CI/CD systems > + - May cause permission issues in shared build systems > + > +This patch modifies ccache source to: > + - Replace util::getenv_path("CCACHE_DIR") with "BR_CACHE_DIR" > + - Replace hardcoded paths (.ccache, .cache/ccache, .config/ccache) > + with Buildroot's HOST_CCACHE_DEFAULT_CCACHE_DIR > + - Disable XDG_CACHE_HOME, XDG_CONFIG_HOME, and XDG_RUNTIME_DIR lookups > + - Update command-line option handling to use BR_CACHE_DIR > + > +This ensures ccache respects Buildroot's cache directory configuration > +and avoids user home directory pollution. > + > +Signed-off-by: Shubham Chakraborty <chakrabortyshubham66@gmail.com> > +--- > + src/ccache/config.cpp | 14 +++++++------- > + src/ccache/core/mainoptions.cpp | 2 +- > + 2 files changed, 8 insertions(+), 8 deletions(-) > + > +diff --git a/src/ccache/config.cpp b/src/ccache/config.cpp > +index a4f67d8..1a6e130 100644 > +--- a/src/ccache/config.cpp > ++++ b/src/ccache/config.cpp > +@@ -500,7 +500,7 @@ default_cache_dir(const fs::path& home_dir) > + # ifdef __APPLE__ > + return home_dir / "Library/Caches/ccache"; > + # else > +- return home_dir / ".cache/ccache"; > ++ return home_dir / HOST_CCACHE_DEFAULT_CCACHE_DIR; > + # endif > + } > + > +@@ -510,7 +510,7 @@ default_config_dir(const fs::path& home_dir) > + # ifdef __APPLE__ > + return home_dir / "Library/Preferences/ccache"; > + # else > +- return home_dir / ".config/ccache"; > ++ return home_dir / HOST_CCACHE_DEFAULT_CCACHE_DIR; > + # endif > + } > + > +@@ -598,13 +598,13 @@ Config::read(const std::vector<std::string>& cmdline_config_settings) > + create_cmdline_settings_map(cmdline_config_settings); > + > + const fs::path home_dir = home_directory(); > +- const util::DirEntry legacy_ccache_dir = home_dir / ".ccache"; > ++ const util::DirEntry legacy_ccache_dir = home_dir / HOST_CCACHE_DEFAULT_CCACHE_DIR; > + #ifdef _WIN32 > + auto env_appdata = util::getenv_path("APPDATA"); > + auto env_local_appdata = util::getenv_path("LOCALAPPDATA"); > + #else > +- auto env_xdg_cache_home = util::getenv_path("XDG_CACHE_HOME"); > +- auto env_xdg_config_home = util::getenv_path("XDG_CONFIG_HOME"); > ++ auto env_xdg_cache_home = std::optional<fs::path>(std::nullopt); > ++ auto env_xdg_config_home = std::optional<fs::path>(std::nullopt); > + #endif > + > + auto env_ccache_configpath = util::getenv_path("CCACHE_CONFIGPATH"); > +@@ -627,7 +627,7 @@ Config::read(const std::vector<std::string>& cmdline_config_settings) > + // A missing config file in SYSCONFDIR is OK so don't check return value. > + update_from_file(system_config_path()); > + > +- auto env_ccache_dir = util::getenv_path("CCACHE_DIR"); > ++ auto env_ccache_dir = util::getenv_path("BR_CACHE_DIR"); > + auto cmdline_cache_dir = cmdline_settings_map.find("cache_dir"); > + > + fs::path config_dir; > +@@ -1232,7 +1232,7 @@ Config::default_temporary_dir() const > + { > + static const fs::path run_user_tmp_dir = [] { > + #ifndef _WIN32 > +- const char* const xdg_runtime_dir = getenv("XDG_RUNTIME_DIR"); > ++ const char* const xdg_runtime_dir = nullptr; > + if (xdg_runtime_dir && DirEntry(xdg_runtime_dir).is_directory()) { > + fs::path dir = FMT("{}/ccache-tmp", xdg_runtime_dir); > + if (fs::create_directories(dir) && access(dir.c_str(), W_OK) == 0) { > +diff --git a/src/ccache/core/mainoptions.cpp b/src/ccache/core/mainoptions.cpp > +index d253ebc..9ad2824 100644 > +--- a/src/ccache/core/mainoptions.cpp > ++++ b/src/ccache/core/mainoptions.cpp > +@@ -527,7 +527,7 @@ process_main_options(int argc, const char* const* argv) > + > + switch (c) { > + case 'd': // --dir > +- util::setenv("CCACHE_DIR", arg); > ++ util::setenv("BR_CACHE_DIR", arg); > + break; > + case FORMAT: > + if (arg == "tab") { > +-- > +2.53.0 > + > diff --git a/package/ccache/ccache.mk b/package/ccache/ccache.mk > index 30f87f7d90..f2f73a115d 100644 > --- a/package/ccache/ccache.mk > +++ b/package/ccache/ccache.mk > @@ -42,16 +42,9 @@ HOST_CCACHE_CONF_OPTS += \ > # so rewrite BR_CACHE_DIR to take that into consideration for SDK purpose > HOST_CCACHE_DEFAULT_CCACHE_DIR = $(patsubst $(HOME)/%,%,$(BR_CACHE_DIR)) > > -define HOST_CCACHE_PATCH_CONFIGURATION > - sed -i 's,getenv("CCACHE_DIR"),getenv("BR_CACHE_DIR"),' $(@D)/src/ccache/config.cpp > - sed -i 's,".ccache","$(HOST_CCACHE_DEFAULT_CCACHE_DIR)",' $(@D)/src/ccache/config.cpp > - sed -i 's,"/.cache/ccache","/$(HOST_CCACHE_DEFAULT_CCACHE_DIR)",' $(@D)/src/ccache/config.cpp > - sed -i 's,"/.config/ccache","/$(HOST_CCACHE_DEFAULT_CCACHE_DIR)",' $(@D)/src/ccache/config.cpp > - sed -i 's,getenv("XDG_CACHE_HOME"),nullptr,' $(@D)/src/ccache/config.cpp > - sed -i 's,getenv("XDG_CONFIG_HOME"),nullptr,' $(@D)/src/ccache/config.cpp > -endef > +HOST_CCACHE_CONF_OPTS += \ > + -DCMAKE_CXX_FLAGS='$(HOST_CXXFLAGS) -DHOST_CCACHE_DEFAULT_CCACHE_DIR=\"$(HOST_CCACHE_DEFAULT_CCACHE_DIR)\"' > > -HOST_CCACHE_POST_PATCH_HOOKS += HOST_CCACHE_PATCH_CONFIGURATION > > define HOST_CCACHE_MAKE_CACHE_DIR > mkdir -p $(BR_CACHE_DIR) _______________________________________________ buildroot mailing list buildroot@buildroot.org https://lists.buildroot.org/mailman/listinfo/buildroot ^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [Buildroot] [PATCH] package/host-ccache: force use of BR_CACHE_DIR instead of user directories 2026-03-13 17:06 ` [Buildroot] [PATCH] package/host-ccache: force use of BR_CACHE_DIR instead of user directories Fiona Klute via buildroot @ 2026-03-13 17:21 ` Shubham Chakraborty 0 siblings, 0 replies; 6+ messages in thread From: Shubham Chakraborty @ 2026-03-13 17:21 UTC (permalink / raw) To: Fiona Klute; +Cc: buildroot [-- Attachment #1.1: Type: text/plain, Size: 9817 bytes --] Hi Fiona, Thank you for the review and for raising this important point. You're absolutely correct - the existing HOST_CCACHE_PATCH_CONFIGURATION approach does work and achieves the same functional goal. This patch is primarily a maintainability improvement rather than fixing a specific bug. My rationale for proposing this change was: 1. *Maintainability*: A proper patch file is easier to maintain across ccache version updates than runtime sed commands, which can silently break if the source code structure changes. 2. *Transparency*: Having the modifications as a formal patch file makes the changes more visible and reviewable. 3. *Potential upstream path*: A well-formed patch could potentially be submitted upstream to ccache with a Buildroot-specific configuration option. However, if the current sed-based approach is working well and is the preferred method by the Buildroot maintainers, I'm happy to withdraw this patch. I don't want to introduce unnecessary churn if the existing solution is adequate. Please let me know your preference. If you'd like me to proceed, I can add more context to the commit message explaining the maintenance benefits. Otherwise, I'll withdraw the patch. Best regards, Shubham On Fri, 13 Mar, 2026, 10:36 pm Fiona Klute, <fiona.klute@gmx.de> wrote: > Am 13.03.26 um 13:07 schrieb Shubham Chakraborty: > > Override ccache's default cache directory paths to use Buildroot's > > BR_CACHE_DIR environment variable instead of CCACHE_DIR and XDG > > standard directories. > > > > By default, ccache stores its cache in user home directories > > (~/.ccache, ~/.cache/ccache, ~/.config/ccache) based on XDG_CACHE_HOME > > and XDG_CONFIG_HOME environment variables. This causes issues in > > Buildroot because: > > > > - Pollutes user home directories during builds > > - Breaks reproducibility across different build environments > > - Complicates cache management in CI/CD systems > > - May cause permission issues in shared build systems > > Under what circumstances can these issues appear? I've done many > Buildroot builds with CCache enabled and haven't encountered any of > them. HOST_CCACHE_PATCH_CONFIGURATION should already be doing what you > describe as the purpose of the new patch, if that's not working > understanding why seems important. > > Best regards, > Fiona > > > This patch modifies ccache source to: > > - Replace util::getenv_path("CCACHE_DIR") with "BR_CACHE_DIR" > > - Replace hardcoded paths (.ccache, .cache/ccache, .config/ccache) > > with Buildroot's HOST_CCACHE_DEFAULT_CCACHE_DIR > > - Disable XDG_CACHE_HOME, XDG_CONFIG_HOME, and XDG_RUNTIME_DIR lookups > > - Update command-line option handling to use BR_CACHE_DIR > > > > This ensures ccache respects Buildroot's cache directory configuration > > and avoids user home directory pollution. > > > > Signed-off-by: Shubham Chakraborty <chakrabortyshubham66@gmail.com> > > --- > > ...ost-ccache-force-use-of-BR_CACHE_DIR.patch | 108 ++++++++++++++++++ > > package/ccache/ccache.mk | 11 +- > > 2 files changed, 110 insertions(+), 9 deletions(-) > > create mode 100644 > package/ccache/0001-package-host-ccache-force-use-of-BR_CACHE_DIR.patch > > > > diff --git > a/package/ccache/0001-package-host-ccache-force-use-of-BR_CACHE_DIR.patch > b/package/ccache/0001-package-host-ccache-force-use-of-BR_CACHE_DIR.patch > > new file mode 100644 > > index 0000000000..a990c43dd2 > > --- /dev/null > > +++ > b/package/ccache/0001-package-host-ccache-force-use-of-BR_CACHE_DIR.patch > > @@ -0,0 +1,108 @@ > > +From 5140c64cdd2d469ff5be7f94cc11de928cbe585a Mon Sep 17 00:00:00 2001 > > +From: Shubham Chakraborty <chakrabortyshubham66@gmail.com> > > +Date: Fri, 13 Mar 2026 15:38:53 +0530 > > +Subject: [PATCH] package/host-ccache: force use of BR_CACHE_DIR. > > + > > +Override ccache's default cache directory paths to use Buildroot's > > +BR_CACHE_DIR environment variable instead of CCACHE_DIR and XDG > > +standard directories. > > + > > +By default, ccache stores its cache in user home directories > > +(~/.ccache, ~/.cache/ccache, ~/.config/ccache) based on XDG_CACHE_HOME > > +and XDG_CONFIG_HOME environment variables. This causes issues in > > +Buildroot because: > > + > > + - Pollutes user home directories during builds > > + - Breaks reproducibility across different build environments > > + - Complicates cache management in CI/CD systems > > + - May cause permission issues in shared build systems > > + > > +This patch modifies ccache source to: > > + - Replace util::getenv_path("CCACHE_DIR") with "BR_CACHE_DIR" > > + - Replace hardcoded paths (.ccache, .cache/ccache, .config/ccache) > > + with Buildroot's HOST_CCACHE_DEFAULT_CCACHE_DIR > > + - Disable XDG_CACHE_HOME, XDG_CONFIG_HOME, and XDG_RUNTIME_DIR lookups > > + - Update command-line option handling to use BR_CACHE_DIR > > + > > +This ensures ccache respects Buildroot's cache directory configuration > > +and avoids user home directory pollution. > > + > > +Signed-off-by: Shubham Chakraborty <chakrabortyshubham66@gmail.com> > > +--- > > + src/ccache/config.cpp | 14 +++++++------- > > + src/ccache/core/mainoptions.cpp | 2 +- > > + 2 files changed, 8 insertions(+), 8 deletions(-) > > + > > +diff --git a/src/ccache/config.cpp b/src/ccache/config.cpp > > +index a4f67d8..1a6e130 100644 > > +--- a/src/ccache/config.cpp > > ++++ b/src/ccache/config.cpp > > +@@ -500,7 +500,7 @@ default_cache_dir(const fs::path& home_dir) > > + # ifdef __APPLE__ > > + return home_dir / "Library/Caches/ccache"; > > + # else > > +- return home_dir / ".cache/ccache"; > > ++ return home_dir / HOST_CCACHE_DEFAULT_CCACHE_DIR; > > + # endif > > + } > > + > > +@@ -510,7 +510,7 @@ default_config_dir(const fs::path& home_dir) > > + # ifdef __APPLE__ > > + return home_dir / "Library/Preferences/ccache"; > > + # else > > +- return home_dir / ".config/ccache"; > > ++ return home_dir / HOST_CCACHE_DEFAULT_CCACHE_DIR; > > + # endif > > + } > > + > > +@@ -598,13 +598,13 @@ Config::read(const std::vector<std::string>& > cmdline_config_settings) > > + create_cmdline_settings_map(cmdline_config_settings); > > + > > + const fs::path home_dir = home_directory(); > > +- const util::DirEntry legacy_ccache_dir = home_dir / ".ccache"; > > ++ const util::DirEntry legacy_ccache_dir = home_dir / > HOST_CCACHE_DEFAULT_CCACHE_DIR; > > + #ifdef _WIN32 > > + auto env_appdata = util::getenv_path("APPDATA"); > > + auto env_local_appdata = util::getenv_path("LOCALAPPDATA"); > > + #else > > +- auto env_xdg_cache_home = util::getenv_path("XDG_CACHE_HOME"); > > +- auto env_xdg_config_home = util::getenv_path("XDG_CONFIG_HOME"); > > ++ auto env_xdg_cache_home = std::optional<fs::path>(std::nullopt); > > ++ auto env_xdg_config_home = std::optional<fs::path>(std::nullopt); > > + #endif > > + > > + auto env_ccache_configpath = util::getenv_path("CCACHE_CONFIGPATH"); > > +@@ -627,7 +627,7 @@ Config::read(const std::vector<std::string>& > cmdline_config_settings) > > + // A missing config file in SYSCONFDIR is OK so don't check return > value. > > + update_from_file(system_config_path()); > > + > > +- auto env_ccache_dir = util::getenv_path("CCACHE_DIR"); > > ++ auto env_ccache_dir = util::getenv_path("BR_CACHE_DIR"); > > + auto cmdline_cache_dir = cmdline_settings_map.find("cache_dir"); > > + > > + fs::path config_dir; > > +@@ -1232,7 +1232,7 @@ Config::default_temporary_dir() const > > + { > > + static const fs::path run_user_tmp_dir = [] { > > + #ifndef _WIN32 > > +- const char* const xdg_runtime_dir = getenv("XDG_RUNTIME_DIR"); > > ++ const char* const xdg_runtime_dir = nullptr; > > + if (xdg_runtime_dir && DirEntry(xdg_runtime_dir).is_directory()) { > > + fs::path dir = FMT("{}/ccache-tmp", xdg_runtime_dir); > > + if (fs::create_directories(dir) && access(dir.c_str(), W_OK) == > 0) { > > +diff --git a/src/ccache/core/mainoptions.cpp > b/src/ccache/core/mainoptions.cpp > > +index d253ebc..9ad2824 100644 > > +--- a/src/ccache/core/mainoptions.cpp > > ++++ b/src/ccache/core/mainoptions.cpp > > +@@ -527,7 +527,7 @@ process_main_options(int argc, const char* const* > argv) > > + > > + switch (c) { > > + case 'd': // --dir > > +- util::setenv("CCACHE_DIR", arg); > > ++ util::setenv("BR_CACHE_DIR", arg); > > + break; > > + case FORMAT: > > + if (arg == "tab") { > > +-- > > +2.53.0 > > + > > diff --git a/package/ccache/ccache.mk b/package/ccache/ccache.mk > > index 30f87f7d90..f2f73a115d 100644 > > --- a/package/ccache/ccache.mk > > +++ b/package/ccache/ccache.mk > > @@ -42,16 +42,9 @@ HOST_CCACHE_CONF_OPTS += \ > > # so rewrite BR_CACHE_DIR to take that into consideration for SDK > purpose > > HOST_CCACHE_DEFAULT_CCACHE_DIR = $(patsubst > $(HOME)/%,%,$(BR_CACHE_DIR)) > > > > -define HOST_CCACHE_PATCH_CONFIGURATION > > - sed -i 's,getenv("CCACHE_DIR"),getenv("BR_CACHE_DIR"),' > $(@D)/src/ccache/config.cpp > > - sed -i 's,".ccache","$(HOST_CCACHE_DEFAULT_CCACHE_DIR)",' > $(@D)/src/ccache/config.cpp > > - sed -i 's,"/.cache/ccache","/$(HOST_CCACHE_DEFAULT_CCACHE_DIR)",' > $(@D)/src/ccache/config.cpp > > - sed -i 's,"/.config/ccache","/$(HOST_CCACHE_DEFAULT_CCACHE_DIR)",' > $(@D)/src/ccache/config.cpp > > - sed -i 's,getenv("XDG_CACHE_HOME"),nullptr,' > $(@D)/src/ccache/config.cpp > > - sed -i 's,getenv("XDG_CONFIG_HOME"),nullptr,' > $(@D)/src/ccache/config.cpp > > -endef > > +HOST_CCACHE_CONF_OPTS += \ > > + -DCMAKE_CXX_FLAGS='$(HOST_CXXFLAGS) > -DHOST_CCACHE_DEFAULT_CCACHE_DIR=\"$(HOST_CCACHE_DEFAULT_CCACHE_DIR)\"' > > > > -HOST_CCACHE_POST_PATCH_HOOKS += HOST_CCACHE_PATCH_CONFIGURATION > > > > define HOST_CCACHE_MAKE_CACHE_DIR > > mkdir -p $(BR_CACHE_DIR) > > [-- Attachment #1.2: Type: text/html, Size: 14359 bytes --] [-- Attachment #2: Type: text/plain, Size: 150 bytes --] _______________________________________________ buildroot mailing list buildroot@buildroot.org https://lists.buildroot.org/mailman/listinfo/buildroot ^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2026-04-03 10:28 UTC | newest] Thread overview: 6+ messages (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- 2026-03-13 11:07 [Buildroot] [PATCH] package/host-ccache: force use of BR_CACHE_DIR instead of user directories Shubham Chakraborty 2026-03-13 11:07 ` [Buildroot] [PATCH] DEVELOPERS: add Shubham Chakraborty as ccache maintainer Shubham Chakraborty 2026-03-27 20:33 ` Julien Olivain via buildroot 2026-04-03 10:28 ` Thomas Perale via buildroot 2026-03-13 17:06 ` [Buildroot] [PATCH] package/host-ccache: force use of BR_CACHE_DIR instead of user directories Fiona Klute via buildroot 2026-03-13 17:21 ` Shubham Chakraborty
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox