summaryrefslogtreecommitdiff
path: root/xmake/rules/mode/xmake.lua
diff options
context:
space:
mode:
authorruki <[email protected]>2023-09-21 22:44:08 +0800
committerruki <[email protected]>2023-09-21 22:44:08 +0800
commitefee9f525906e48699c4bf0eb10cce74d4e7b468 (patch)
tree37892b254262d928d05c6f62a1a22aa3832a04c9 /xmake/rules/mode/xmake.lua
parent8afc0e7ed5d14918fa4fafd450b23263f62ea147 (diff)
enable asan for objc
Diffstat (limited to 'xmake/rules/mode/xmake.lua')
-rw-r--r--xmake/rules/mode/xmake.lua23
1 files changed, 4 insertions, 19 deletions
diff --git a/xmake/rules/mode/xmake.lua b/xmake/rules/mode/xmake.lua
index e2bfc298b..66c5e1911 100644
--- a/xmake/rules/mode/xmake.lua
+++ b/xmake/rules/mode/xmake.lua
@@ -184,9 +184,9 @@ rule("mode.coverage")
-- define rule: asan mode
rule("mode.asan")
- on_config(function (target)
- import("lib.detect.find_tool")
- import("core.base.semver")
+
+ -- we use after_load because c++.build.sanitizer rule/on_config need it
+ after_load(function (target)
-- is asan mode now? xmake f -m asan
if is_mode("asan") then
@@ -206,22 +206,7 @@ rule("mode.asan")
end
-- enable asan checker
- target:add("cxflags", "-fsanitize=address")
- target:add("mxflags", "-fsanitize=address")
- target:add("ldflags", "-fsanitize=address")
- target:add("shflags", "-fsanitize=address")
-
- if target:is_plat("windows") and target:is_binary() then
- local msvc = target:toolchain("msvc")
- if msvc then
- local envs = msvc:runenvs()
- local vscmd_ver = envs and envs.VSCMD_VER
- if vscmd_ver and semver.match(vscmd_ver):ge("17.7") then
- local cl = assert(find_tool("cl", {envs = envs}), "cl not found!")
- target:add("runenvs", "PATH", path.directory(cl.program))
- end
- end
- end
+ target:set("policy", "build.sanitizer.address", true)
end
end)