diff options
| author | ruki <[email protected]> | 2025-12-22 19:40:12 +0800 |
|---|---|---|
| committer | GitHub <[email protected]> | 2025-12-22 19:40:12 +0800 |
| commit | 1b6b7d629d464c4640660889695b98c93faaff37 (patch) | |
| tree | de981c22860baa55b600459fd876f58fe39b10b2 | |
| parent | dd5d93e1e0c7fe23290ad2e83f94cffb9362d524 (diff) | |
Refactor sanitizer config generation logic
| -rw-r--r-- | xmake/core/package/package.lua | 24 |
1 files changed, 2 insertions, 22 deletions
diff --git a/xmake/core/package/package.lua b/xmake/core/package/package.lua index 6c2742c80..b287ab360 100644 --- a/xmake/core/package/package.lua +++ b/xmake/core/package/package.lua @@ -2457,28 +2457,8 @@ end -- generate sanitizer configs function _instance:_generate_sanitizer_configs(checkmode, sourcekind) - local configs = {} - if sourcekind and self:has_tool(sourcekind, "cl", "clang", "clangxx", "clang_cl", "gcc", "gxx") then - local cflag = sourcekind == "cxx" and "cxxflags" or "cflags" - configs[cflag] = "-fsanitize=" .. checkmode - end - - local ldflags = {} - -- msvc does not have an fsanitize linker flag, so the 'link' tool is excluded - if self:has_tool("ld", "clang", "clangxx", "gcc", "gxx") then - table.insert(ldflags, "-fsanitize=" .. checkmode) - end - - if self:is_plat("windows") and checkmode == "address" and not self:has_tool("cxx", "cl") then - local toolchain_utils = sandbox_module.import("private.utils.toolchain", {anonymous = true}) - table.join2(ldflags, toolchain_utils.get_llvm_asan_flags(self)) - end - - if #ldflags ~= 0 then - configs.ldflags = ldflags - configs.shflags = ldflags - end - return configs + local toolchain_utils = sandbox_module.import("private.utils.toolchain", {anonymous = true}) + return toolchain_utils.get_sanitizer_flags(self, {checkmode = checkmode, sourcekind = sourcekind}) end -- generate building configs for has_xxx/check_xxx |
