microsoft / microsoft/vscode-cmake-tools
Add path to MSVC binaries to PATH for launch/debug
- Dominant language
- TypeScript
- Stars
- 1.7k
- Forks
- 546
- Avg merge
- 2d 16h
- Merged PRs (30d)
- 32
Description
### Brief Issue Summary
There are some DLL files MSVC may link to, but are not included in PATH. This especially affects the AddressSanitizer; the needed runtime DLLs lie with the compiler binaries.
In my case, the needed files are located at `C:\Program Files (x86)\Microsoft Visual Studio\2019\BuildTools\VC\Tools\MSVC\14.29.30037\bin\Hostx64\x64`. Depending on the selected toolkit and the VS version, hardcoding this path makes no sense.
### Expected:
1. Create quick start project with executable binary
2. Add `set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} /Oy- /fsanitize=address")` to CMakeLists.txt
3. Build project
4. Run resulting binary using "run" or "debug" button in the bottom bar
Note: A solution in which I somehow pass the compiler path into the launch configuration would be fine for me. But for that, I need to know a substitution variable to use for that.
### Apparent Behavior:
The compiled binary exits with exit code -1073741515 (0xc0000135). (seen in debug output)
I did some research and this exit code is usually caused by missing DLL files.
### CMake Tools Log
```
[main] Building folder: asan-test
[build] Starting build
[proc] Executing command: "C:\Program Files (x86)\Microsoft Visual Studio\2019\BuildTools\Common7\IDE\CommonExtensions\Microsoft\CMake\CMake\bin\cmake.exe" --build c:/Users/xxx/Git/asan-test/build --config Debug --target ALL_BUILD -j 14 --
[build] Microsoft (R) Build Engine version 16.10.2+857e5a733 for .NET Framework
[build] Copyright (C) Microsoft Corporation. All rights reserved.
[build]
[build] Checking Build System
[build] Building Custom Rule C:/Users/xxx/Git/asan-test/CMakeLists.txt
[build] main.cpp
[build] LINK : warning LNK4300: ignoring '/INCREMENTAL' because input module contains ASAN metadata [C:\Users\xxx\Git\asan-test\build\asan-test.vcxproj]
[build] asan-test.vcxproj -> C:\Users\xxx\Git\asan-test\build\Debug\asan-test.exe
[build] Building Custom Rule C:/Users/xxx/Git/asan-test/CMakeLists.txt
[build] Build finished with exit code 0
```
### Platform and Versions
- **Operating System**: Windows 10
- **CMake Version**: 3.20.21032501-MSVC_2
- **VSCode Version**: 1.57.1
- **CMake Tools Extension Version**: 1.7.,3
- **Compiler/Toolchain**: Visual Studio Build Tools 2019 16.10.2+857e5a733; MSVC 19.29.30038.1
Contributor guide
Research direction
Start by reproducing the Windows 10 quick-start project with the MSVC AddressSanitizer flags and inspect how CMake Tools constructs the launch and debug environment. Done means the MSVC compiler-binary directory is located without a hardcoded versioned path and the resulting executable launches or debugs without the missing-DLL error.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- cmake, cpp, typescript
- Domain
- build-system, devtools
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 38/100