fpetrogalli added a comment.

@barannikov88  - Imam stuck with an incomplete explanation:

The issue raised by @mgorny is about stand-alone 
<https://llvm.org/docs/GettingStarted.html#stand-alone-builds> builds. In this 
build configuration, clang is built separately from LLVM, which is first build 
and installed in a folder.

When clang is build as a stand-alone project, clang does not have access to the 
cmake configuration of LLVM. Therefore it knows nothing about the tablegen 
target `RISCVTargetParserTableGen`.

The's why we see the following error when building stand-alone clang on `main`:

  CMake Error at 
/Users/fpetrogalli/projects/cpu-defs/install/lib/cmake/llvm/AddLLVM.cmake:536 
(add_dependencies):
    The dependency target "RISCVTargetParserTableGen" of target
    "obj.clangBasic" does not exist.
  Call Stack (most recent call first):
    cmake/modules/AddClang.cmake:106 (llvm_add_library)
    lib/Basic/CMakeLists.txt:40 (add_clang_library)

I do not know why `LLVMTargetParser` (which is also specified in the cmake 
configuration of llvm) is instead recognised as a valid dependencies of clang 
on some LLVM library. Maybe because cmake looks in the prefix folder where LLVM 
was installed and finds the object file of the library?

FWIW, I was able to reproduce the issue reported by @mgorny via the following 
script when run on `main`:

  #!/bin/sh
  
  build_llvm=`pwd`/build-llvm
  build_clang=`pwd`/build-clang
  installprefix=`pwd`/install
  llvm=`pwd`/llvm-project
  mkdir -p $build_llvm
  mkdir -p $installprefix
  
  cmake -G Ninja -S $llvm/llvm -B $build_llvm \
        -DLLVM_INSTALL_UTILS=ON \
        -DCMAKE_INSTALL_PREFIX=$installprefix \
        -DCMAKE_BUILD_TYPE=Release
  
  
  ninja -C $build_llvm install
  
  cmake -G Ninja -S $llvm/clang -B $build_clang \
        -DLLVM_EXTERNAL_LIT=$build_llvm/utils/llvm-lit \
        -DLLVM_ROOT=$installprefix

Given it was an issue that cmake itself was reporting (and not a build time 
failure), I thought that its disappearance after applying this patch was a 
signal thatI was doing the right thing.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D141581

_______________________________________________
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to