Re: [Lldb-commits] [PATCH] D15067: Design building out of sources

2016-05-11 Thread Kamil Rytarowski via lldb-commits
krytarowski added a comment.

In http://reviews.llvm.org/D15067#419964, @labath wrote:

> Good question. I don't really have an opinion on that... Is it just that 
> single line? (this would be simpler if you uploaded the final version :) ). 
> If it just that single line, then I think it's fine. If you also need to play 
> with the ADDITIONAL_VERSIONS and such, then we should think about making a 
> macro or doing something else to avoid code duplication (there is already a 
> FIXME in scripts/Python/modules/readline mentioning the additional versions).


Sorry for delay. I'm going to update the diff.


Repository:
  rL LLVM

http://reviews.llvm.org/D15067



___
lldb-commits mailing list
lldb-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


Re: [Lldb-commits] [PATCH] D15067: Design building out of sources

2016-05-03 Thread Pavel Labath via lldb-commits
labath added a comment.

Good question. I don't really have an opinion on that... Is it just that single 
line? (this would be simpler if you uploaded the final version :) ). If it just 
that single line, then I think it's fine. If you also need to play with the 
ADDITIONAL_VERSIONS and such, then we should think about making a macro or 
doing something else to avoid code duplication (there is already a FIXME in 
scripts/Python/modules/readline mentioning the additional versions).


Repository:
  rL LLVM

http://reviews.llvm.org/D15067



___
lldb-commits mailing list
lldb-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


Re: [Lldb-commits] [PATCH] D15067: Design building out of sources

2016-05-03 Thread Kamil Rytarowski via lldb-commits
krytarowski added a comment.

In http://reviews.llvm.org/D15067#419632, @labath wrote:

> Looks good.


Thanks!

Are you accepting it with the patch in `scripts/CMakeLists.txt` as noted in the 
comment?


Repository:
  rL LLVM

http://reviews.llvm.org/D15067



___
lldb-commits mailing list
lldb-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


Re: [Lldb-commits] [PATCH] D15067: Design building out of sources

2016-05-03 Thread Pavel Labath via lldb-commits
labath accepted this revision.
labath added a comment.

Looks good.


Repository:
  rL LLVM

http://reviews.llvm.org/D15067



___
lldb-commits mailing list
lldb-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


Re: [Lldb-commits] [PATCH] D15067: Design building out of sources

2016-05-01 Thread Kamil Rytarowski via lldb-commits
krytarowski added inline comments.


Comment at: cmake/modules/LLDBStandalone.cmake:85
@@ -63,3 +84,3 @@
 
   if (PYTHON_EXECUTABLE STREQUAL "")
 set(Python_ADDITIONAL_VERSIONS 3.5 3.4 3.3 3.2 3.1 3.0 2.7 2.6 2.5)

When I am including conditionally `include(FindPythonInterp)` with this 
`PYTHON_EXECUTABLE STREQUAL ""` conditional I'm facing the said issue with:

```
CMake Error at scripts/cmake_install.cmake:31 (file):
  file INSTALL cannot find
  "/tmp/pkgsrc-tmp/wip/lldb-git/work/build/lib/python.".
Call Stack (most recent call first):
  cmake_install.cmake:37 (include)
  


*** Error code 1
```

If I put here `include(FindPythonInterp)` unconditionally, there is no error in 
`cmake_install.cmake:37`.


Repository:
  rL LLVM

http://reviews.llvm.org/D15067



___
lldb-commits mailing list
lldb-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


Re: [Lldb-commits] [PATCH] D15067: Design building out of sources

2016-05-01 Thread Kamil Rytarowski via lldb-commits
krytarowski added a comment.

please take a look @zturner @labath


Repository:
  rL LLVM

http://reviews.llvm.org/D15067



___
lldb-commits mailing list
lldb-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


Re: [Lldb-commits] [PATCH] D15067: Design building out of sources

2016-05-01 Thread Kamil Rytarowski via lldb-commits
krytarowski updated this revision to Diff 55742.
krytarowski added a comment.

