aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJussi Pakkanen <jpakkane@gmail.com>2021-03-09 18:17:36 +0000
committerDylan Baker <dylan@pnwbakers.com>2021-03-09 13:52:15 -0800
commitd76345b4beec48484e31110b225c3256d8ba264b (patch)
tree4921110841399cc65b972ba5757be47d44b66f57
parent6f9d6858ce7875ea9225c5c113c487dc01b96b15 (diff)
downloadmeson-d76345b4beec48484e31110b225c3256d8ba264b.zip
meson-d76345b4beec48484e31110b225c3256d8ba264b.tar.gz
meson-d76345b4beec48484e31110b225c3256d8ba264b.tar.bz2
Add address sanitizer support for Visual Studio.
-rw-r--r--docs/markdown/Builtin-options.md4
-rw-r--r--docs/markdown/snippets/vsasan.md6
-rw-r--r--mesonbuild/compilers/cpp.py1
-rw-r--r--mesonbuild/compilers/mixins/visualstudio.py9
4 files changed, 18 insertions, 2 deletions
diff --git a/docs/markdown/Builtin-options.md b/docs/markdown/Builtin-options.md
index e3805ac..ce33fce 100644
--- a/docs/markdown/Builtin-options.md
+++ b/docs/markdown/Builtin-options.md
@@ -138,7 +138,9 @@ available on all platforms or with all compilers:
| b_vscrt | from_buildtype | none, md, mdd, mt, mtd, from_buildtype, static_from_buildtype | VS runtime library to use (since 0.48.0) (static_from_buildtype since 0.56.0) |
The value of `b_sanitize` can be one of: `none`, `address`, `thread`,
-`undefined`, `memory`, `address,undefined`.
+`undefined`, `memory`, `address,undefined`, but note that some
+compilers might not support all of them. For example Visual Studio
+only supports the address sanitizer.
* < 0 means disable, == 0 means automatic selection, > 0 sets a specific number to use
diff --git a/docs/markdown/snippets/vsasan.md b/docs/markdown/snippets/vsasan.md
new file mode 100644
index 0000000..287400e
--- /dev/null
+++ b/docs/markdown/snippets/vsasan.md
@@ -0,0 +1,6 @@
+## Address sanitizer support for Visual Studio
+
+The `b_sanitize` option for enabling Address sanitizer now works with
+the Visual Studio compilers. This requires [a sufficiently new version
+of Visual
+Studio](https://devblogs.microsoft.com/cppblog/address-sanitizer-for-msvc-now-generally-available/).
diff --git a/mesonbuild/compilers/cpp.py b/mesonbuild/compilers/cpp.py
index 4d55ccd..d0e3fd2 100644
--- a/mesonbuild/compilers/cpp.py
+++ b/mesonbuild/compilers/cpp.py
@@ -663,7 +663,6 @@ class VisualStudioCPPCompiler(CPP11AsCPP14Mixin, VisualStudioLikeCPPCompilerMixi
CPPCompiler.__init__(self, exelist, version, for_machine, is_cross,
info, exe_wrapper, linker=linker, full_version=full_version)
MSVCCompiler.__init__(self, target)
- self.base_options = {OptionKey(o) for o in ['b_pch', 'b_vscrt', 'b_ndebug']} # FIXME add lto, pgo and the like
self.id = 'msvc'
def get_options(self) -> 'KeyedOptionDictType':
diff --git a/mesonbuild/compilers/mixins/visualstudio.py b/mesonbuild/compilers/mixins/visualstudio.py
index 3ba0610..2b173eb 100644
--- a/mesonbuild/compilers/mixins/visualstudio.py
+++ b/mesonbuild/compilers/mixins/visualstudio.py
@@ -125,6 +125,8 @@ class VisualStudioLikeCompiler(Compiler, metaclass=abc.ABCMeta):
self.machine = 'arm'
else:
self.machine = target
+ if mesonlib.version_compare(self.version, '>=19.29.29917'):
+ self.base_options.add(mesonlib.OptionKey('b_sanitize'))
assert self.linker is not None
self.linker.machine = self.machine
@@ -159,6 +161,13 @@ class VisualStudioLikeCompiler(Compiler, metaclass=abc.ABCMeta):
def get_no_optimization_args(self) -> T.List[str]:
return ['/Od']
+ def sanitizer_compile_args(self, value: str) -> T.List[str]:
+ if value == 'none':
+ return []
+ if value != 'address':
+ raise mesonlib.MesonException('VS only supports address sanitizer at the moment.')
+ return ['/fsanitize=address']
+
def get_output_args(self, target: str) -> T.List[str]:
if target.endswith('.exe'):
return ['/Fe' + target]