Building the LLVM with msbuild

hey I’m trying to build the LLVM.sln with msbuild but the process seems to fail after 2:30 hrs
the cmd is “msbuild /p:Configuration=release LLVM.sln”
On the guide it specifies to build with cmake, is it possible to do so with MSBuild?

I doubt that the SLN is still up-to-date. You can generate a sln from CMake though, but I really recommend ninja instead.

Oh my… that solution hasn’t been updated in years.

@hansw2000, git log looks like you were the last one to touch those files. Should we just delete them at this point since they clearly aren’t actively maintained?

Is there a guide available on how to create a valid .sln ?
I need to build it with msbuild specifically for testing.
Thanks!

@IncredibleMax, you can generate a solution file using CMake, or you can open the LLVM checkout in Visual Studio and allow Visual Studio’s CMake integration to configure and build using Ninja.

There are some docs here: Getting Started with the LLVM System using Microsoft Visual Studio — LLVM 16.0.0git documentation

Also, looking at that msbuild code I think it is actually templates for creating msbuild projects that use LLVM & Clang not intended for building LLVM. If that is the case we could probably benefit from a readme and maybe renaming the solution file…

Those files are not related to building LLVM, they’re for building the LLVM’s Visual Studio integration. That has been obsolete for a few years since Microsoft started providing an integration in VS2019 themselves. Since this is both obsolete and abandoned, I agree we should delete it. Here’s the patch: ⚙ D124521 Remove the Visual Studio/MSBuild integration

(I have no idea if this is related to the original question though, I’m not sure where they got their LLVM.sln from…)

Hi, everyone so I built .sln file with cmake. but when I try to build I get the following LNK errors:

cmd used was: msbuild /p:Configuration=debug;platform=x64 /t:BuildGenerateSources;BuildCompile;BuildLink LLVM.sln

"C:\projects_to_build\llvm-project\build\LLVM.sln" (BuildGenerateSources;BuildCompile;BuildLink target) (1) ->
"C:\projects_to_build\llvm-project\build\ALL_BUILD.vcxproj.metaproj" (BuildGenerateSources target) (2) ->
"C:\projects_to_build\llvm-project\build\tools\llvm-shlib\LLVM-C.vcxproj.metaproj" (BuildGenerateSources target) (18) ->
"C:\projects_to_build\llvm-project\build\tools\llvm-shlib\LLVM-C_exports.vcxproj.metaproj" (BuildGenerateSources target) (19) ->
"C:\projects_to_build\llvm-project\build\lib\Transforms\AggressiveInstCombine\LLVMAggressiveInstCombine.vcxproj.metaproj" (BuildGenerateSources tar
get) (20) ->
"C:\projects_to_build\llvm-project\build\lib\Analysis\LLVMAnalysis.vcxproj.metaproj" (BuildGenerateSources target) (21) ->
"C:\projects_to_build\llvm-project\build\lib\Bitcode\Reader\LLVMBitReader.vcxproj.metaproj" (BuildGenerateSources target) (24) ->
"C:\projects_to_build\llvm-project\build\lib\IR\LLVMCore.vcxproj.metaproj" (BuildGenerateSources target) (27) ->
"C:\projects_to_build\llvm-project\build\lib\Remarks\LLVMRemarks.vcxproj.metaproj" (BuildGenerateSources target) (28) ->
"C:\projects_to_build\llvm-project\build\include\llvm\IR\intrinsics_gen.vcxproj.metaproj" (BuildGenerateSources target) (29) ->
"C:\projects_to_build\llvm-project\build\include\llvm\IR\intrinsics_gen.vcxproj" (BuildGenerateSources target) (38) ->
"C:\projects_to_build\llvm-project\build\utils\TableGen\llvm-tblgen.vcxproj" (default target) (37:3) ->
(Link target) ->
  LINK : fatal error LNK1104: cannot open file '..\..\Debug\lib\LLVMSupport.lib' [C:\projects_to_build\llvm-project\build\utils\TableGen\llvm-tblge
n.vcxproj]

"C:\projects_to_build\llvm-project\build\LLVM.sln" (BuildGenerateSources;BuildCompile;BuildLink target) (1) ->
"C:\projects_to_build\llvm-project\build\ALL_BUILD.vcxproj.metaproj" (BuildGenerateSources target) (2) ->
"C:\projects_to_build\llvm-project\build\tools\clang\tools\apinotes-test\apinotes-test.vcxproj.metaproj" (BuildGenerateSources target) (149) ->
"C:\projects_to_build\llvm-project\build\tools\clang\clang-tablegen-targets.vcxproj.metaproj" (BuildGenerateSources target) (150) ->
"C:\projects_to_build\llvm-project\build\tools\clang\include\clang\Basic\ClangARMCdeBuiltinAliases.vcxproj.metaproj" (BuildGenerateSources target)
(151) ->
"C:\projects_to_build\llvm-project\build\tools\clang\include\clang\Basic\ClangARMCdeBuiltinAliases.vcxproj" (BuildGenerateSources target) (160) ->
"C:\projects_to_build\llvm-project\build\tools\clang\utils\TableGen\clang-tblgen.vcxproj" (default target) (159:3) ->
  LINK : fatal error LNK1104: cannot open file '..\..\..\..\Debug\lib\LLVMSupport.lib' [C:\projects_to_build\llvm-project\build\tools\clang\utils\T
ableGen\clang-tblgen.vcxproj]

couldn’t find the specified file in the source directories

I will sincerely appreciate any help!

(post deleted by author)

Which version of LLVM are you trying to build and what was your CMake invocation?

I cloned the git repository as is, and generated .sln
This is how .sln was generated:

cmake -S llvm -B build -DLLVM_ENABLE_PROJECTS=clang -DLLVM_TARGETS_TO_BUILD=X86 -Thost=x64

I am not very familiar with msbuild, but if I would guess the problem is with the /t argument above and what you need to pass there.

That said - I would not recommend msbuild at all, ninja is faster and better tested.

I moved the topic out of “Project Infrastructure / GitHub” as it is certainly not GitHub related.