Revamp the patch and reduce it only to the CMake part.

Leave regex code for later.


Repository:
  rL LLVM

http://reviews.llvm.org/D15067

Files:
  cmake/modules/LLDBStandalone.cmake

Index: cmake/modules/LLDBStandalone.cmake
===
--- cmake/modules/LLDBStandalone.cmake
+++ cmake/modules/LLDBStandalone.cmake
@@ -6,57 +6,78 @@
 
   option(LLVM_INSTALL_TOOLCHAIN_ONLY "Only include toolchain files in the 'install' target." OFF)
 
-  set(LLDB_PATH_TO_LLVM_SOURCE "" CACHE PATH
-"Path to LLVM source code. Not necessary if using an installed LLVM.")
-  set(LLDB_PATH_TO_LLVM_BUILD "" CACHE PATH
-"Path to the directory where LLVM was built or installed.")
-
-  set(LLDB_PATH_TO_CLANG_SOURCE "" CACHE PATH
-"Path to Clang source code. Not necessary if using an installed Clang.")
-  set(LLDB_PATH_TO_CLANG_BUILD "" CACHE PATH
-"Path to the directory where Clang was built or installed.")
-
-  if (LLDB_PATH_TO_LLVM_SOURCE)
-if (NOT EXISTS "${LLDB_PATH_TO_LLVM_SOURCE}/cmake/config-ix.cmake")
-  message(FATAL_ERROR "Please set LLDB_PATH_TO_LLVM_SOURCE to the root "
-  "directory of LLVM source code.")
+  # Rely on llvm-config.
+  set(CONFIG_OUTPUT)
+  find_program(LLVM_CONFIG "llvm-config")
+  if(LLVM_CONFIG)
+message(STATUS "Found LLVM_CONFIG as ${LLVM_CONFIG}")
+set(CONFIG_COMMAND ${LLVM_CONFIG}
+  "--assertion-mode"
+  "--bindir"
+  "--libdir"
+  "--includedir"
+  "--prefix"
+  "--src-root")
+execute_process(
+  COMMAND ${CONFIG_COMMAND}
+  RESULT_VARIABLE HAD_ERROR
+  OUTPUT_VARIABLE CONFIG_OUTPUT
+)
+if(NOT HAD_ERROR)
+  string(REGEX REPLACE
+"[ \t]*[\r\n]+[ \t]*" ";"
+CONFIG_OUTPUT ${CONFIG_OUTPUT})
+
 else()
-  get_filename_component(LLVM_MAIN_SRC_DIR ${LLDB_PATH_TO_LLVM_SOURCE}
- ABSOLUTE)
-  set(LLVM_MAIN_INCLUDE_DIR "${LLVM_MAIN_SRC_DIR}/include")
-  list(APPEND CMAKE_MODULE_PATH "${LLVM_MAIN_SRC_DIR}/cmake/modules")
+  string(REPLACE ";" " " CONFIG_COMMAND_STR "${CONFIG_COMMAND}")
+  message(STATUS "${CONFIG_COMMAND_STR}")
+  message(FATAL_ERROR "llvm-config failed with status ${HAD_ERROR}")
 endif()
+  else()
+message(FATAL_ERROR "llvm-config not found -- ${LLVM_CONFIG}")
   endif()
 
-  if (LLDB_PATH_TO_CLANG_SOURCE)
-  get_filename_component(CLANG_MAIN_SRC_DIR ${LLDB_PATH_TO_CLANG_SOURCE}
- ABSOLUTE)
-  set(CLANG_MAIN_INCLUDE_DIR "${CLANG_MAIN_SRC_DIR}/include")
+  list(GET CONFIG_OUTPUT 0 ENABLE_ASSERTIONS)
+  list(GET CONFIG_OUTPUT 1 TOOLS_BINARY_DIR)
+  list(GET CONFIG_OUTPUT 2 LIBRARY_DIR)
+  list(GET CONFIG_OUTPUT 3 INCLUDE_DIR)
+  list(GET CONFIG_OUTPUT 4 LLVM_OBJ_ROOT)
+  list(GET CONFIG_OUTPUT 5 MAIN_SRC_DIR)
+
+  if(NOT MSVC_IDE)
+set(LLVM_ENABLE_ASSERTIONS ${ENABLE_ASSERTIONS}
+  CACHE BOOL "Enable assertions")
+# Assertions should follow llvm-config's.
+mark_as_advanced(LLVM_ENABLE_ASSERTIONS)
   endif()
 
