diff options
| author | ruki <[email protected]> | 2024-01-25 00:44:24 +0800 |
|---|---|---|
| committer | ruki <[email protected]> | 2024-01-25 12:10:22 +0800 |
| commit | fba862bb13f8780dd01ce85be8ac7c5709289b6d (patch) | |
| tree | 6a5224ad975348b8a8a480d421423c4f309d56cc /xmake/modules/lib/detect/has_flags.lua | |
| parent | 21aeb8d32ec1892904cc34a57e9c2c3d83b9f1bd (diff) | |
lock and unlock coroutine #4645
Diffstat (limited to 'xmake/modules/lib/detect/has_flags.lua')
| -rw-r--r-- | xmake/modules/lib/detect/has_flags.lua | 15 |
1 files changed, 5 insertions, 10 deletions
diff --git a/xmake/modules/lib/detect/has_flags.lua b/xmake/modules/lib/detect/has_flags.lua index dc11db11c..e45a7a5b3 100644 --- a/xmake/modules/lib/detect/has_flags.lua +++ b/xmake/modules/lib/detect/has_flags.lua @@ -80,14 +80,6 @@ function main(name, flags, opt) .. (tool.version or "") .. "_" .. (opt.toolkind or "") .. "_" .. (opt.flagkind or "") .. "_" .. table.concat(opt.sysflags, " ") .. "_" .. opt.flagskey - -- @note avoid detect the same program in the same time if running in the coroutine (e.g. ccache) - local coroutine_running = scheduler.co_running() - if coroutine_running then - while _g._checking ~= nil and _g._checking == key do - scheduler.co_yield() - end - end - -- attempt to get result from cache first local cacheinfo = detectcache:get("lib.detect.has_flags") if not cacheinfo then @@ -101,6 +93,10 @@ function main(name, flags, opt) 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) @@ -122,7 +118,6 @@ function main(name, flags, opt) profiler.enter("has_flags", tool.name, checkflags[1]) -- detect.tools.xxx.has_flags(flags, opt)? - _g._checking = coroutine_running and key or nil local hasflags = import("detect.tools." .. tool.name .. ".has_flags", {try = true}) local errors = nil if hasflags then @@ -133,7 +128,6 @@ function main(name, flags, opt) if opt.on_check then result, errors = opt.on_check(result, errors) end - _g._checking = nil result = result or false -- stop profile @@ -156,6 +150,7 @@ function main(name, flags, opt) cacheinfo[key] = result detectcache:set("lib.detect.has_flags", cacheinfo) detectcache:save() + scheduler.co_unlock(key) return result end |
