[CMake][Compiler-rt] Compute `LLVM_MAIN_SRC_DIR` assuming the monorepo

Authored by delcypher on Tue, Mar 30, 12:50 PM.


[CMake][Compiler-rt] Compute LLVM_MAIN_SRC_DIR assuming the monorepo

When doing a standalone compiler-rt build we currently rely on
getting information from the llvm-config binary. Previously
we would rely on calling llvm-config --src-root to find the
LLVM sources. Unfortunately the returned path could easily be wrong
if the sources were built on another machine.

Now that compiler-rt is part of a monorepo we can easily fix this
problem by finding the LLVM source tree next to compiler-rt in
the monorepo. We do this regardless of whether or not the llvm-config
binary is available which moves us one step closer to not requiring
llvm-config to be available.

To try avoid anyone breaking anyone who relies on the current behavior,
if the path assuming the monorepo layout doesn't exist we invoke
llvm-config --src-root to get the path. A deprecation warning is
emitted if this path is taken because we should remove this path
in the future given that other runtimes already assume the monorepo

We also now emit a warning if LLVM_MAIN_SRC_DIR does not exist.
The intention is that this should be a hard error in future but
to avoid breaking existing users we'll keep this as a warning
for now.


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