-  list(APPEND CMAKE_MODULE_PATH "${LLDB_PATH_TO_LLVM_BUILD}/lib${LLVM_LIBDIR_SUFFIX}/cmake/llvm")
+  set(LLVM_TOOLS_BINARY_DIR ${TOOLS_BINARY_DIR} CACHE PATH "Path to llvm/bin")
+  set(LLVM_LIBRARY_DIR ${LIBRARY_DIR} CACHE PATH "Path to llvm/lib")
+  set(LLVM_MAIN_INCLUDE_DIR ${INCLUDE_DIR} CACHE PATH "Path to llvm/include")
+  set(LLVM_BINARY_DIR ${LLVM_OBJ_ROOT} CACHE PATH "Path to LLVM build tree")
+  set(LLVM_MAIN_SRC_DIR ${MAIN_SRC_DIR} CACHE PATH "Path to LLVM source tree")
 
-  if (LLDB_PATH_TO_LLVM_BUILD)
-get_filename_component(PATH_TO_LLVM_BUILD ${LLDB_PATH_TO_LLVM_BUILD}
-   ABSOLUTE)
-  else()
-message(FATAL_ERROR "Please set LLDB_PATH_TO_LLVM_BUILD to the root "
-"directory of LLVM build or install site.")
-  endif()
+  find_program(LLVM_TABLEGEN_EXE "llvm-tblgen" ${LLVM_TOOLS_BINARY_DIR}
+NO_DEFAULT_PATH)
 
-  if (LLDB_PATH_TO_CLANG_BUILD)
-get_filename_component(PATH_TO_CLANG_BUILD ${LLDB_PATH_TO_CLANG_BUILD}
-   ABSOLUTE)
+  set(LLVM_CMAKE_PATH "${LLVM_BINARY_DIR}/lib${LLVM_LIBDIR_SUFFIX}/cmake/llvm")
+  set(LLVMCONFIG_FILE "${LLVM_CMAKE_PATH}/LLVMConfig.cmake")
+  if(EXISTS ${LLVMCONFIG_FILE})
+list(APPEND CMAKE_MODULE_PATH "${LLVM_CMAKE_PATH}")
+include(${LLVMCONFIG_FILE})
   else()
-message(FATAL_ERROR "Please set LLDB_PATH_TO_CLANG_BUILD to the root "
-"directory of Clang build or install site.")
+message(FATAL_ERROR "Not found: ${LLVMCONFIG_FILE}")
   endif()
 
-
-  # These variables are used by add_llvm_library.
+  # They are used as destination of target generators.
   set(LLVM_RUNTIME_OUTPUT_INTDIR ${CMAKE_BINARY_DIR}/${CMAKE_CFG_INTDIR}/bin)
   set(LLVM_LIBRARY_OUTPUT_INTDIR ${CMAKE_BINARY_DIR}/${CMAKE_CFG_INTDIR}/lib${LLVM_LIBDIR_SUFFIX})
