You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
|[`/FS`](fs-force-synchronous-pdb-writes.md)| Forces serialization of all writes to the program database (PDB) file through MSPDBSRV.EXE. |
52
+
|[`/fsanitize`](fsanitize.md.md)| Enables compilation of sanitizer instrumentation such as AddressSanitizer. |
52
53
|[`/FU`](fu-name-forced-hash-using-file.md)| Forces the use of a file name as if it had been passed to the [`#using`](../../preprocessor/hash-using-directive-cpp.md) directive. |
53
54
|[`/Fx`](fx-merge-injected-code.md)| Merges injected code with source file. |
54
55
|[`/GA`](ga-optimize-for-windows-application.md)| Optimizes code for Windows application. |
Use the **`/fsanitize`** compiler options to enable sanitizers. As of Visual Studio 2019 16.9, the only supported sanitizer is [AddressSanitizer](../../sanitizers/asan.md).
11
11
@@ -14,13 +14,12 @@ Use the **`/fsanitize`** compiler options to enable sanitizers. As of Visual Stu
14
14
> **`/fsanitize=address`**\
15
15
> **`/fsanitize-address-use-after-return`**\
16
16
> **`/fno-sanitize-address-vcasan-lib`**\
17
-
> **`/INFERASANLIBS`**\[**`:no`**]
18
17
19
18
## Remarks
20
19
21
20
The **`/fsanitize=address`** compiler option enables [AddressSanitizer](../../sanitizers/asan.md), a powerful compiler and runtime technology to light up [hard-to-find bugs](../../sanitizers/asan.md#error-types).
22
21
23
-
The **`/fsanitize-address-use-after-return`** and **`/fno-sanitize-address-vcasan-lib`** compiler options, and the **`/INFERASANLIBS`**and **`/INFERASANLIBS:no`** linker options offer support for advanced users. See [AddressSanitizer build and language reference](../../sanitizers/asan-building.md) for more details.
22
+
The **`/fsanitize-address-use-after-return`** and **`/fno-sanitize-address-vcasan-lib`** compiler options, and the [`/INFERASANLIBS` (Use inferred sanitizer libs)](./inferasanlibs.md)and **`/INFERASANLIBS:NO`** linker options offer support for advanced users. See [AddressSanitizer build and language reference](../../sanitizers/asan-building.md) for more details.
24
23
25
24
The **`/fsanitize`** options are available beginning in Visual Studio 2019 version 16.9.
26
25
@@ -44,9 +43,6 @@ The **`/fsanitize`** options are available beginning in Visual Studio 2019 versi
44
43
45
44
1. Choose **OK** or **Apply** to save your changes.
46
45
47
-
, go to the by using the **Additional Options** properties under the respective dropdowns.
48
-
Set the advanced compiler and linker options by using the **Additional Options** properties under the respective dropdowns.
49
-
50
46
### To set this compiler option programmatically
51
47
52
48
- See <xref:Microsoft.VisualStudio.VCProjectEngine.VCCLCompilerTool.AdditionalOptions%2A>.
@@ -55,6 +51,7 @@ Set the advanced compiler and linker options by using the **Additional Options**
Use the **`/INFERASANLIBS`** linker option to enable or disable linking to the default sanitizer libraries. As of Visual Studio 2019 16.9, the only supported sanitizer is [AddressSanitizer](../../sanitizers/asan.md).
11
+
12
+
## Syntax
13
+
14
+
> **`/INFERASANLIBS`**\[**`:NO`**]
15
+
16
+
## Remarks
17
+
18
+
The **`/INFERASANLIBS`** linker option enables the default [AddressSanitizer](../../sanitizers/asan.md) libraries. AddressSanitizer is a powerful compiler and runtime technology to light up [hard-to-find bugs](../../sanitizers/asan.md#error-types).
19
+
20
+
The **`/INFERASANLIBS`** and **`/INFERASANLIBS:NO`** linker options offer support for advanced users. See [AddressSanitizer build and language reference](../../sanitizers/asan-building.md) for more details.
21
+
22
+
The **`/INFERASANLIBS`** option is available beginning in Visual Studio 2019 version 16.9.
23
+
24
+
### To set the **`/INFERASANLIBS`** linker option in the Visual Studio development environment
25
+
26
+
1. Open your project's **Property Pages** dialog box.
1. Modify the **Additional Options** property. To enable default libraries, enter **/INFERASANLIBS** in the edit box. To disable default libraries, enter **/INFERASANLIBS:no** instead.
31
+
32
+
1. Choose **OK** or **Apply** to save your changes.
33
+
34
+
### To set this linker option programmatically
35
+
36
+
- See <xref:Microsoft.VisualStudio.VCProjectEngine.VCLinkerTool.AdditionalOptions%2A>.
Copy file name to clipboardExpand all lines: docs/sanitizers/asan-building.md
+11-9Lines changed: 11 additions & 9 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -116,11 +116,13 @@ The library chosen depends on the compilation options, and is automatically link
116
116
|**`/MTd`**|*`libvcasand.lib`*|
117
117
|**`/MDd`**|*`vcasand.lib`*|
118
118
119
-
However, if you compile using **`/Zl`** (Omit default library name), you'll need to manually specify the library. If you don't, you'll get a link failure; one of:
119
+
However, if you compile using **`/Zl`** (Omit default library name), you'll need to manually specify the library. If you don't, you'll get a link failure; here are some typical examples:
120
120
121
121
```Output
122
122
error LNK2001: unresolved external symbol __you_must_link_with_VCAsan_lib
123
123
error LNK2001: unresolved external symbol ___you_must_link_with_VCAsan_lib
124
+
error LNK2019: unresolved external symbol __asan_report_load4 referenced in function main
125
+
error LNK2019: unresolved external symbol __asan_report_load8 referenced in function main
124
126
```
125
127
126
128
The improved debugging can be disabled at compile time using the **`/fno-sanitize-address-vcasan-lib`** option.
@@ -129,14 +131,14 @@ The improved debugging can be disabled at compile time using the **`/fno-sanitiz
129
131
130
132
The **`/fsanitize=address`** compiler option produces a binary that exposes memory safety bugs at runtime. When the binary is started from the command line, and the runtime reports an error, it prints the error details. It then and exits the process. The `ASAN_VCASAN_DEBUGGING` environment variable can be set to launch the Visual Studio IDE immediately when the runtime reports an error. This compiler option lets you view the error, superimposed over your source code, at the precise line and column that caused the error.
131
133
132
-
To enable this behavior, run the command `set ASAN_VCASAN_DEBUGGING=1` before you run your application. You can disable the enhanced debugging experience by running `set ASAN_VISAS_DEBUGGING=0`.
134
+
To enable this behavior, run the command `set ASAN_VCASAN_DEBUGGING=1` before you run your application. You can disable the enhanced debugging experience by running `set ASAN_VCASAN_DEBUGGING=0`.
133
135
134
136
## See also
135
137
136
-
-[AddressSanitizer Overview](./asan.md)
137
-
-[AddressSanitizer Known Issues](./asan-known-issues.md)
138
-
-[AddressSanitizer Build and Language Reference](./asan-building.md)
We've ported some examples to help you learn to use the AddressSanitizer features supported by MSVC in your code. These examples are based on sources in the [LLVM compiler-rt test suite](https://github.com/llvm/llvm-project/tree/main/compiler-rt/test/asan/TestCases).
10
+
11
+
## Build the examples
12
+
13
+
Each example provides source code and compilation instructions for a command-line build. To build each example, open a developer command prompt. Create a folder for your example project, then make it the current directory. Then copy the example code into a source file with the appropriate name, such as *`example1.cpp`*. Follow the build instructions to generate and run the instrumented code in the debugger.
0 commit comments