From ae9fec0bdfc9e8414102659ee166cc4442eb6ec5 Mon Sep 17 00:00:00 2001 From: Eric Fiselier Date: Fri, 12 Dec 2014 03:12:18 +0000 Subject: Add support for building libc++ as a 32 bit library git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@224096 91177308-0d34-0410-b5e6-96231b3b80d8 --- CMakeLists.txt | 9 +++++++++ test/CMakeLists.txt | 1 + test/lit.cfg | 3 +++ test/lit.site.cfg.in | 1 + 4 files changed, 14 insertions(+) diff --git a/CMakeLists.txt b/CMakeLists.txt index ca15f8743..3565169fd 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -43,6 +43,7 @@ option(LIBCXX_ENABLE_WERROR "Fail and stop if a warning is triggered." OFF) option(LIBCXX_ENABLE_CXX1Y "Enable -std=c++1y and use of c++1y language features if the compiler supports it." OFF) option(LIBCXX_ENABLE_SHARED "Build libc++ as a shared library." ON) option(LIBCXX_ENABLE_THREADS "Build libc++ with support for threads." ON) +option(LIBCXX_BUILD_32_BITS "Build 32 bit libc++" OFF) option(LIBCXX_ENABLE_MONOTONIC_CLOCK "Build libc++ with support for a monotonic clock. This option may only be used when LIBCXX_ENABLE_THREADS=OFF." ON) @@ -205,6 +206,14 @@ if (NOT LIBCXX_ENABLE_SHARED) list(APPEND LIBCXX_COMPILE_FLAGS -D_LIBCPP_BUILD_STATIC) endif() +if (CMAKE_SIZEOF_VOID_P EQUAL 8 AND NOT WIN32) + if (LIBCXX_BUILD_32_BITS) + message(STATUS "Building 32 bits executables and libraries.") + list(APPEND LIBCXX_CXX_FLAGS "-m32") + endif() +elseif(LIBCXX_BUILD_32_BITS) + message(FATAL_ERROR "LIBCXX_BUILD_32_BITS=ON is not supported on this platform.") +endif() # This is the _ONLY_ place where add_definitions is called. if (MSVC) add_definitions(-D_CRT_SECURE_NO_WARNINGS) diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt index 0d053b4b0..fe82dee0b 100644 --- a/test/CMakeLists.txt +++ b/test/CMakeLists.txt @@ -30,6 +30,7 @@ if(PYTHONINTERP_FOUND) pythonize_bool(LIBCXX_ENABLE_EXCEPTIONS) pythonize_bool(LIBCXX_ENABLE_RTTI) pythonize_bool(LIBCXX_ENABLE_SHARED) + pythonize_bool(LIBCXX_BUILD_32_BITS) pythonize_bool(LIBCXX_ENABLE_THREADS) pythonize_bool(LIBCXX_ENABLE_MONOTONIC_CLOCK) diff --git a/test/lit.cfg b/test/lit.cfg index 8bad0308e..23348a042 100644 --- a/test/lit.cfg +++ b/test/lit.cfg @@ -436,6 +436,9 @@ class Configuration(object): self.config.available_features.add('rtti') else: self.compile_flags += ['-fno-rtti', '-D_LIBCPP_NO_RTTI'] + enable_32bit = self.get_lit_bool('enable_32bit', False) + if enable_32bit: + self.compile_flags += ['-m32'] # Configure threading features. enable_threads = self.get_lit_bool('enable_threads', True) enable_monotonic_clock = self.get_lit_bool('enable_monotonic_clock', True) diff --git a/test/lit.site.cfg.in b/test/lit.site.cfg.in index 32619717d..f4bd8e467 100644 --- a/test/lit.site.cfg.in +++ b/test/lit.site.cfg.in @@ -7,6 +7,7 @@ config.python_executable = "@PYTHON_EXECUTABLE@" config.enable_exceptions = "@LIBCXX_ENABLE_EXCEPTIONS@" config.enable_rtti = "@LIBCXX_ENABLE_RTTI@" config.enable_shared = "@LIBCXX_ENABLE_SHARED@" +config.enable_32bit = "@LIBCXX_BUILD_32_BITS@" config.enable_threads = "@LIBCXX_ENABLE_THREADS@" config.enable_monotonic_clock = "@LIBCXX_ENABLE_MONOTONIC_CLOCK@" config.cxx_abi = "@LIBCXX_CXX_ABI_LIBNAME@" -- cgit v1.2.3