[CMake][compiler-rt] Don't load LLVM config in the runtimes build

LLVM runtimes build already loads the LLVM config and sets all
appropriate variables, no need to do it again.

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

GitOrigin-RevId: 9c2700dfa51a3f10e47f902939bbbe0a5b6b9c9b
diff --git a/CMakeLists.txt b/CMakeLists.txt
index f6b1f1a..e43017d 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -79,7 +79,9 @@
   set(CMAKE_CXX_STANDARD_REQUIRED YES)
   set(CMAKE_CXX_EXTENSIONS NO)
 
-  load_llvm_config()
+  if (NOT LLVM_RUNTIMES_BUILD)
+    load_llvm_config()
+  endif()
   if (TARGET intrinsics_gen)
     # Loading the llvm config causes this target to be imported so place it
     # under the appropriate folder in an IDE.
diff --git a/lib/builtins/CMakeLists.txt b/lib/builtins/CMakeLists.txt
index 42015ef..3eefba8 100644
--- a/lib/builtins/CMakeLists.txt
+++ b/lib/builtins/CMakeLists.txt
@@ -25,7 +25,9 @@
   include(base-config-ix)
   include(CompilerRTUtils)
 
-  load_llvm_config()
+  if (NOT LLVM_RUNTIMES_BUILD)
+    load_llvm_config()
+  endif()
   construct_compiler_rt_default_triple()
 
   include(SetPlatformToolchainTools)