[clang] [Clang] Include LLVM CodeGen CMake file (PR #109601)
Tristan Ross via cfe-commits
cfe-commits at lists.llvm.org
Sun Sep 22 21:05:47 PDT 2024
https://github.com/RossComputerGuy created https://github.com/llvm/llvm-project/pull/109601
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
```
>From a64ba9cc4f2c70f6040c1954fedc5674bba96575 Mon Sep 17 00:00:00 2001
From: Tristan Ross <tristan.ross at midstall.com>
Date: Sun, 22 Sep 2024 21:02:12 -0700
Subject: [PATCH] [Clang] Include LLVM CodeGen CMake file
---
clang/lib/CodeGen/CMakeLists.txt | 4 ++++
1 file changed, 4 insertions(+)
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
More information about the cfe-commits
mailing list