3

I want to set up a debugger for Visual Studio Code so I tried to build LLVM environment so as to have LLDB on my computer. But the build fails with following output:

CMake Warning at cmake/modules/GetHostTriple.cmake:28 (message):
  unable to determine host target triple
Call Stack (most recent call first):
  cmake/config-ix.cmake:401 (get_host_triple)
  CMakeLists.txt:670 (include)
 
 
CMake Error at cmake/config-ix.cmake:409 (string):
  string sub-command REGEX, mode MATCH needs at least 5 arguments total to
  command.
Call Stack (most recent call first):
  CMakeLists.txt:670 (include)
 
CMake Error at cmake/config-ix.cmake:453 (message):
  Unknown architecture host
Call Stack (most recent call first):
  CMakeLists.txt:670 (include)

I use clang v11.0.1, CMake v3.18.0-rc4, and Ninja v1.10.2.

Vlad Tkach
  • 63
  • 6

1 Answers1

7

I had same problem and fixed by adding this line manually as build option:

-DLLVM_HOST_TRIPLE=x86_64
Dharman
  • 30,962
  • 25
  • 85
  • 135
Celuk
  • 561
  • 7
  • 17
  • Where did you add this? – user162988 Mar 29 '22 at 21:33
  • @user162988 While building from [source](https://github.com/llvm/llvm-project), you can add this flag like other options, for example: `cmake -G "Visual Studio 16 2019" -Thost=x64 -DLLVM_ENABLE_PROJECTS=clang -DLLVM_TARGETS_TO_BUILD=all` `-DLLVM_HOST_TRIPLE=x86_64` `../llvm` So here, you can use `Ninja` after `-G` flag as generator like asked in the question and you can use also different `-D` flags to configure project anyway you like. – Celuk Mar 30 '22 at 00:40
  • This can be done in your newly created `build` directory by command window and after that `cmake --build .` build the whole thing with your configurations. Please look at how to build llvm in detail because I just gave an example that I haven't tried at the moment, that's why many other errors can occur when you are building, so you may need to change or add some flags. So, the answer to your question is that I was added this flag to my cmake configurations like the example that I gave and the problem was solved for me at that time. – Celuk Mar 30 '22 at 00:56
  • @Celuk How did you find this? Couldn't find it on the "Building LLVM with CMake" page. – User 10482 Aug 22 '23 at 01:52
  • @User10482 by looking llvm internals, cmake files and by trial and error. LLVM is not well documented I think. – Celuk Aug 22 '23 at 04:10