<div dir="ltr">This has been on my mind for quite some time, but recently it's been popping up more and more seeing some of the issues people have run into.<div><br></div><div>Before people get the wrong idea, let me make one thing clear.  **I am not proposing we stop supporting the CMake Visual Studio generator.  I am only proposing we stop supporting actually compiling with the generated project**.  Yes the distinction is important, and I'll elaborate more on why later.  First though, here are some of the issues with the VS generator:</div><div><br></div><div>1) Using MSBuild is slower than Ninja.</div><div>2) Unless you remember to pass -Thost=x64 on the command line, you won't be able to successfully build.  We can (and have) updated the documentation to indicate this, but it's not intuitive and still bites people because for some reason this is not the default.</div><div><div><font color="#212121">3) Even if you do pass -Thost=x64 to CMake, it will apparently still fail sometimes.  See this thread for details: <a href="http://lists.llvm.org/pipermail/cfe-dev/2018-October/059609.html">http://lists.llvm.org/pipermail/cfe-dev/2018-October/059609.html</a>.  It seems the parallel build scheduler does not do a good job and can bring a machine down.  This is not the first time though, every couple of months there's a thread about how building or running tests from within VS doesn't work.</font></div></div><div>4) Supporting it is a continuous source of errors and mistakes when writing tests.  The VS generator outputs a project which can build Debug / Release with a single project.  This means that `CMAKE_BUILD_TYPE=Debug` is a no-op on this generator.  The reason this matters for the test suite is because `${CMAKE_CURRENT_BINARY_DIR}` isn't sufficient to identify the location of the binaries.  You need `<span style="font-size:13px;color:rgb(33,33,33)">${CMAKE_CURRENT_BINARY_DIR}/${</span><span style="font-size:13px;color:rgb(33,33,33)">CMAKE_CFG_INTDIR}` instead.</span></div><div><span style="font-size:13px;color:rgb(33,33,33)"><br></span></div><div><span style="color:rgb(33,33,33)">There is a continuous source of problems in our CMake [1, 2, 3, 4, 5].  It also affects tests, and every time someone adds a new lit site configuration, they have to remember to add this magic block of code:</span></div><div><span style="color:rgb(33,33,33)"><br></span></div><div><div style=""><font color="#212121"># Support substitution of the tools_dir with user parameters. This is</font></div><div style=""><font color="#212121"># used when we can't determine the tool dir at configuration time.</font></div><div style=""><font color="#212121">try:</font></div><div style=""><font color="#212121">    config.llvm_tools_dir = config.llvm_tools_dir % lit_config.params</font></div><div style=""><font color="#212121">    config.llvm_shlib_dir = config.llvm_shlib_dir % lit_config.params</font></div><div style=""><font color="#212121">except KeyError:</font></div><div style=""><font color="#212121">    e = sys.exc_info()[1]</font></div><div style=""><font color="#212121">    key, = e.args</font></div><div style=""><font color="#212121">    lit_config.fatal("unable to find %r parameter, use '--param=%s=VALUE'" % (key,key))</font></div></div><div style=""><font color="#212121"><br></font></div><div style=""><font color="#212121">to the file (even though only about 2 people actually understand what this does), which has caused problems several times.</font></div><div style=""><font color="#212121"><br></font></div><div style=""><font color="#212121">5) VSCode and Visual Studio both support opening CMake projects directly now, which bypasses MSBuild.  I don't know how well Visual Studio supports LLVM's CMake, but the last time I tried it with VSCode on Linux it worked fine.</font></div><div style=""><br></div><div style="">----</div><div style=""><br></div><div><font color="#212121">I mentioned earlier that the distinction between not *building* with a VS-generated project and not supporting the VS generator is important.</font></div><div><font color="#212121"><br></font></div><div><font color="#212121">I don't want to speak for everyone, but I believe that *most* people use the VS generator because they want IDE support for their projects.  They want to be able to browse code, hit F5 to debug, F9 to set breakpoints, etc.  They don't necessarily care that Ctrl+Shift+B is how the code is generated versus some other incantation.  I'm asserting that it's possible to still have all the things people actually want from the VS generator without actually building from inside of VS.  In fact, I've been doing this for several years.  The workflow is:</font></div><div><font color="#212121"><br></font></div><div><font color="#212121">1) Run CMake twice, generating to separate output directories.  Once using -G "Visual Studio 15 2017" and once using -G Ninja, each to different directories.</font></div><div><font color="#212121"><br></font></div><div><font color="#212121">2) Open the VS one.  You have full IDE support.</font></div><div><font color="#212121"><br></font></div><div><font color="#212121">3) Instead of hitting Ctrl+Shift+B to build, have a command prompt window open and type ninja.  Wait for it to complete.  If you want to you can make a custom tool command in Visual Studio so that you can access this from a keyboard shortcut.</font></div><div><font color="#212121"><br></font></div><div><font color="#212121">4) When you want to debug, set your startup project (as you normally would), right click and hit properties, go to Debugging, change Command from $(TargetPath) to <type the full path to bin/foo.exe of the program you want to debug>.</font></div><div><font color="#212121"><br></font></div><div><font color="#212121">5) Hit F5.</font></div><div><font color="#212121"><br></font></div><div><font color="#212121">In short, with only 2 simple additional steps (run CMake an extra time, and type a path into a window), people can have the exact workflow they are used to, plus faster builds, minus all of the problems and complexities associated with building from within VS.</font></div><div><font color="#212121"><br></font></div><div><font color="#212121">And we can simplify our CMake logic and lit configuration files as well.</font></div><div><font color="#212121"><br></font></div><div><font color="#212121">----</font></div><div><font color="#212121"><br></font></div><div><div><span style="color:rgb(33,33,33)"><br class="inbox-inbox-Apple-interchange-newline">[1] - </span><font color="#212121"><a href="https://reviews.llvm.org/D43096">https://reviews.llvm.org/D43096</a></font><br></div><div><font color="#212121">[2] - <a href="https://reviews.llvm.org/D46642">https://reviews.llvm.org/D46642</a></font></div><div><font color="#212121">[3] - <a href="https://reviews.llvm.org/D45918">https://reviews.llvm.org/D45918</a></font></div><div><font color="#212121">[4] - <a href="https://reviews.llvm.org/D45333">https://reviews.llvm.org/D45333</a></font></div><div><font color="#212121">[5] - <a href="https://reviews.llvm.org/D46334">https://reviews.llvm.org/D46334</a></font></div><div><font color="#212121"><br></font></div><br class="inbox-inbox-Apple-interchange-newline"></div></div>