Skip to contentSkip to conversation

artifacts in sstate-plaindirs are deleted and not cached

DISCUSSION Alberto Pianon 1 participant 1 message Nov 15, 2023

lore
Share & tools
lore
#0 lore raw

Hi,

I wanted to add sstate cache support to my WIP meta-bbtracer layer and I ran into a problem.

Following the manual (https://docs.yoctoproject.org/singleindex.html#shared-state), I tried to use sstate-plaindirs instead of separate sstate-inputdirs and sstate-outputdirs since I don't actually need to use different directories, but I noticed that artifacts placed in such dirs always get deleted, and the corresponding zst archive in sstate-cache is empty. If I use sstate-inputdirs/outputdirs, it works.

To isolate and reproduce the issue, I set up a dummy yocto layer that just adds a class that adds a task that writes a dummy file after do_unpack: https://github.com/alpianon/meta-sstate-test

The dummy bbclass is:

```
SSTATE_TEST_DIR = "${TMPDIR}/sstate-test/${PN}"
SSTATE_TEST_FILE = "${SSTATE_TEST_DIR}/sstate-test.json"

python do_sstatetest () {
    bb.warn("writing to %s" % d.getVar("SSTATE_TEST_FILE"))
    with open(d.getVar("SSTATE_TEST_FILE"), "w") as f:
        f.write("Hello World!")
}

addtask do_sstatetest after do_unpack before do_patch

SSTATETASKS += "do_sstatetest"
do_sstatetest[sstate-plaindirs] = "${SSTATE_TEST_DIR}"

python do_sstatetest_setscene () {
    sstate_setscene(d)
}

addtask do_sstatetest_setscene

do_sstatetest[dirs] = "${SSTATE_TEST_DIR}"
```

After running bitbake -c sstatetest <whatever-recipe>, a sstate-test.json is expected to be found in tmp/sstate-test/<whatever-recipe>, but such dir is empty instead. But if I remove the whole sstate configuration from the above bbclass, the file is there after running the task.

By adding some debug messages to sstate.bbclass, I concluded that the sstate "plaindir" content gets deleted by prepdir() function called within this code in sstate.bbclass: https://git.yoctoproject.org/poky/tree/meta/classes-global/sstate.bbclass#n385 but I don't understand why.

Is that the intended behaviour? Am I missing something?

Thanks
Cheers,

Alberto