[clang] [Clang] Include LLVM CodeGen CMake file (PR #109601)

via cfe-commits cfe-commits at lists.llvm.org
Sun Sep 22 21:06:17 PDT 2024


llvmbot wrote:


<!--LLVM PR SUMMARY COMMENT-->

@llvm/pr-subscribers-clang

Author: Tristan Ross (RossComputerGuy)

<details>
<summary>Changes</summary>

Fixes a build failure with Clang being built from standalone sources (environments like Nix).

Exact error:
```
CMake Error at /nix/store/h9yw8mg03z3dz6rgcjr7gbzkjysqc2sj-llvm-20.0.0-unstable-2024-09-22-dev/lib/cmake/llvm/AddLLVM.cmake:587 (add_dependencies):
  The dependency target "vt_gen" of target "obj.clangCodeGen" does not exist.
Call Stack (most recent call first):
  cmake/modules/AddClang.cmake:109 (llvm_add_library)
  lib/CodeGen/CMakeLists.txt:57 (add_clang_library)


CMake Error at /nix/store/h9yw8mg03z3dz6rgcjr7gbzkjysqc2sj-llvm-20.0.0-unstable-2024-09-22-dev/lib/cmake/llvm/AddLLVM.cmake:807 (add_dependencies):
  The dependency target "vt_gen" of target "clangCodeGen" does not exist.
Call Stack (most recent call first):
  cmake/modules/AddClang.cmake:109 (llvm_add_library)
  lib/CodeGen/CMakeLists.txt:57 (add_clang_library)
```

This fix can be reproduced via the following script (just set out to some remote source and monorepoSrc to your LLVM source dir):
```
mkdir -p "$out"
cp -r ${monorepoSrc}/cmake "$out"
cp -r ${monorepoSrc}/${pname} "$out"
cp -r ${monorepoSrc}/clang-tools-extra "$out"

mkdir -p "$out/llvm/include/llvm/CodeGen"
cp -r ${monorepoSrc}/llvm/include/llvm/CodeGen/CMakeLists.txt "$out/llvm/include/llvm/CodeGen/"

mkdir -p "$out/clang/include/llvm"
cp -r ${monorepoSrc}/llvm/include/llvm/CodeGen $out/clang/include/llvm/CodeGen
```

---
Full diff: https://github.com/llvm/llvm-project/pull/109601.diff


1 Files Affected:

- (modified) clang/lib/CodeGen/CMakeLists.txt (+4) 


``````````diff
diff --git a/clang/lib/CodeGen/CMakeLists.txt b/clang/lib/CodeGen/CMakeLists.txt
index 868ec847b9634b..2b1be3f4c3035d 100644
--- a/clang/lib/CodeGen/CMakeLists.txt
+++ b/clang/lib/CodeGen/CMakeLists.txt
@@ -1,3 +1,7 @@
+if(EXISTS ${LLVM_MAIN_SRC_DIR}/include/llvm/CodeGen)
+  add_subdirectory(${LLVM_MAIN_SRC_DIR}/include/llvm/CodeGen llvm/lib/CodeGen)
+endif()
+
 set(LLVM_LINK_COMPONENTS
   AggressiveInstCombine
   Analysis

``````````

</details>


https://github.com/llvm/llvm-project/pull/109601


More information about the cfe-commits mailing list