This is an archive of the discontinued LLVM Phabricator instance.

[docs] Clarify how to run cmake and llvm-lit with Visual Studio addressing PR45978
ClosedPublic

Authored by yaron.keren on Aug 19 2021, 10:29 PM.

Diff Detail

Event Timeline

yaron.keren requested review of this revision.Aug 19 2021, 10:29 PM
yaron.keren created this revision.
Herald added a project: Restricted Project. · View Herald TranscriptAug 19 2021, 10:29 PM
This revision was not accepted when it landed; it landed in state Needs Review.Aug 20 2021, 12:54 AM
This revision was automatically updated to reflect the committed changes.
amccarth added inline comments.
llvm/docs/GettingStartedVS.rst
126

There are some potential gotchas lurking here.

Visual Studio (often) includes cmake, git, ninja, and even python. Those might be different versions than what you installed in the previous steps. Depending how vcvarsall.bat juggles the path, you might not be invoking the versions you think you are. In many cases, this might not be a problem, but it can be a real mess in lldb, especially lldb tests.

My solution is:

  • Do not install CMake, git, or ninja. Rely on the VS-distributed ones.
  • Uninstall the VS-distributed Python, then install an independent python3 (with debug libraries if working in LLDB). The VS version doesn't come with the debug libraries. Even with all the CMake fixes and hints to point to your own python3, some parts of the build may pick up the VS version (or any other version) that exists on the machine. Apparently, there can be only one.
  • Use the git tools instead of the out-of-date and unsupported GnuWin32 one...
  • ... except for make, which isn't included in the git tools, so that's the only GnuWin32 tool I do install. (LLDB tests uses make to build test executables.)
  • And you might want doxygen.
  • LLDB also requires swift.
  • I maintain my own set of batch files that start by running vcvarsall.bat to select the right toolchain and then fix-up the PATH to ensure I get a consistent set of tools. I have shortcuts for each configuration that lunch CMD with the appropriate batch file.
  • I also use a batch file to run CMake, since there are so many flags you have to get right. For example:
cmake -GNinja -DCMAKE_BUILD_TYPE=Debug -DLLDB_TEST_DEBUG_TEST_CRASHES=1 -DLLDB_PYTHON_HOME="C:\Program Files\Python38" -DPython3_ROOT_DIR="C:\Program Files\Python38" -DPython3_FIND_REGISTRY=LAST -DLLDB_TEST_COMPILER=D:\src\llvm\build\ninja_dbg\bin\clang.exe ..\..\llvm-project\llvm -DLLVM_ENABLE_ZLIB=OFF -DLLVM_ENABLE_PROJECTS="clang;lld;lldb"

I completely agree, the Getting Started document should be modernized considering a current Visual Studio 2019 installation bundles tools and that GnuWin32 is antique. I will create revision for your review.