-
Notifications
You must be signed in to change notification settings - Fork 15.4k
[clang] fix clang_cmake_builddir #155844
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[clang] fix clang_cmake_builddir #155844
Conversation
|
@llvm/pr-subscribers-clang Author: Romaric Jodin (rjodinchr) ChangesWhen building llvm from a subdirectory (like clspv does) When building runtimes (libclc for example), the build fails looking for clang (through Fix that issue by setting For default llvm build (using llvm as the main cmake project), it should not change anything. Full diff: https://github.com/llvm/llvm-project/pull/155844.diff 1 Files Affected:
diff --git a/clang/cmake/modules/CMakeLists.txt b/clang/cmake/modules/CMakeLists.txt
index d2d68121371bf..b3b4a74f6d470 100644
--- a/clang/cmake/modules/CMakeLists.txt
+++ b/clang/cmake/modules/CMakeLists.txt
@@ -8,15 +8,14 @@ include(FindPrefixFromConfig)
# the usual CMake convention seems to be ${Project}Targets.cmake.
set(CLANG_INSTALL_PACKAGE_DIR "${CMAKE_INSTALL_PACKAGEDIR}/clang" CACHE STRING
"Path for CMake subdirectory for Clang (defaults to '${CMAKE_INSTALL_PACKAGEDIR}/clang')")
-# CMAKE_INSTALL_PACKAGEDIR might be absolute, so don't reuse below.
-set(clang_cmake_builddir "${CMAKE_BINARY_DIR}/lib${LLVM_LIBDIR_SUFFIX}/cmake/clang")
# Keep this in sync with llvm/cmake/CMakeLists.txt!
set(LLVM_INSTALL_PACKAGE_DIR "${CMAKE_INSTALL_PACKAGEDIR}/llvm" CACHE STRING
"Path for CMake subdirectory for LLVM (defaults to '${CMAKE_INSTALL_PACKAGEDIR}/llvm')")
# CMAKE_INSTALL_PACKAGEDIR might be absolute, so don't reuse below.
-string(REPLACE "${CMAKE_CFG_INTDIR}" "." llvm_cmake_builddir "${LLVM_LIBRARY_DIR}")
-set(llvm_cmake_builddir "${llvm_cmake_builddir}/cmake/llvm")
+string(REPLACE "${CMAKE_CFG_INTDIR}" "." llvm_builddir "${LLVM_LIBRARY_DIR}")
+set( llvm_cmake_builddir "${llvm_builddir}/cmake/llvm")
+set(clang_cmake_builddir "${llvm_builddir}/cmake/clang")
get_property(CLANG_EXPORTS GLOBAL PROPERTY CLANG_EXPORTS)
export(TARGETS ${CLANG_EXPORTS} FILE ${clang_cmake_builddir}/ClangTargets.cmake)
|
|
@frasercrmck please take a look |
When building llvm from a subdirectory (like clspv does) `CMAKE_BINARY_DIR` is at the top of the build directory. When building runtimes (libclc for example), the build fails looking for clang (through `find_package` looking at `LLVM_BINARY_DIR` with `NO_DEFAULT_PATH` & `NO_CMAKE_FIND_ROOT_PATH`) because clang is not in `LLVM_BINARY_DIR`. Fix that issue by setting `clang_cmake_builddir` the same way we set `llvm_cmake_builddir` from `LLVM_BINARY_DIR`. For default llvm build (using llvm as the main cmake project), it should not change anything.
420b284 to
bc8040d
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks ok to me. So far seems like even on main, setting -DLLVM_LIBDIR_SUFFIX seem to have the same effect so seems like this is ok
Adding @kwk in case I'm missing something
Was searching for somebody who could double-check, saw you were part of the release status team, so guessed maybe you were familiar with the importants bits around those build directories bits? Do you know a better contact point? |
Ah I see. @tru and @tstellar are probably more familiar with these bits. |
frasercrmck
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't feel able to approve, I'm afraid.
|
@tstellar would you be the one to review the build files? |
tstellar
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM. This seems OK to me since it's not going to affect most people's configuration.
|
LLVM Buildbot has detected a new failure on builder Full details are available at: https://lab.llvm.org/buildbot/#/builders/88/builds/16017 Here is the relevant piece of the build log for the reference |
|
LLVM Buildbot has detected a new failure on builder Full details are available at: https://lab.llvm.org/buildbot/#/builders/95/builds/18194 Here is the relevant piece of the build log for the reference |
|
Hi Folks, this results in This affects the nixpkgs build (likely others), and anywhere llvm is installed separately from clang, which is having to revert this patch to make the build work again: NixOS/nixpkgs#443041 Please could we entertain a revert and alternative solution? |
|
(@rjodinchr FYI) Hi, so to understand, is it when you do something like |
|
@Keenuts, no, the failing step is here ( which tries to write the config file during the cmake invocation. |
|
@peterwaller-arm do you have a way to get/reproduce the cmake configuration command line? |
|
Here's the full set of cmake flags passed by the nix buildsystem. At a glance I suppose the problematic one is LLVM_DIR which points into an installation tree of LLVM, not a build tree. |
Not totally certain of this because it's actually pointing at the From the CMakeCache I have: which are installation trees. These come via the installed cmake files: |
|
Thanks, I can reproduce with the following steps: |
Reverts #155844 Romaric is OOO for the next 2 weeks and I don't have the context on the other part (clspv) to propose a fix forward. Reverting for now.
Reverts llvm/llvm-project#155844 Romaric is OOO for the next 2 weeks and I don't have the context on the other part (clspv) to propose a fix forward. Reverting for now.
When building llvm from a subdirectory (like clspv does)
CMAKE_BINARY_DIRis at the top of the build directory.When building runtimes (libclc for example), the build fails looking for clang (through
find_packagelooking atLLVM_BINARY_DIRwithNO_DEFAULT_PATH&NO_CMAKE_FIND_ROOT_PATH) because clang is not inLLVM_BINARY_DIR.Fix that issue by setting
clang_cmake_builddirthe same way we setllvm_cmake_builddirfromLLVM_BINARY_DIR.For default llvm build (using llvm as the main cmake project), it should not change anything.