[PATCH] [libc++] Add support for cross compiling libc++.

Dan Albert danalbert at google.com
Wed Jan 14 18:16:11 PST 2015


Hi jroelofs, EricWF,

REPOSITORY
  rL LLVM

http://reviews.llvm.org/D6990

Files:
  CMakeLists.txt
  test/CMakeLists.txt
  test/libcxx/test/config.py
  test/lit.site.cfg.in

Index: CMakeLists.txt
===================================================================
--- CMakeLists.txt
+++ CMakeLists.txt
@@ -80,6 +80,14 @@
 set_property(CACHE LIBCXX_CXX_ABI PROPERTY STRINGS ;${CXXABIS})
 
 #===============================================================================
+# Cross compiling options
+#===============================================================================
+if (LIBCXX_CROSSCOMPILING)
+  option(LIBCXX_SYSROOT "Sysroot for cross compiling.")
+  option(LIBCXX_GCC_TOOLCHAIN "GCC toolchain for cross compiling.")
+endif ()
+
+#===============================================================================
 # Configure System
 #===============================================================================
 
@@ -277,6 +285,13 @@
   endif()
 endif()
 
+# Configure cross compiling options.
+append_if(LIBCXX_CXX_FLAGS LIBCXX_SYSROOT "--sysroot ${LIBCXX_SYSROOT}")
+append_if(LIBCXX_CXX_FLAGS LIBCXX_GCC_TOOLCHAIN
+          "-gcc-toolchain ${LIBCXX_GCC_TOOLCHAIN}")
+append_if(LIBCXX_CXX_FLAGS LIBCXX_CROSSCOMPILING
+          "-target ${LIBCXX_TARGET_TRIPLE}")
+
 string(REPLACE ";" " " LIBCXX_CXX_FLAGS "${LIBCXX_CXX_FLAGS}")
 set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${LIBCXX_CXX_FLAGS}")
 
Index: test/CMakeLists.txt
===================================================================
--- test/CMakeLists.txt
+++ test/CMakeLists.txt
@@ -23,6 +23,9 @@
   set(LIT_ARGS "${LLVM_LIT_ARGS}")
   separate_arguments(LIT_ARGS)
 
+  option(LIBCXX_LIT_VARIANT "Configuration variant to use for LIT." "libcxx")
+
+  pythonize_bool(LIBCXX_CROSSCOMPILING)
   pythonize_bool(LIBCXX_ENABLE_EXCEPTIONS)
   pythonize_bool(LIBCXX_ENABLE_RTTI)
   pythonize_bool(LIBCXX_ENABLE_SHARED)
Index: test/libcxx/test/config.py
===================================================================
--- test/libcxx/test/config.py
+++ test/libcxx/test/config.py
@@ -296,6 +296,14 @@
         # Configure extra compile flags.
         compile_flags_str = self.get_lit_conf('compile_flags', '')
         self.compile_flags += shlex.split(compile_flags_str)
+        if self.get_lit_conf('crosscompiling', False):
+            sysroot = self.get_lit_conf('sysroot')
+            if sysroot:
+                self.compile_flags += ['--sysroot', sysroot]
+            gcc_toolchain = self.get_lit_conf('gcc_toolchain')
+            if gcc_toolchain:
+                self.compile_flags += ['-gcc-toolchain', gcc_toolchain]
+            self.compile_flags += ['-target', self.config.target_triple]
 
     def configure_compile_flags_header_includes(self):
         self.compile_flags += ['-I' + self.libcxx_src_root + '/test/support']
Index: test/lit.site.cfg.in
===================================================================
--- test/lit.site.cfg.in
+++ test/lit.site.cfg.in
@@ -13,6 +13,13 @@
 config.cxx_abi                  = "@LIBCXX_CXX_ABI_LIBNAME@"
 config.use_sanitizer            = "@LLVM_USE_SANITIZER@"
 config.abi_library_path         = "@LIBCXX_CXX_ABI_LIBRARY_PATH@"
+config.target_triple            = "@LIBCXX_TARGET_TRIPLE@"
+config.configuration_variant    = "@LIBCXX_LIT_VARIANT@"
+
+config.crosscompiling = @LIBCXX_CROSSCOMPILING@
+if config.crosscompiling:
+    config.sysroot = "@LIBCXX_SYSROOT@"
+    config.gcc_toolchain = "@LIBCXX_GCC_TOOLCHAIN@"
 
 # Let the main config do the real work.
 lit_config.load_config(config, "@LIBCXX_SOURCE_DIR@/test/lit.cfg")

EMAIL PREFERENCES
  http://reviews.llvm.org/settings/panel/emailpreferences/
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D6990.18206.patch
Type: text/x-patch
Size: 3400 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20150115/cda3324a/attachment.bin>


More information about the cfe-commits mailing list