diff options
| author | DownerCase <[email protected]> | 2025-06-20 18:11:48 +0100 |
|---|---|---|
| committer | DownerCase <[email protected]> | 2025-06-20 18:16:09 +0100 |
| commit | 749d449e2ff77f43771467b986aa203546f3a808 (patch) | |
| tree | 5659fc8f52b03ebe17ac42ed3ec2043b3de34975 | |
| parent | 9da165f03d6967aa1c82836527eb22702745421a (diff) | |
fix: Do not add -fsanitize flags to msvc linker
msvc's link.exe does not have an `fsanitize` flag.
It was not causing build failures by was creating warning messages like:
LINK : warning LNK4044: unrecognized option '/fsanitize=address'; ignored
| -rw-r--r-- | xmake/core/package/package.lua | 3 | ||||
| -rw-r--r-- | xmake/rules/c++/build_sanitizer/config.lua | 3 |
2 files changed, 4 insertions, 2 deletions
diff --git a/xmake/core/package/package.lua b/xmake/core/package/package.lua index df2be796c..9a1835950 100644 --- a/xmake/core/package/package.lua +++ b/xmake/core/package/package.lua @@ -2431,7 +2431,8 @@ function _instance:_generate_sanitizer_configs(checkmode, sourcekind) end -- add ldflags and shflags - if self:has_tool("ld", "link", "clang", "clangxx", "gcc", "gxx") then + -- msvc does not have an fsanitize linker flag, so the 'link' tool is excluded + if self:has_tool("ld", "clang", "clangxx", "gcc", "gxx") then configs.ldflags = "-fsanitize=" .. checkmode configs.shflags = "-fsanitize=" .. checkmode end diff --git a/xmake/rules/c++/build_sanitizer/config.lua b/xmake/rules/c++/build_sanitizer/config.lua index b2480eb73..1a82090fe 100644 --- a/xmake/rules/c++/build_sanitizer/config.lua +++ b/xmake/rules/c++/build_sanitizer/config.lua @@ -41,7 +41,8 @@ function _add_build_sanitizer(target, sourcekind, checkmode) end -- add ldflags and shflags - if target:has_tool("ld", "link", "clang", "clangxx", "gcc", "gxx") then + -- msvc does not have an fsanitize linker flag, so the 'link' tool is excluded + if target:has_tool("ld", "clang", "clangxx", "gcc", "gxx") then target:add("ldflags", "-fsanitize=" .. checkmode, {force = true}) target:add("shflags", "-fsanitize=" .. checkmode, {force = true}) end |
