summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJérôme Leclercq <[email protected]>2023-10-26 11:36:24 +0200
committerGitHub <[email protected]>2023-10-26 11:36:24 +0200
commit5b0dde755ac682f18a407899f16905a1aae331f9 (patch)
tree4228c8a8804b017ce4fd681b4d06e184ac1aaf13
parent30b0405058c7a90ec60f36179993c74b59717994 (diff)
Fix asan and lto config handling
This fixes two things: 1) when `project.policy("build.sanitizer.address")` is true, there is no way to disable asan on a package, `add_requires("xx", { configs { asan = false } })` won't work because of the `or` (it should check for nil) 2) When asan is set to false, it won't match installed packages with asan key set to nil even though they are identical. So when asan/lto key is set to false, it will remove the asan/lto key from config
-rw-r--r--xmake/modules/private/action/require/impl/package.lua13
1 files changed, 11 insertions, 2 deletions
diff --git a/xmake/modules/private/action/require/impl/package.lua b/xmake/modules/private/action/require/impl/package.lua
index a7377d41b..a726e0f27 100644
--- a/xmake/modules/private/action/require/impl/package.lua
+++ b/xmake/modules/private/action/require/impl/package.lua
@@ -502,8 +502,17 @@ function _init_requireinfo(requireinfo, package, opt)
if project.policy("package.inherit_external_configs") then
requireinfo.configs.vs_runtime = requireinfo.configs.vs_runtime or get_config("vs_runtime")
end
- requireinfo.configs.lto = requireinfo.configs.lto or project.policy("build.optimization.lto")
- requireinfo.configs.asan = requireinfo.configs.asan or project.policy("build.sanitizer.address")
+ local function initconfig(key, default)
+ if requireinfo.configs[key] == nil then
+ requireinfo.configs[key] = default
+ end
+ -- set false key as nil so hashes match
+ if not requireinfo.configs[key] then
+ requireinfo.configs[key] = nil
+ end
+ end
+ initconfig("asan", project.policy("build.sanitizer.address"))
+ initconfig("lto", project.policy("build.optimization.lto"))
end
-- but we will ignore some configs for buildhash in the headeronly and host/binary package
-- @note on_test still need these configs, @see https://github.com/xmake-io/xmake/issues/4124