From 84e7c19365b5a8a1aa48682eb14759e81dc519d9 Mon Sep 17 00:00:00 2001 From: ruki Date: Tue, 7 Mar 2023 00:51:10 +0800 Subject: improve has_flags --- xmake/modules/lib/detect/has_flags.lua | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) 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 -- cgit v1.3.1