-  set(LLVM_LIBRARY_DIR ${LLVM_LIBRARY_OUTPUT_INTDIR})
+  if(WIN32 

Re: [Lldb-commits] [PATCH] D15067: Design building out of sources

2016-02-09 Thread Kamil Rytarowski via lldb-commits
krytarowski added a comment.

Just in case someone will be quicker, new version against revamped CMake dirs 
is in pkgsrc-wip/lldb-git


Repository:
  rL LLVM

http://reviews.llvm.org/D15067



___
lldb-commits mailing list
lldb-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


Re: [Lldb-commits] [PATCH] D15067: Design building out of sources

2016-01-23 Thread Kamil Rytarowski via lldb-commits
krytarowski added a comment.

For the reference, I hold on with pushing this forward, till I will get 
significantly larger coverage with tests on my platform.

I keep this patch locally for local development.


Repository:
  rL LLVM

http://reviews.llvm.org/D15067



___
lldb-commits mailing list
lldb-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


Re: [Lldb-commits] [PATCH] D15067: Design building out of sources

2015-12-01 Thread Eugene Zelenko via lldb-commits
Eugene.Zelenko added a comment.

In http://reviews.llvm.org/D15067#299220, @labath wrote:

> In http://reviews.llvm.org/D15067#298902, @Eugene.Zelenko wrote:
>
> > But it's necessary to pass path from CMake command line argument to 
> > find_program after PATHS. Another problem if default OS location (if Clang 
> > installed and of old version) will be returned instead of build one.
>
>
> I don't know what would be the idiomatic cmake-fu to achieve that, but I'd 
> just pass the the full path to the llvm-config binary, including the name. 
> This way, we could also handle cases when the binary has a version suffix 
> (e.g., debian likes to ship the binary as llvm-config-3.x).


I think find_program() should be called if LLVM_CONFIG is empty or not exist.


Repository:
  rL LLVM

http://reviews.llvm.org/D15067



___
lldb-commits mailing list
lldb-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


Re: [Lldb-commits] [PATCH] D15067: Design building out of sources

2015-12-01 Thread Pavel Labath via lldb-commits
labath added a comment.

In http://reviews.llvm.org/D15067#298902, @Eugene.Zelenko wrote:

> But it's necessary to pass path from CMake command line argument to 
> find_program after PATHS. Another problem if default OS location (if Clang 
> installed and of old version) will be returned instead of build one.


I don't know what would be the idiomatic cmake-fu to achieve that, but I'd just 
pass the the full path to the llvm-config binary, including the name. This way, 
we could also handle cases when the binary has a version suffix (e.g., debian 
likes to ship the binary as llvm-config-3.x).


Repository:
  rL LLVM

http://reviews.llvm.org/D15067



___
lldb-commits mailing list
lldb-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


Re: [Lldb-commits] [PATCH] D15067: Design building out of sources

2015-11-30 Thread Eugene Zelenko via lldb-commits
Eugene.Zelenko added a comment.

In http://reviews.llvm.org/D15067#298830, @krytarowski wrote:

> In http://reviews.llvm.org/D15067#298701, @Eugene.Zelenko wrote:
>
> > I build LLVM/Clang with LLVM_ENABLE_WARNINGS=ON, so I'll need to use 
> > llvm-config from build directory. I'm not sure how well find_program will 
> > work if path to /bin will be not added to PATH, so 
> > probably will be good idea to allow LLVM_CONFIG to be set in Cmake command 
> > line and use find_program only if LLVM_CONFIG is not set.
>
>
> This should be already handled by CMake:
>  https://cmake.org/cmake/help/v3.0/command/find_program.html


But it's necessary to pass path from CMake command line argument to 
find_program after PATHS. Another problem if default OS location (if Clang 
installed and of old version) will be returned instead of build one.


Repository:
  rL LLVM

http://reviews.llvm.org/D15067



___
lldb-commits mailing list
lldb-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


Re: [Lldb-commits] [PATCH] D15067: Design building out of sources

2015-11-30 Thread Zachary Turner via lldb-commits
zturner added a subscriber: zturner.
zturner requested changes to this revision.
zturner added a reviewer: zturner.
zturner added a comment.
This revision now requires changes to proceed.

@labath, can you point out where clang is doing the same thing?  I searched for 
files named `regcomp.c` for example, and only found the one copy in llvm.  
Duplicating code seems like a blocking issue to me, this will make the THIRD 
regex implementation in LLDB if we do this.

Standalone build does not mean you don't need to link against LLVM libraries.


Repository:
  rL LLVM

http://reviews.llvm.org/D15067



___
lldb-commits mailing list
lldb-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


Re: [Lldb-commits] [PATCH] D15067: Design building out of sources

2015-11-30 Thread Zachary Turner via lldb-commits
zturner added a comment.

lldb-mi is including from the source tree, it should be including from the 
incldue tree.

In other words, the incldue should be changed to:

  #include "llvm/Support/Regex.h"

and the code should be updated to use `llvm::Regex` instead of the raw c 
functions.


Repository:
  rL LLVM

http://reviews.llvm.org/D15067



___
lldb-commits mailing list
lldb-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


Re: [Lldb-commits] [PATCH] D15067: Design building out of sources

2015-11-30 Thread Pavel Labath via lldb-commits
labath requested changes to this revision.
labath added a comment.

OK, llvm seems to export the regex interface via include/llvm/Support/Regex.h. 
I think we should fix lldb-mi to use this interface instead, and then our 
problem will go away. The MI wrapper seems to be very simple, so it should not 
be a big problem to port it over.


Repository:
  rL LLVM

http://reviews.llvm.org/D15067



___
lldb-commits mailing list
lldb-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


Re: [Lldb-commits] [PATCH] D15067: Design building out of sources

2015-11-30 Thread Pavel Labath via lldb-commits
labath added a comment.

Hmm.. you are right, of course.. I was only looking at the second version of 
the patch, which seems to omit the regex files. However that seems to by 
accidental, as they are still references in the CMake files.

I agree that we should not copy the files over.

@krytarowski, I assume that the problem is that the regex headers are in 
llvm/lib (instead of include/llvm), which means they are not installed, and you 
cannot include them later. Is that correct?

It seems that is being done on purpose, so I guess it's a question whether 
lldb-mi should have been using them in the first place. We'll need to think 
about this more.


Repository:
  rL LLVM

http://reviews.llvm.org/D15067



___
lldb-commits mailing list
lldb-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


Re: [Lldb-commits] [PATCH] D15067: Design building out of sources

2015-11-30 Thread Eugene Zelenko via lldb-commits
Eugene.Zelenko added a comment.

I build LLVM/Clang with LLVM_ENABLE_WARNINGS=ON, so I'll need to use 
llvm-config from build directory. I'm not sure how well find_program will work 
if path to /bin will be not added to PATH, so probably will be 
good idea to allow LLVM_CONFIG to be set in Cmake command line and use 
find_program only if LLVM_CONFIG is not set.


Repository:
  rL LLVM

http://reviews.llvm.org/D15067



___
lldb-commits mailing list
lldb-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


Re: [Lldb-commits] [PATCH] D15067: Design building out of sources

2015-11-30 Thread Kamil Rytarowski via lldb-commits
krytarowski added a comment.

In http://reviews.llvm.org/D15067#298701, @Eugene.Zelenko wrote:

> I build LLVM/Clang with LLVM_ENABLE_WARNINGS=ON, so I'll need to use 
> llvm-config from build directory. I'm not sure how well find_program will 
> work if path to /bin will be not added to PATH, so probably 
> will be good idea to allow LLVM_CONFIG to be set in Cmake command line and 
> use find_program only if LLVM_CONFIG is not set.


This should be already handled by CMake:
https://cmake.org/cmake/help/v3.0/command/find_program.html


Repository:
  rL LLVM

http://reviews.llvm.org/D15067



___
lldb-commits mailing list
lldb-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


Re: [Lldb-commits] [PATCH] D15067: Design building out of sources

2015-11-30 Thread Pavel Labath via lldb-commits
labath added subscribers: artagnon, Eugene.Zelenko, tfiala.
labath added a comment.

It seems to follow what clang does here, so I think it should be ok.

However, I'm not actually using the standalone build... I've added some people 
who I think might be using it. Let's give them a bit of time to respond. If 
there are no objections, then I'll commit this..


Repository:
  rL LLVM

http://reviews.llvm.org/D15067



___
lldb-commits mailing list
lldb-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


Re: [Lldb-commits] [PATCH] D15067: Design building out of sources

2015-11-29 Thread Kamil Rytarowski via lldb-commits
krytarowski added a comment.

@labath feel free to disagree with the regex files. It was copied from LLVM. If 
you disagree, help me please to export it in LLVM build for everybody or find a 
better solution.

pkgsrc-wip commit affirming that it works:
https://wip.pkgsrc.org/cgi-bin/gitweb.cgi?p=pkgsrc-wip.git;a=commit;h=85621c794d26ed60844215ae16d3b4a4309d969e

Without this patch I'm falling asleep in front of the computer waiting for 
build to be finished.


Repository:
  rL LLVM

http://reviews.llvm.org/D15067



___
lldb-commits mailing list
lldb-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits


Re: [Lldb-commits] [PATCH] D15067: Design building out of sources

2015-11-29 Thread Kamil Rytarowski via lldb-commits
krytarowski updated this revision to Diff 41366.
krytarowski added a comment.

Upload the proper latest patch.


Repository:
  rL LLVM

http://reviews.llvm.org/D15067

Files:
  cmake/modules/LLDBStandalone.cmake
  scripts/CMakeLists.txt
  source/Utility/CMakeLists.txt
  tools/lldb-mi/MIUtilParse.h

Index: tools/lldb-mi/MIUtilParse.h
===
--- tools/lldb-mi/MIUtilParse.h
+++ tools/lldb-mi/MIUtilParse.h
@@ -9,8 +9,7 @@
  
 #pragma once
  
-// Third party headers:
-#include "../lib/Support/regex_impl.h"
+#include "lldb/Utility/regex_impl.h"
 
 // In-house headers:
 #include "MIUtilString.h"
Index: source/Utility/CMakeLists.txt
===
--- source/Utility/CMakeLists.txt
+++ source/Utility/CMakeLists.txt
@@ -17,4 +17,9 @@
   TaskPool.cpp
   TimeSpecTimeout.cpp
   UriParser.cpp
+  regcomp.c
+  regerror.c
+  regexec.c
+  regfree.c
+  regstrlcpy.c
   )
