summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDan Albert <danalbert@google.com>2015-01-16 00:55:15 +0000
committerDan Albert <danalbert@google.com>2015-01-16 00:55:15 +0000
commitdb56013cd13442bb194a62cdd6c57ef69c9708bc (patch)
treef65d5a666ed56b7e512dbe25c630c3580591c022
parent18e53ca3dd5a3caccca85d96a5b4dc1667e712dd (diff)
downloadbcm5719-llvm-db56013cd13442bb194a62cdd6c57ef69c9708bc.tar.gz
bcm5719-llvm-db56013cd13442bb194a62cdd6c57ef69c9708bc.zip
[libc++] Add support for cross compiling.
Reviewers: EricWF, jroelofs Reviewed By: jroelofs Subscribers: cfe-commits Differential Revision: http://reviews.llvm.org/D6990 llvm-svn: 226237
-rw-r--r--libcxx/CMakeLists.txt7
-rw-r--r--libcxx/test/libcxx/test/config.py17
-rw-r--r--libcxx/test/lit.site.cfg.in3
3 files changed, 23 insertions, 4 deletions
diff --git a/libcxx/CMakeLists.txt b/libcxx/CMakeLists.txt
index 99a4a33f5f3..51d9958a207 100644
--- a/libcxx/CMakeLists.txt
+++ b/libcxx/CMakeLists.txt
@@ -57,6 +57,8 @@ option(LIBCXX_ENABLE_MONOTONIC_CLOCK
This option may only be used when LIBCXX_ENABLE_THREADS=OFF." ON)
option(LIBCXX_INSTALL_HEADERS "Install the libc++ headers." ON)
option(LIBCXX_INSTALL_SUPPORT_HEADERS "Install libc++ support headers." ON)
+set(LIBCXX_SYSROOT "" CACHE STRING "Use alternate sysroot.")
+set(LIBCXX_GCC_TOOLCHAIN "" CACHE STRING "Use alternate GCC toolchain.")
if (LIBCXX_BUILT_STANDALONE)
set(LLVM_USE_SANITIZER "" CACHE STRING
"Define the sanitizer used to build the library and tests")
@@ -277,6 +279,11 @@ if (LIBCXX_BUILT_STANDALONE)
endif()
endif()
+list(APPEND LIBCXX_CXX_FLAGS "-target ${LIBCXX_TARGET_TRIPLE}")
+append_if(LIBCXX_CXX_FLAGS LIBCXX_SYSROOT "--sysroot ${LIBCXX_SYSROOT}")
+append_if(LIBCXX_CXX_FLAGS LIBCXX_GCC_TOOLCHAIN
+ "-gcc-toolchain ${LIBCXX_GCC_TOOLCHAIN}")
+
string(REPLACE ";" " " LIBCXX_CXX_FLAGS "${LIBCXX_CXX_FLAGS}")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${LIBCXX_CXX_FLAGS}")
diff --git a/libcxx/test/libcxx/test/config.py b/libcxx/test/libcxx/test/config.py
index bb4c5a8094e..70af0df4492 100644
--- a/libcxx/test/libcxx/test/config.py
+++ b/libcxx/test/libcxx/test/config.py
@@ -230,9 +230,9 @@ class Configuration(object):
locale.setlocale(locale.LC_ALL, default_locale)
# Write an "available feature" that combines the triple when
- # use_system_cxx_lib is enabled. This is so that we can easily write XFAIL
- # markers for tests that are known to fail with versions of libc++ as
- # were shipped with a particular triple.
+ # use_system_cxx_lib is enabled. This is so that we can easily write
+ # XFAIL markers for tests that are known to fail with versions of
+ # libc++ as were shipped with a particular triple.
if self.use_system_cxx_lib:
self.config.available_features.add(
'with_system_cxx_lib=%s' % self.config.target_triple)
@@ -288,7 +288,7 @@ class Configuration(object):
if not enable_threads:
self.configure_compile_flags_no_threads()
if not enable_monotonic_clock:
- self.configure_compile_flags_no_monotonic_clock()
+ self.configure_compile_flags_no_monotonic_clock()
elif not enable_monotonic_clock:
self.lit_config.fatal('enable_monotonic_clock cannot be false when'
' enable_threads is true.')
@@ -298,6 +298,15 @@ class Configuration(object):
compile_flags_str = self.get_lit_conf('compile_flags', '')
self.compile_flags += shlex.split(compile_flags_str)
+ 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']
libcxx_headers = self.get_lit_conf('libcxx_headers',
diff --git a/libcxx/test/lit.site.cfg.in b/libcxx/test/lit.site.cfg.in
index 59c44b82518..148adeb55a5 100644
--- a/libcxx/test/lit.site.cfg.in
+++ b/libcxx/test/lit.site.cfg.in
@@ -14,6 +14,9 @@ config.cxx_abi = "@LIBCXX_CXX_ABI_LIBNAME@"
config.use_sanitizer = "@LLVM_USE_SANITIZER@"
config.abi_library_path = "@LIBCXX_CXX_ABI_LIBRARY_PATH@"
config.configuration_variant = "@LIBCXX_LIT_VARIANT@"
+config.target_triple = "@LIBCXX_TARGET_TRIPLE@"
+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")
OpenPOWER on IntegriCloud