summaryrefslogtreecommitdiff
path: root/xmake/modules/lib
diff options
context:
space:
mode:
authorruki <[email protected]>2023-03-07 00:51:10 +0800
committerruki <[email protected]>2023-03-06 23:07:37 +0800
commit84e7c19365b5a8a1aa48682eb14759e81dc519d9 (patch)
tree8077e256afb96a6c6631affcf855453a06aace22 /xmake/modules/lib
parent07c40ef1b398ee4970a9383953477c017b1576e4 (diff)
improve has_flags
Diffstat (limited to 'xmake/modules/lib')
-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