cmake: Introduce a key version to invalidate corrupted caches

When a bug in the caching mechanism is detected the cache format must
be bumped to ensure that we no longer get a cache hit on old corrupted
keys.

This fixes #7246 when the cache is corrupted.

Signed-off-by: Sebastian Bøe <sebastian.boe@nordicsemi.no>
This commit is contained in:
Sebastian Bøe 2018-05-02 15:43:56 +02:00 committed by Anas Nashif
commit aa90d72116

View file

@ -622,8 +622,15 @@ function(zephyr_check_compiler_flag lang option check)
# We need to create a unique key wrt. testing the toolchain # We need to create a unique key wrt. testing the toolchain
# capability. This key must be a valid C identifier that includes # capability. This key must be a valid C identifier that includes
# everything that can affect the toolchain test. # everything that can affect the toolchain test.
# The 'cacheformat' must be bumped if a bug in the caching mechanism
# is detected and all old keys must be invalidated.
set(cacheformat 2)
set(key_string "") set(key_string "")
set(key_string "${key_string}ZEPHYR_TOOLCHAIN_CAPABILITY_CACHE_") set(key_string "${key_string}ZEPHYR_TOOLCHAIN_CAPABILITY_CACHE_")
set(key_string "${key_string}cacheformat_")
set(key_string "${key_string}${cacheformat}_")
set(key_string "${key_string}${TOOLCHAIN_SIGNATURE}_") set(key_string "${key_string}${TOOLCHAIN_SIGNATURE}_")
set(key_string "${key_string}${lang}_") set(key_string "${key_string}${lang}_")
set(key_string "${key_string}${option}_") set(key_string "${key_string}${option}_")