From b456912fdc3e910f9bf570ec1a9f2287027afbc1 Mon Sep 17 00:00:00 2001 From: ruki Date: Thu, 25 Jan 2024 00:49:02 +0800 Subject: improve feature --- xmake/modules/lib/detect/features.lua | 15 +++++---------- 1 file changed, 5 insertions(+), 10 deletions(-) (limited to 'xmake/modules/lib/detect/features.lua') diff --git a/xmake/modules/lib/detect/features.lua b/xmake/modules/lib/detect/features.lua index 8b9bde45b..33be29301 100644 --- a/xmake/modules/lib/detect/features.lua +++ b/xmake/modules/lib/detect/features.lua @@ -57,29 +57,24 @@ function main(name, opt) _g._RESULTS = _g._RESULTS or {} local results = _g._RESULTS - -- @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 - -- get result from the cache first local result = results[key] if result ~= nil then 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) + -- detect.tools.xxx.features(opt)? - _g._checking = coroutine_running and key or nil local features = import("detect.tools." .. tool.name .. ".features", {try = true}) if features then result = features(opt) end - _g._checking = nil result = result or {} results[key] = result + scheduler.co_unlock(key) return result end -- cgit v1.3.1