Skip to content

build-system: use better default for DLCACHE_DIR#22398

Open
maribu wants to merge 1 commit into
RIOT-OS:masterfrom
maribu:DLCACHE_DIR
Open

build-system: use better default for DLCACHE_DIR#22398
maribu wants to merge 1 commit into
RIOT-OS:masterfrom
maribu:DLCACHE_DIR

Conversation

@maribu

@maribu maribu commented Jun 19, 2026

Copy link
Copy Markdown
Member

Contribution description

We already have $(BUILD_DIR) for RIOT cache's and is used for caching package source and STM32 vendor header files. To follow suit, this sets the default to $(BUILD_DIR)/dlcache.

In addition, this allows building on a read-only source directories.

Testing procedure

With master and RIOT mounted read-only into /data/ext/RIOT, not setting DLCACHE_DIR by hand, and having BUILD_DIR mounted read-write into the container:

/data/ext/RIOT/dist/tools/dlcache/dlcache.sh: line 34: can't create /data/ext/RIOT/.dlcache/c25519-2017-10-05.zip.locked: Read-only file system
read EC key
make[1]: *** [Makefile:29: /build/pkg/c25519-2017-10-05.zip] Error 2
writing EC key
/data/ext/RIOT/dist/tools/dlcache/dlcache.sh: line 34: can't create /data/ext/RIOT/.dlcache/c25519-2017-10-05.zip.locked: Read-only file system

Same situation with this PR:

/data/ext/RIOT/dist/tools/dlcache/dlcache.sh: downloading "https://www.dlbeer.co.nz/downloads/c25519-2017-10-05.zip"...
Connecting to www.dlbeer.co.nz (120.138.18.251:443)
saving to '/build/dlcache/c25519-2017-10-05.zip'
c25519-2017-10-05.zi  47% |***************                 | 32457  0:00:01 ETA
c25519-2017-10-05.zi 100% |********************************| 68419  0:00:00 ETA
'/build/dlcache/c25519-2017-10-05.zip' saved
/data/ext/RIOT/dist/tools/dlcache/dlcache.sh: done downloading "https://www.dlbeer.co.nz/downloads/c25519-2017-10-05.zip"

Issues/PRs references

None

Declaration of AI-Tools / LLMs usage:

AI-Tools / LLMs that were used are:

  • none

@maribu maribu added Type: bug The issue reports a bug / The PR fixes a bug (including spelling errors) Impact: minor The PR is small in size and might only require a quick look of a knowledgeable reviewer Type: cleanup The issue proposes a clean-up / The PR cleans-up parts of the codebase / documentation CI: ready for build If set, CI server will compile all applications for all available boards for the labeled PR labels Jun 19, 2026
@maribu maribu enabled auto-merge June 19, 2026 20:10
@github-actions github-actions Bot added the Area: build system Area: Build system label Jun 19, 2026
@riot-ci

riot-ci commented Jun 19, 2026

Copy link
Copy Markdown

Murdock results

✔️ PASSED

5f5d6dd build-system: use better default for DLCACHE_DIR

Success Failures Total Runtime
11124 0 11124 12m:05s

Artifacts

@crasbe

crasbe commented Jun 19, 2026

Copy link
Copy Markdown
Contributor

Wait that's weird... the DLCACHE is supposed to be at home at ~/.dlcache.

I guess the way it works is that the DLCACHE_DIR path doesn't exist and therefore dist/tools/dlcache/dlcache.sh chooses ~/.dlcache and creates the folder if it doesn't exist?

DLCACHE_DIR=${DLCACHE_DIR:-~/.dlcache}
mkdir -p "$DLCACHE_DIR"

@crasbe

crasbe commented Jun 19, 2026

Copy link
Copy Markdown
Contributor

Okay fascinating... in a Docker container, the local folder is used and without the Docker container, the folder in HOME is used.

That's not ideal I think 🤔

@maribu

maribu commented Jun 19, 2026

Copy link
Copy Markdown
Member Author

The KEY=${KEY:-<DEFAULT>} syntax is to make sure that if $KEY is not provided by the environment, it does have a sane default (here ~/.dlcache).

I'd argue that both ~/.dlcache and $(RIOTBASE)/.dlcache are poor defaults. Ideally, one would use subfolder of "${XDG_CACHE_DIR:-$(xdg-user-dir)/.cache}" by default, as that would be the canonical place as far as I know.

But given that we do actually have $(BUILD_DIR) to control the RIOT cache (and many RIOT users do set it to point to "${XDG_CACHE_DIR:-$(xdg-user-dir)/.cache}/RIOT" via ~/zshrc/~/.profile/...), I'd argue that would make the better default here.

@crasbe

crasbe commented Jun 19, 2026

Copy link
Copy Markdown
Contributor

What would a .cache folder in the $(RIOTBASE) be for? I don't have that.
I have a .cache folder in $HOME, but there's nothing in it.

The point of having .dlcache in the $HOME directory is that the stuff downloaded rarely changes, similarly to .gitcache, which also defaults to $HOME.

I'm not aware of any documentation to setup a .cache folder for RIOT stuff 🤔

@maribu

maribu commented Jun 19, 2026

Copy link
Copy Markdown
Member Author

What would a .cache folder in the $(RIOTBASE) be for? I don't have that.

I agree on that. "${XDG_CACHE_DIR:-$(xdg-user-dir)/.cache}/RIOT" would evaluate to ~/.cache/RIOT on most systems and IMO that would be a better default for $(BUILD_DIR) than the current $(RIOT_BASE)/build, especially when working with multiple work trees.

But the problem at hand is that while most caches in RIOT do use $(BUILD_DIR), $(DLCACHE_DIR) is not. It IMO definitely should. Especially given:

cat ~/.cache/RIOT/CACHEDIR.TAG
Signature: 8a477f597d28d172789f06886806bc55
# This folder contains RIOT's build cache

The creation of that CACHEDIR.TAG and the comment make it pretty clear that we intend this to be the base folder for all RIOT caches.

@maribu maribu requested review from AnnsAnns, benpicco and chrysn June 22, 2026 15:11
We already have `$(BUILD_DIR)` for RIOT cache's and is used for caching
package source and STM32 vendor header files. To follow suit, this sets
the default to `$(BUILD_DIR)/dlcache`.

In addition, this allows building on a read-only source directories.
@github-actions github-actions Bot added the Area: tools Area: Supplementary tools label Jun 22, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Area: build system Area: Build system Area: tools Area: Supplementary tools CI: ready for build If set, CI server will compile all applications for all available boards for the labeled PR Impact: minor The PR is small in size and might only require a quick look of a knowledgeable reviewer Type: bug The issue reports a bug / The PR fixes a bug (including spelling errors) Type: cleanup The issue proposes a clean-up / The PR cleans-up parts of the codebase / documentation

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants