summaryrefslogtreecommitdiff
path: root/xmake/modules/lib/detect/has_flags.lua
diff options
context:
space:
mode:
authorruki <[email protected]>2024-01-25 22:32:40 +0800
committerruki <[email protected]>2024-01-25 12:10:23 +0800
commit039897c33bf0e4066eaae3583d09721f46226a87 (patch)
tree9d8d6b9c79f6c68f26d86fe387a0d0638bbec96f /xmake/modules/lib/detect/has_flags.lua
parentdbb46f95b4b61787857261807a741f8ae34db7f9 (diff)
improve to find_program
Diffstat (limited to 'xmake/modules/lib/detect/has_flags.lua')
-rw-r--r--xmake/modules/lib/detect/has_flags.lua9
1 files changed, 5 insertions, 4 deletions
diff --git a/xmake/modules/lib/detect/has_flags.lua b/xmake/modules/lib/detect/has_flags.lua
index e45a7a5b3..abfae3a57 100644
--- a/xmake/modules/lib/detect/has_flags.lua
+++ b/xmake/modules/lib/detect/has_flags.lua
@@ -80,6 +80,10 @@ function main(name, flags, opt)
.. (tool.version or "") .. "_" .. (opt.toolkind or "")
.. "_" .. (opt.flagkind or "") .. "_" .. table.concat(opt.sysflags, " ") .. "_" .. opt.flagskey
+ -- @see https://github.com/xmake-io/xmake/issues/4645
+ -- @note avoid detect the same program in the same time leading to deadlock if running in the coroutine (e.g. ccache)
+ scheduler.co_lock(key)
+
-- attempt to get result from cache first
local cacheinfo = detectcache:get("lib.detect.has_flags")
if not cacheinfo then
@@ -90,13 +94,10 @@ function main(name, flags, opt)
end
local result = cacheinfo[key]
if result ~= nil and not opt.force then
+ scheduler.co_unlock(key)
return result
end
- -- @see https://github.com/xmake-io/xmake/issues/4645
- -- @note avoid detect the same program in the same time leading to deadlock if running in the coroutine (e.g. ccache)
- scheduler.co_lock(key)
-
-- generate all checked flags
local checkflags = table.join(flags, opt.sysflags)