[all-commits] [llvm/llvm-project] 52bcda: [build] Fix stand-alone builds of clang.

Francesco Petrogalli via All-commits all-commits at lists.llvm.org
Mon Jan 23 13:12:46 PST 2023


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: 52bcdac3b8425e20023151bb726b56fd6f62ec17
      https://github.com/llvm/llvm-project/commit/52bcdac3b8425e20023151bb726b56fd6f62ec17
  Author: Francesco Petrogalli <francesco.petrogalli at apple.com>
  Date:   2023-01-23 (Mon, 23 Jan 2023)

  Changed paths:
    M clang/lib/Basic/CMakeLists.txt
    M clang/lib/Driver/CMakeLists.txt
    M llvm/cmake/modules/LLVMConfig.cmake.in

  Log Message:
  -----------
  [build] Fix stand-alone builds of clang.

The header file `llvm/include/llvm/Targetparser/RISCVTargetParser.h`
relies on the auto-generated *.inc file associated to the tablegen
target `RISCVTargetParserTableGen`.

Both clangBasic and clangDriver include `RISCVTargetParser.h`,
therefore we need to make sure that the *.inc file is avaiable to
avoid compilation errors like the following:

    FAILED: tools/clang/lib/Basic/CMakeFiles/obj.clangBasic.dir/Targets/RISCV.cpp.o
    /usr/bin/c++  [bunch of non interesting stuff]  -c <path-to>/llvm-project/clang/lib/Basic/Targets/RISCV.cpp
    In file included from <path-to>/llvm-project/clang/lib/Basic/Targets/RISCV.cpp:19:
    <path-to>/llvm-project/llvm/include/llvm/TargetParser/RISCVTargetParser.h:29:10: fatal error: llvm/TargetParser/RISCVTargetParserDef.inc: No such file or directory
      29 | #include "llvm/TargetParser/RISCVTargetParserDef.inc"
         |          ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

The stand-alone build of `clang` has been tested with the following
script (see [*] for further information):

```
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/lit \
      -DLLVM_ROOT=$installprefix
```

[*] https://llvm.org/docs/GettingStarted.html#stand-alone-builds

Differential Revision: https://reviews.llvm.org/D141581




More information about the All-commits mailing list