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

Adrian McCarthy via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Fri Aug 20 11:08:37 PDT 2021


amccarth added inline comments.


================
Comment at: llvm/docs/GettingStartedVS.rst:126
+        c:\build> cmake ..\llvm\llvm -DLLVM_ENABLE_PROJECTS=clang -DLLVM_TARGETS_TO_BUILD=X86 -Thost=x64
+
    * See the :doc:`LLVM CMake guide <CMake>` for detailed information about
----------------
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"
```



Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D108444/new/

https://reviews.llvm.org/D108444



More information about the llvm-commits mailing list