|
| 1 | +--- |
| 2 | +title: "/dynamicdeopt (Enable C++ Dynamic Debugging (Preview))" |
| 3 | +description: "Use the Microsoft C++ compiler option /dynamicdeopt to use C++ Dynamic Debugging." |
| 4 | +ms.date: 03/14/2025 |
| 5 | +f1_keywords: ["/dynamicdeopt", "VC.Project.VCNMakeTool.CompileAsManaged", "VC.Project.VCCLCompilerTool.CompileAsManaged"] |
| 6 | +helpviewer_keywords: ["cl.exe compiler, common language runtime option", "-dynamicdeopt compiler option [C++]", "dynamicdeopt compiler option [C++]", "/clr compiler option [C++]", "Managed Extensions for C++, compiling", "common language runtime, /clr compiler option"] |
| 7 | +--- |
| 8 | +# `/dynamicdeopt` (Enable C++ Dynamic Debugging) (Preview) |
| 9 | +> [!IMPORTANT] |
| 10 | +> The `/dynamicdeopt` compiler switch is currently in PREVIEW. |
| 11 | +> This information relates to a prerelease feature that might be substantially modified before release. Microsoft makes no warranties, expressed or implied, with respect to the information provided here. |
| 12 | +
|
| 13 | +Enable [C++ Dynamic Debugging (Preview)](/visualstudio/debugger/cpp-dynamic-debugging) so you can debug optimized code as if it were compiled deoptimized and step in anywhere with on-demand function deoptimization. |
| 14 | + |
| 15 | +## Syntax |
| 16 | + |
| 17 | +> **`/dynamicdeopt`** |
| 18 | +> **`/dynamicdeopt:suffix <suffix>`** |
| 19 | +> **`/dynamicdeopt:sync`** |
| 20 | +
|
| 21 | +## Arguments |
| 22 | + |
| 23 | +*`suffix`*\ |
| 24 | +Specify the file extension for the deoptimized output. |
| 25 | + |
| 26 | +With no options and given `test.cpp` as input, your output includes `test.obj`, `test.exe`, and `test.pdb`, as well as `test.alt.obj`, `test.alt.exe`, and `test.alt.pdb`. This switch allows you to change the suffix of the unoptimized binary build artifacts from `.alt` to something else. If you change the suffix, all files must use the new suffix, and it needs to match the name passed to the linker using [`/dynamicdeopt:suffix` (Preview)](dynamic-deopt-linker.md). You typically don't use this switch unless you need to avoid filename collisions with other files that you have. |
| 27 | + |
| 28 | +*`sync`*\ |
| 29 | +Builds the deoptimized output after building the optimized output instead of in parallel. By default, the compiler spawns a parallel instance of the code generator. This switch makes the them run serially, instead. This switch is provided in case this better suits your build environment. |
| 30 | + |
| 31 | +## Remarks |
| 32 | + |
| 33 | +This preview flag, available starting with Visual Studio 2022 Version 17.14 Preview 2, applies only to x64 projects and must be used with the corresponding linker flag, [`/DYNAMICDEOPT`](dynamic-deopt-linker.md). |
| 34 | + |
| 35 | +Compiling with `/dynamicdeopt` generates other binaries that are used for debugging. When you debug an optimized file and debug into an optimized function, the debugger steps into the alternate binary instead. This allows you to debug as if you're debugging unoptimized code while still getting the performance advantages of optimized code. |
| 36 | + |
| 37 | +`/dynamicdeopt` requires: |
| 38 | + |
| 39 | +`/DEBUG` or `/DEBUG:FULL`. If you don't specify `/DEBUG`, or if you specify `/DEBUG:FASTLINK`, the linker gives a fatal error. |
| 40 | +If you specify `/INCREMENTAL`, the compiler generates a warning and automatically turns off `/INCREMENTAL`. |
| 41 | +If you specify `/OPT:ICF`, the compiler generates a warning that the debug experience isn't as good. This is because ICF can cause functions to be removed from the alt file, which means you can't step into them. |
| 42 | + |
| 43 | +`/dynamicdeopt` is incompatible with edit-and-continue and the following compiler switches: |
| 44 | + |
| 45 | +```cpp |
| 46 | +/GL |
| 47 | +/ZI |
| 48 | +/RTC1 |
| 49 | +/RTCs |
| 50 | +/RTCc |
| 51 | +/RTCu |
| 52 | +/GH |
| 53 | +/Gh |
| 54 | +/fastcap |
| 55 | +/callcap |
| 56 | +/ZW |
| 57 | +fsanitize=address |
| 58 | +fsanitize=kernel-address |
| 59 | +All of the CLR flags |
| 60 | +``` |
| 61 | + |
| 62 | +### Set this linker option in the Visual Studio development environment |
| 63 | + |
| 64 | +You can set this switch inside Visual Studio. For more information, see [C++ Dynamic Debugging (Preview)](/visualstudio/debugger/cpp-dynamic-debugging#build-system-integration). There are advantages to setting the switch in Visual Studio because MSBuild automatically suppresses some of the incompatible switches such as `/GL` and `/OPT:ICF`. It also sets the corresponding linker option (`/DYNAMICDEOPT`). You can also set the switch in the command line. |
| 65 | + |
| 66 | +### Set this compiler option programmatically |
| 67 | + |
| 68 | +- See <xref:Microsoft.VisualStudio.VCProjectEngine.VCCLCompilerTool.CompileAsManaged>. |
| 69 | + |
| 70 | +## See also |
| 71 | + |
| 72 | +[C++ Dynamic Debugging (Preview)](/visualstudio/debugger/cpp-dynamic-debugging)\ |
| 73 | +[MSVC Compiler Options](compiler-options.md)\ |
| 74 | +[MSVC Compiler Command-Line Syntax](compiler-command-line-syntax.md) |
0 commit comments