[cfe-dev] [libcxx] [libcxxabi] Improve cmake scripts

Lei Zhang via cfe-dev cfe-dev at lists.llvm.org
Wed May 25 04:49:51 PDT 2016


Hi,

I'm trying to build a C++ runtime stack composed of libcxx, libcxxabi and
libunwind on Linux, out of the LLVM tree. It is pretty smooth once you find
out the right options to use, which are not mentioned on the official pages.

But there's still something I find a bit annoying and could be easily fixed
in the cmake scripts:

- When building libcxx, you can specify locations of libcxxabi's headers
and library file respectively via LIBCXX_CXX_ABI_INCLUDE_PATHS and
LIBCXX_CXX_ABI_LIBRARY_PATH. But somehow LIBCXX_CXX_ABI_LIBRARY_PATH is not
parsed properly in the cmake script and you can't set it to a relative
path; while you can set LIBCXX_CXX_ABI_INCLUDE_PATHS to either relative or
absolute paths. This looks inconsistent to me, and can be trivially fixed.

- When building libcxxabi, you can specify the location of libunwind's
headers via LIBCXXABI_LIBUNWIND_PATH, but have nowhere to specify the
location of its library file; thus I have to manually set
CMAKE_SHARED_LINKER_FLAGS to include this path. Again this looks
inconsistent, and could be fixed by introducing a similar variable named
LIBCXXABI_LIBUWIND_LIBRARY_PATH.


These are not big problems. I just feel like making the cmake options look
more consistent, and the fix is really trivial. I include the experimental
patches that I use and it's just a few lines of change.


Thanks!
Lei
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-dev/attachments/20160525/34d9995b/attachment.html>
-------------- next part --------------
Index: cmake/Modules/HandleLibCXXABI.cmake
===================================================================
--- cmake/Modules/HandleLibCXXABI.cmake	(revision 270683)
+++ cmake/Modules/HandleLibCXXABI.cmake	(working copy)
@@ -22,6 +22,9 @@
     "Paths to C++ ABI header directories separated by ';'." FORCE
     )
 
+  set(LIBCXX_CXX_ABI_LIBRARY_PATH "${LIBCXX_CXX_ABI_LIBRARY_PATH}"
+      CACHE PATH "Path to C++ ABI library directory")
+
   set(LIBCXX_CXX_ABI_LIBRARY ${abilib})
 
   set(LIBCXX_ABILIB_FILES ${abifiles})
-------------- next part --------------
Index: CMakeLists.txt
===================================================================
--- CMakeLists.txt	(revision 270683)
+++ CMakeLists.txt	(working copy)
@@ -116,6 +116,7 @@
 set(LIBCXXABI_GCC_TOOLCHAIN "" CACHE STRING "GCC toolchain for cross compiling.")
 set(LIBCXXABI_SYSROOT "" CACHE STRING "Sysroot for cross compiling.")
 set(LIBCXXABI_LIBCXX_LIBRARY_PATH "" CACHE STRING "The path to libc++ library.")
+set(LIBCXXABI_LIBUNWIND_LIBRARY_PATH "" CACHE PATH "The path to libunwind library")
 
 # Default to building a shared library so that the default options still test
 # the libc++abi that is being built. There are two problems with testing a
@@ -332,6 +333,8 @@
 
   include_directories("${LIBCXXABI_LIBUNWIND_INCLUDES_INTERNAL}")
   include_directories("${LIBCXXABI_LIBUNWIND_SOURCES}")
+
+  list(APPEND LIBCXXABI_LINK_FLAGS "-L${LIBCXXABI_LIBUNWIND_LIBRARY_PATH}")
 endif ()
 
 # Add source code. This also contains all of the logic for deciding linker flags


More information about the cfe-dev mailing list