[PATCH] D24084: [CMake] Cleanup libunwind lookup code.

Logan Chien via cfe-commits cfe-commits at lists.llvm.org
Wed Aug 31 08:41:41 PDT 2016


logan created this revision.
logan added reviewers: mclow.lists, rengolin, EricWF, danalbert, thakis.
logan added a subscriber: cfe-commits.

This commit refines the code for libunwind lookup.

First, this commit will always search for libunwind no matter LLVM
unwinder is enabled or not.  We have to do so because we need the
modified "unwind.h" from libunwind.  (Note: <unwind.h> which is bundled
with clang/gcc is not sufficient.)

Second, this commit removes LIBCXXABI_LIBUNWIND_INCLUDE_INTERNAL and
refines the find_path() function.  Now, it looks similar to the one for
libc++.

Third, this commit removes LIBCXXABI_LIBUNWIND_SOURCES since it haven't
been used for a while.  (Note: The reference to "libunwind_ext.h" has
been removed since r241993.)

https://reviews.llvm.org/D24084

Files:
  CMakeLists.txt

Index: CMakeLists.txt
===================================================================
--- CMakeLists.txt
+++ CMakeLists.txt
@@ -137,6 +137,7 @@
   message(FATAL_ERROR "libc++abi must be built as either a shared or static library.")
 endif()
 
+# Find libc++ include path and source path.
 find_path(
   LIBCXXABI_LIBCXX_INCLUDES
   vector
@@ -167,6 +168,25 @@
 set(LIBCXXABI_LIBCXX_PATH "${LIBCXXABI_LIBCXX_PATH}" CACHE PATH
     "Specify path to libc++ source." FORCE)
 
+# Find libunwind include path (for unwind.h)
+find_path(
+  LIBCXXABI_LIBUNWIND_INCLUDES
+  libunwind.h
+  PATHS ${LIBCXXABI_LIBUNWIND_INCLUDES}
+        ${LIBCXXABI_LIBUNWIND_PATH}/include
+        ${CMAKE_BINARY_DIR}/${LIBCXXABI_LIBUNWIND_INCLUDES}
+        ${LLVM_MAIN_SRC_DIR}/projects/libunwind/include
+  NO_DEFAULT_PATH
+)
+
+if (LIBCXXABI_LIBUNWIND_INCLUDES STREQUAL "LIBCXXABI_LIBUNWIND_INCLUDES-NOTFOUND")
+  message(WARNING "LIBCXXABI_LIBUNWIND_INCLUDES was not specified and couldn't be infered.")
+  set(LIBCXXABI_LIBUNWIND_INCLUDES "")
+endif()
+
+set(LIBCXXABI_LIBUNWIND_INCLUDES "${LIBCXXABI_LIBUNWIND_INCLUDES}" CACHE PATH
+    "Specify path to libunwind includes." FORCE)
+
 #===============================================================================
 # Configure System
 #===============================================================================
@@ -351,40 +371,13 @@
 # Setup Source Code
 #===============================================================================
 
-set(LIBCXXABI_LIBUNWIND_INCLUDES "${LIBCXXABI_LIBUNWIND_INCLUDES}" CACHE PATH
-    "Specify path to libunwind includes." FORCE)
-set(LIBCXXABI_LIBUNWIND_PATH "${LIBCXXABI_LIBUNWIND_PATH}" CACHE PATH
-    "Specify path to libunwind source." FORCE)
+# Add libunwind include to header search path (for unwind.h)
+if (LIBCXXABI_LIBUNWIND_INCLUDES)
+  include_directories("${LIBCXXABI_LIBUNWIND_INCLUDES}")
+endif()
 
+# Add libc++abi include to header search path.
 include_directories(include)
-if (LIBCXXABI_USE_LLVM_UNWINDER OR LLVM_NATIVE_ARCH MATCHES ARM)
-  find_path(
-    LIBCXXABI_LIBUNWIND_INCLUDES_INTERNAL
-    libunwind.h
-    PATHS ${LIBCXXABI_LIBUNWIND_INCLUDES}
-          ${LIBCXXABI_LIBUNWIND_PATH}/include
-          ${CMAKE_BINARY_DIR}/${LIBCXXABI_LIBUNWIND_INCLUDES}
-          ${LLVM_MAIN_SRC_DIR}/projects/libunwind/include
-    NO_DEFAULT_PATH
-  )
-
-  find_path(
-    LIBCXXABI_LIBUNWIND_SOURCES
-    libunwind_ext.h
-    PATHS ${LIBCXXABI_LIBUNWIND_PATH}/src/
-          ${LIBCXXABI_LIBUNWIND_INCLUDES}/../src/
-          ${LLVM_MAIN_SRC_DIR}/projects/libunwind/src/
-    NO_DEFAULT_PATH
-  )
-
-  if (LIBCXXABI_LIBUNWIND_SOURCES STREQUAL "LIBCXXABI_LIBUNWIND_SOURCES-NOTFOUND")
-    message(WARNING "LIBCXXABI_LIBUNWIND_SOURCES was not specified and couldn't be infered.")
-    set(LIBCXXABI_LIBUNWIND_SOURCES "")
-  endif()
-
-  include_directories("${LIBCXXABI_LIBUNWIND_INCLUDES_INTERNAL}")
-  include_directories("${LIBCXXABI_LIBUNWIND_SOURCES}")
-endif()
 
 # Add source code. This also contains all of the logic for deciding linker flags
 # soname, etc...


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D24084.69865.patch
Type: text/x-patch
Size: 3067 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20160831/0b8fb59e/attachment.bin>


More information about the cfe-commits mailing list