summaryrefslogtreecommitdiff
path: root/xmake/modules/lib/detect/has_flags.lua
diff options
context:
space:
mode:
Diffstat (limited to 'xmake/modules/lib/detect/has_flags.lua')
-rw-r--r--xmake/modules/lib/detect/has_flags.lua8
1 files changed, 7 insertions, 1 deletions
diff --git a/xmake/modules/lib/detect/has_flags.lua b/xmake/modules/lib/detect/has_flags.lua
index 1d5cd3848..3567ceae6 100644
--- a/xmake/modules/lib/detect/has_flags.lua
+++ b/xmake/modules/lib/detect/has_flags.lua
@@ -88,7 +88,13 @@ function main(name, flags, opt)
end
-- attempt to get result from cache first
- local cacheinfo = detectcache:get("lib.detect.has_flags") or {}
+ local cacheinfo = detectcache:get("lib.detect.has_flags")
+ if not cacheinfo then
+ -- since has_flags may be switched to other concurrent processes during cache saving,
+ -- we need to commit the initialized cache to avoid multiple cache objects overwriting it.
+ cacheinfo = {}
+ detectcache:set("lib.detect.has_flags", cacheinfo)
+ end
local result = cacheinfo[key]
if result ~= nil and not opt.force then
return result