Index: scripts/CMakeLists.txt
===
--- scripts/CMakeLists.txt
+++ scripts/CMakeLists.txt
@@ -9,6 +9,8 @@
   ${LLDB_SOURCE_DIR}/include/lldb/lldb-versioning.h
 )
 
+include(FindPythonInterp)
+
 find_package(SWIG REQUIRED)
 add_custom_command(
   OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/LLDBWrapPython.cpp
Index: cmake/modules/LLDBStandalone.cmake
===
--- cmake/modules/LLDBStandalone.cmake
+++ cmake/modules/LLDBStandalone.cmake
@@ -6,57 +6,77 @@
 
   option(LLVM_INSTALL_TOOLCHAIN_ONLY "Only include toolchain files in the 'install' target." OFF)
 
-  set(LLDB_PATH_TO_LLVM_SOURCE "" CACHE PATH
-"Path to LLVM source code. Not necessary if using an installed LLVM.")
-  set(LLDB_PATH_TO_LLVM_BUILD "" CACHE PATH
-"Path to the directory where LLVM was built or installed.")
-
-  set(LLDB_PATH_TO_CLANG_SOURCE "" CACHE PATH
-"Path to Clang source code. Not necessary if using an installed Clang.")
-  set(LLDB_PATH_TO_CLANG_BUILD "" CACHE PATH
-"Path to the directory where Clang was built or installed.")
-
-  if (LLDB_PATH_TO_LLVM_SOURCE)
-if (NOT EXISTS "${LLDB_PATH_TO_LLVM_SOURCE}/cmake/config-ix.cmake")
-  message(FATAL_ERROR "Please set LLDB_PATH_TO_LLVM_SOURCE to the root "
-  "directory of LLVM source code.")
+  # Rely on llvm-config.
+  set(CONFIG_OUTPUT)
+  find_program(LLVM_CONFIG "llvm-config")
+  if(LLVM_CONFIG)
+message(STATUS "Found LLVM_CONFIG as ${LLVM_CONFIG}")
+set(CONFIG_COMMAND ${LLVM_CONFIG}
+  "--assertion-mode"
+  "--bindir"
+  "--libdir"
+  "--includedir"
+  "--prefix"
+  "--src-root")
+execute_process(
+  COMMAND ${CONFIG_COMMAND}
+  RESULT_VARIABLE HAD_ERROR
+  OUTPUT_VARIABLE CONFIG_OUTPUT
+)
+if(NOT HAD_ERROR)
+  string(REGEX REPLACE
+"[ \t]*[\r\n]+[ \t]*" ";"
+CONFIG_OUTPUT ${CONFIG_OUTPUT})
 else()
-  get_filename_component(LLVM_MAIN_SRC_DIR ${LLDB_PATH_TO_LLVM_SOURCE}
- ABSOLUTE)
-  set(LLVM_MAIN_INCLUDE_DIR "${LLVM_MAIN_SRC_DIR}/include")
-  list(APPEND CMAKE_MODULE_PATH "${LLVM_MAIN_SRC_DIR}/cmake/modules")
+  string(REPLACE ";" " " CONFIG_COMMAND_STR "${CONFIG_COMMAND}")
+  message(STATUS "${CONFIG_COMMAND_STR}")
+  message(FATAL_ERROR "llvm-config failed with status ${HAD_ERROR}")
 endif()
+  else()
+message(FATAL_ERROR "llvm-config not found -- ${LLVM_CONFIG}")
   endif()
 
-  if (LLDB_PATH_TO_CLANG_SOURCE)
-  get_filename_component(CLANG_MAIN_SRC_DIR ${LLDB_PATH_TO_CLANG_SOURCE}
- ABSOLUTE)
-  set(CLANG_MAIN_INCLUDE_DIR "${CLANG_MAIN_SRC_DIR}/include")
+  list(GET CONFIG_OUTPUT 0 ENABLE_ASSERTIONS)
+  list(GET CONFIG_OUTPUT 1 TOOLS_BINARY_DIR)
+  list(GET CONFIG_OUTPUT 2 LIBRARY_DIR)
+  list(GET CONFIG_OUTPUT 3 INCLUDE_DIR)
+  list(GET CONFIG_OUTPUT 4 LLVM_OBJ_ROOT)
+  list(GET CONFIG_OUTPUT 5 MAIN_SRC_DIR)
+
+  if(NOT MSVC_IDE)
+set(LLVM_ENABLE_ASSERTIONS ${ENABLE_ASSERTIONS}
+  CACHE BOOL "Enable assertions")
+# Assertions should follow llvm-config's.
+mark_as_advanced(LLVM_ENABLE_ASSERTIONS)
   endif()
 
-  list(APPEND CMAKE_MODULE_PATH "${LLDB_PATH_TO_LLVM_BUILD}/share/llvm/cmake")
+  set(LLVM_TOOLS_BINARY_DIR ${TOOLS_BINARY_DIR} CACHE PATH "Path to llvm/bin")
+  set(LLVM_LIBRARY_DIR ${LIBRARY_DIR} CACHE PATH "Path to llvm/lib")
+  set(LLVM_MAIN_INCLUDE_DIR ${INCLUDE_DIR} CACHE PATH "Path to llvm/include")
+  set(LLVM_BINARY_DIR ${LLVM_OBJ_ROOT} CACHE PATH "Path to LLVM build tree")
+  set(LLVM_MAIN_SRC_DIR ${MAIN_SRC_DIR} CACHE PATH "Path to LLVM source tree")
 
-  if (LLDB_PATH_TO_LLVM_BUILD)
-get_filename_component(PATH_TO_LLVM_BUILD ${LLDB_PATH_TO_LLVM_BUILD}
-   ABSOLUTE)
-  else()
-message(FATAL_ERROR "Please set LLDB_PATH_TO_LLVM_BUILD to the root "
-"directory of LLVM build or install site.")
-  endif()
+