[PATCH] D115568: [lld][CMake] Use `GNUInstallDirs` to support custom installation dirs

John Ericson via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Fri Dec 31 16:58:07 PST 2021


Ericson2314 added inline comments.


================
Comment at: lld/CMakeLists.txt:159
+  "${LLD_SOURCE_DIR}/cmake/modules"
+  "${LLD_SOURCE_DIR}/../cmake/Modules"
+  )
----------------
mstorsjo wrote:
> mstorsjo wrote:
> > This broke building in my setups.
> > 
> > In my setups, I still symlink the clang/lld directories into llvm/tools instead of invoking them via `LLVM_ENABLE_PROJECTS`. Thus referring to `${LLD_SOURCE_DIR}/..` ends up at `llvm-project/llvm/tools` instead of at `llvm-project`.
> > 
> > Is there some better cmake variable we could use here for unambiguously referring to the monorepo root?
> > 
> > (As backstory - a condition for me for getting away from building in that legacy setup, would be to be able to build things with the main llvm-project directory as main target directory for the cmake invocation. When pointing cmake at llvm-project/llvm, cmake uses relative paths for all files under the llvm subdir, but uses absolute paths for files under e.g. llvm-project/lld. With those tools symlinked under llvm-project/llvm/tools, it ends up using relative paths for all files. Using relative paths for compiling files is vital for being able to use ccache across different source trees, otherwise all built object files are unique for each source tree, due to e.g. paths in assert messages.)
> I guess a working, but inelegant, solution would be to use `${LLVM_MAIN_SRC_DIR}/../cmake` if it happens to exist, otherwise fall back on `${LLD_SOURCE_DIR}/../cmake`. The former would normally work, but could maybe fail if building lld standalone without being invoked from the main llvm tree, and the llvm-project source tree has been moved since llvm itself was built.
Sorry about this. The runtime libraries (compile-rt, libunwind, libcxxabi, etc.) do this already, so I figured it was OK.

As a temp hack, you can symlink the repo-root `cmake` as `llvm/tools/cmake`. That should fix the `../cmake`, right?

I think the better thing to do is simply make a new `CACHE PATH` for "shared cmake utils" in each of these projects, so you can set that one however you like.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D115568



More information about the llvm-commits mailing list