[cfe-commits] [libcxx] r121510 - in /libcxx/trunk: CMakeLists.txt cmake/ cmake/Modules/ cmake/Modules/GetTriple.cmake cmake/Modules/MacroEnsureOutOfSourceBuild.cmake cmake/config-ix.cmake include/__config include/__split_buffer include/locale include/memory include/utility lib/CMakeLists.txt lib/buildit src/locale.cpp test/CMakeLists.txt test/lit.cfg test/lit.site.cfg.in
Michael J. Spencer
bigcheesegs at gmail.com
Fri Dec 10 11:47:55 PST 2010
Author: mspencer
Date: Fri Dec 10 13:47:54 2010
New Revision: 121510
URL: http://llvm.org/viewvc/llvm-project?rev=121510&view=rev
Log:
Add CMake build and fix major Linux blockers.
Added:
libcxx/trunk/CMakeLists.txt
libcxx/trunk/cmake/
libcxx/trunk/cmake/Modules/
libcxx/trunk/cmake/Modules/GetTriple.cmake
libcxx/trunk/cmake/Modules/MacroEnsureOutOfSourceBuild.cmake
libcxx/trunk/cmake/config-ix.cmake
libcxx/trunk/lib/CMakeLists.txt
libcxx/trunk/test/CMakeLists.txt
libcxx/trunk/test/lit.site.cfg.in
Modified:
libcxx/trunk/include/__config
libcxx/trunk/include/__split_buffer
libcxx/trunk/include/locale
libcxx/trunk/include/memory
libcxx/trunk/include/utility
libcxx/trunk/lib/buildit
libcxx/trunk/src/locale.cpp
libcxx/trunk/test/lit.cfg
Added: libcxx/trunk/CMakeLists.txt
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/CMakeLists.txt?rev=121510&view=auto
==============================================================================
--- libcxx/trunk/CMakeLists.txt (added)
+++ libcxx/trunk/CMakeLists.txt Fri Dec 10 13:47:54 2010
@@ -0,0 +1,159 @@
+# See www/CMake.html for instructions on how to build libcxx with CMake.
+
+#===============================================================================
+# Setup Project
+#===============================================================================
+
+project(libcxx CXX C)
+cmake_minimum_required(VERSION 2.8)
+
+set(PACKAGE_NAME libcxx)
+set(PACKAGE_VERSION trunk-svn)
+set(PACKAGE_STRING "${PACKAGE_NAME} ${PACKAGE_VERSION}")
+set(PACKAGE_BUGREPORT "llvmbugs at cs.uiuc.edu")
+
+# Add path for custom modules
+set(CMAKE_MODULE_PATH
+ ${CMAKE_MODULE_PATH}
+ "${CMAKE_CURRENT_SOURCE_DIR}/cmake"
+ "${CMAKE_CURRENT_SOURCE_DIR}/cmake/Modules"
+ )
+
+# Require out of source build.
+include(MacroEnsureOutOfSourceBuild)
+MACRO_ENSURE_OUT_OF_SOURCE_BUILD(
+ "${PROJECT_NAME} requires an out of source build. Please create a separate
+ build directory and run 'cmake /path/to/${PROJECT_NAME} [options]' there."
+ )
+
+#===============================================================================
+# Setup CMake Options
+#===============================================================================
+
+# Define options.
+option(LIBCXX_ENABLE_EXCEPTIONS "Use exceptions." ON)
+option(LIBCXX_ENABLE_RTTI "Use run time type information." ON)
+option(LIBCXX_ENABLE_ASSERTIONS "Enable assertions independent of build mode." ON)
+option(LIBCXX_ENABLE_PEDANTIC "Compile with pedantic enabled." ON)
+option(LIBCXX_ENABLE_WERROR "Fail and stop if a warning is triggered." OFF)
+option(LIBCXX_ENABLE_CXX0X "Enable -std=c++0x and use of c++0x language features if the compiler supports it." ON)
+option(LIBCXX_ENABLE_SHARED "Build libc++ as a shared library." ON)
+
+#===============================================================================
+# Configure System
+#===============================================================================
+
+# Get triples.
+include(GetTriple)
+get_host_triple(LIBCXX_HOST_TRIPLE
+ LIBCXX_HOST_ARCH
+ LIBCXX_HOST_VENDOR
+ LIBCXX_HOST_OS
+ )
+set(LIBCXX_HOST_TRIPLE ${LIBCXX_HOST_TRIPLE} CACHE STRING "Host triple.")
+get_target_triple(LIBCXX_TARGET_TRIPLE
+ LIBCXX_TARGET_ARCH
+ LIBCXX_TARGET_VENDOR
+ LIBCXX_TARGET_OS
+ )
+set(LIBCXX_TARGET_TRIPLE ${LIBCXX_TARGET_TRIPLE} CACHE STRING "Target triple.")
+
+# Configure compiler.
+include(config-ix)
+
+#===============================================================================
+# Setup Compiler Flags
+#===============================================================================
+
+# Get required flags.
+# On all systems the system c++ standard library headers need to be excluded.
+if (MSVC)
+ # MSVC only has -X, which disables all default includes; including the crt.
+ # Thus, we do nothing and hope we don't accidentally include any of the C++
+ # headers.
+else()
+ if (LIBCXX_HAS_NOSTDINCXX_FLAG)
+ set(LIBCXX_CXX_REQUIRED_FLAGS -nostdinc++)
+ endif()
+ if (LIBCXX_ENABLE_CXX0X AND LIBCXX_HAS_STDCXX0X_FLAG)
+ list(APPEND LIBCXX_CXX_REQUIRED_FLAGS -std=c++0x)
+ endif()
+endif()
+
+macro(append_if list condition var)
+ if (${condition})
+ list(APPEND ${list} ${var})
+ endif()
+endmacro()
+
+# Get warning flags
+append_if(LIBCXX_WARNING_FLAGS LIBCXX_HAS_WALL_FLAG -Wall)
+append_if(LIBCXX_WARNING_FLAGS LIBCXX_HAS_W_FLAG -W)
+append_if(LIBCXX_WARNING_FLAGS LIBCXX_HAS_WNO_UNUSED_PARAMETER_FLAG -Wno-unused-parameter)
+append_if(LIBCXX_WARNING_FLAGS LIBCXX_HAS_WWRITE_STRINGS_FLAG -Wwrite-strings)
+append_if(LIBCXX_WARNING_FLAGS LIBCXX_HAS_WNO_LONG_LONG_FLAG -Wno-long-long)
+if (LIBCXX_ENABLE_WERROR)
+ append_if(LIBCXX_WARNING_FLAGS LIBCXX_HAS_WERROR_FLAG -Werror)
+ append_if(LIBCXX_WARNING_FLAGS LIBCXX_HAS_WX_FLAG -WX)
+endif()
+if (LIBCXX_ENABLE_PEDANTIC)
+ append_if(LIBCXX_WARNING_FLAGS LIBCXX_HAS_PEDANTIC_FLAG -pedantic)
+endif()
+
+# Get feature flags.
+# Exceptions
+if (LIBCXX_ENABLE_EXCEPTIONS)
+ # Catches C++ exceptions only and tells the compiler to assume that extern C
+ # functions never throw a C++ exception.
+ append_if(LIBCXX_CXX_FEATURE_FLAGS LIBCXX_HAS_EHSC_FLAG -EHsc)
+else()
+ list(APPEND LIBCXX_CXX_FEATURE_FLAGS -D_LIBCPP_NO_EXCEPTIONS)
+ append_if(LIBCXX_CXX_FEATURE_FLAGS LIBCXX_HAS_NO_EHS_FLAG -EHs-)
+ append_if(LIBCXX_CXX_FEATURE_FLAGS LIBCXX_HAS_NO_EHA_FLAG -EHa-)
+ append_if(LIBCXX_CXX_FEATURE_FLAGS LIBCXX_HAS_FNO_EXCEPTIONS_FLAG -fno-exceptions)
+endif()
+# RTTI
+if (NOT LIBCXX_ENABLE_RTTI)
+ list(APPEND LIBCXX_CXX_FEATURE_FLAGS -D_LIBCPP_NO_RTTI)
+ append_if(LIBCXX_CXX_FEATURE_FLAGS LIBCXX_HAS_NO_GR_FLAG -GR-)
+ append_if(LIBCXX_CXX_FEATURE_FLAGS LIBCXX_HAS_FNO_RTTI_FLAG -fno-rtti)
+endif()
+# Assert
+if (LLVM_ENABLE_ASSERTIONS)
+ # MSVC doesn't like _DEBUG on release builds. See PR 4379.
+ if (NOT MSVC)
+ list(APPEND LIBCXX_CXX_FEATURE_FLAGS -D_DEBUG)
+ endif()
+ # On Release builds cmake automatically defines NDEBUG, so we
+ # explicitly undefine it:
+ if (uppercase_CMAKE_BUILD_TYPE STREQUAL "RELEASE")
+ list(APPEND LIBCXX_CXX_FEATURE_FLAGS -UNDEBUG)
+ endif()
+else()
+ if (NOT uppercase_CMAKE_BUILD_TYPE STREQUAL "RELEASE")
+ list(APPEND LIBCXX_CXX_FEATURE_FLAGS -DNDEBUG)
+ endif()
+endif()
+
+# This is the _ONLY_ place where add_definitions is called.
+add_definitions(
+ ${LIBCXX_CXX_REQUIRED_FLAGS}
+ ${LIBCXX_CXX_WARNING_FLAGS}
+ ${LIBCXX_CXX_FEATURE_FLAGS}
+ )
+
+#===============================================================================
+# Setup Source Code
+#===============================================================================
+
+include_directories(include)
+
+# Add source code. This also contains all of the logic for deciding linker flags
+# soname, etc...
+add_subdirectory(lib)
+
+#===============================================================================
+# Setup Tests
+#===============================================================================
+
+add_subdirectory(test)
Added: libcxx/trunk/cmake/Modules/GetTriple.cmake
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/cmake/Modules/GetTriple.cmake?rev=121510&view=auto
==============================================================================
--- libcxx/trunk/cmake/Modules/GetTriple.cmake (added)
+++ libcxx/trunk/cmake/Modules/GetTriple.cmake Fri Dec 10 13:47:54 2010
@@ -0,0 +1,53 @@
+# Define functions to get the host and target triple.
+
+function(get_host_triple out out_arch out_vendor out_os)
+ # Get the architecture.
+ set(arch ${CMAKE_HOST_SYSTEM_PROCESSOR})
+ if (arch STREQUAL "x86")
+ set(arch "i686")
+ endif()
+ # Get the vendor.
+ if (${CMAKE_HOST_SYSTEM_NAME} STREQUAL "Darwin")
+ set(vendor "apple")
+ else()
+ set(vendor "pc")
+ endif()
+ # Get os.
+ if (${CMAKE_HOST_SYSTEM_NAME} STREQUAL "Windows")
+ set(os "win32")
+ else()
+ string(TOLOWER ${CMAKE_HOST_SYSTEM_NAME} os)
+ endif()
+ set(triple "${arch}-${vendor}-${os}")
+ set(${out} ${triple} PARENT_SCOPE)
+ set(${out_arch} ${arch} PARENT_SCOPE)
+ set(${out_vendor} ${vendor} PARENT_SCOPE)
+ set(${out_os} ${os} PARENT_SCOPE)
+ message(STATUS "Host triple: ${triple}")
+endfunction()
+
+function(get_target_triple out out_arch out_vendor out_os)
+ # Get the architecture.
+ set(arch ${CMAKE_SYSTEM_PROCESSOR})
+ if (arch STREQUAL "x86")
+ set(arch "i686")
+ endif()
+ # Get the vendor.
+ if (${CMAKE_SYSTEM_NAME} STREQUAL "Darwin")
+ set(vendor "apple")
+ else()
+ set(vendor "pc")
+ endif()
+ # Get os.
+ if (${CMAKE_SYSTEM_NAME} STREQUAL "Windows")
+ set(os "win32")
+ else()
+ string(TOLOWER ${CMAKE_SYSTEM_NAME} os)
+ endif()
+ set(triple "${arch}-${vendor}-${os}")
+ set(${out} ${triple} PARENT_SCOPE)
+ set(${out_arch} ${arch} PARENT_SCOPE)
+ set(${out_vendor} ${vendor} PARENT_SCOPE)
+ set(${out_os} ${os} PARENT_SCOPE)
+ message(STATUS "Target triple: ${triple}")
+endfunction()
Added: libcxx/trunk/cmake/Modules/MacroEnsureOutOfSourceBuild.cmake
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/cmake/Modules/MacroEnsureOutOfSourceBuild.cmake?rev=121510&view=auto
==============================================================================
--- libcxx/trunk/cmake/Modules/MacroEnsureOutOfSourceBuild.cmake (added)
+++ libcxx/trunk/cmake/Modules/MacroEnsureOutOfSourceBuild.cmake Fri Dec 10 13:47:54 2010
@@ -0,0 +1,18 @@
+# MACRO_ENSURE_OUT_OF_SOURCE_BUILD(<errorMessage>)
+
+macro( MACRO_ENSURE_OUT_OF_SOURCE_BUILD _errorMessage )
+
+string( COMPARE EQUAL "${CMAKE_SOURCE_DIR}" "${CMAKE_BINARY_DIR}" _insource )
+if( _insource )
+ message( SEND_ERROR "${_errorMessage}" )
+ message( FATAL_ERROR
+ "In-source builds are not allowed.
+ CMake would overwrite the makefiles distributed with Compiler-RT.
+ Please create a directory and run cmake from there, passing the path
+ to this source directory as the last argument.
+ This process created the file `CMakeCache.txt' and the directory `CMakeFiles'.
+ Please delete them."
+ )
+endif( _insource )
+
+endmacro( MACRO_ENSURE_OUT_OF_SOURCE_BUILD )
Added: libcxx/trunk/cmake/config-ix.cmake
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/cmake/config-ix.cmake?rev=121510&view=auto
==============================================================================
--- libcxx/trunk/cmake/config-ix.cmake (added)
+++ libcxx/trunk/cmake/config-ix.cmake Fri Dec 10 13:47:54 2010
@@ -0,0 +1,37 @@
+include(CheckLibraryExists)
+include(CheckCXXCompilerFlag)
+
+# Check compiler flags
+check_cxx_compiler_flag(-std=c++0x LIBCXX_HAS_STDCXX0X_FLAG)
+check_cxx_compiler_flag(-fPIC LIBCXX_HAS_FPIC_FLAG)
+check_cxx_compiler_flag(-nodefaultlibs LIBCXX_HAS_NODEFAULTLIBS_FLAG)
+check_cxx_compiler_flag(-nostdinc++ LIBCXX_HAS_NOSTDINCXX_FLAG)
+check_cxx_compiler_flag(-Wall LIBCXX_HAS_WALL_FLAG)
+check_cxx_compiler_flag(-W LIBCXX_HAS_W_FLAG)
+check_cxx_compiler_flag(-Wno-unused-parameter LIBCXX_HAS_WNO_UNUSED_PARAMETER_FLAG)
+check_cxx_compiler_flag(-Wwrite-strings LIBCXX_HAS_WWRITE_STRINGS_FLAG)
+check_cxx_compiler_flag(-Wno-long-long LIBCXX_HAS_WNO_LONG_LONG_FLAG)
+check_cxx_compiler_flag(-pedantic LIBCXX_HAS_PEDANTIC_FLAG)
+check_cxx_compiler_flag(-Werror LIBCXX_HAS_WERROR_FLAG)
+check_cxx_compiler_flag(-fno-exceptions LIBCXX_HAS_FNO_EXCEPTIONS_FLAG)
+check_cxx_compiler_flag(-fno-rtti LIBCXX_HAS_FNO_RTTI_FLAG)
+check_cxx_compiler_flag(/WX LIBCXX_HAS_WX_FLAG)
+check_cxx_compiler_flag(/EHsc LIBCXX_HAS_EHSC_FLAG)
+check_cxx_compiler_flag(/EHs- LIBCXX_HAS_NO_EHS_FLAG)
+check_cxx_compiler_flag(/EHa- LIBCXX_HAS_NO_EHA_FLAG)
+check_cxx_compiler_flag(/GR- LIBCXX_HAS_NO_GR_FLAG)
+
+# Check libraries
+check_library_exists(pthread pthread_create "" LIBCXX_HAS_PTHREAD_LIB)
+check_library_exists(c printf "" LIBCXX_HAS_C_LIB)
+check_library_exists(m ccos "" LIBCXX_HAS_M_LIB)
+check_library_exists(gcc_s __gcc_personality_v0 "" LIBCXX_HAS_GCC_S_LIB)
+
+# Check C++0x features
+if (LIBCXX_ENABLE_CXX0X)
+ if (LIBCXX_HAS_STDCXX0X_FLAG)
+ set(CMAKE_REQUIRED_DEFINITIONS -std=c++0x)
+ endif()
+else()
+ set(LIBCXX_HAS_STDCXX0X_FLAG FALSE)
+endif()
Modified: libcxx/trunk/include/__config
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/include/__config?rev=121510&r1=121509&r2=121510&view=diff
==============================================================================
--- libcxx/trunk/include/__config (original)
+++ libcxx/trunk/include/__config Fri Dec 10 13:47:54 2010
@@ -214,6 +214,7 @@
#endif // !(__GNUC__ >= 4 && __GNUC_MINOR__ >= 4)
#if !(__GNUC__ >= 4 && __GNUC_MINOR__ >= 6)
+#define _LIBCPP_HAS_NO_ALWAYS_INLINE_VARIADICS
#define _LIBCPP_HAS_NO_NULLPTR
#endif
Modified: libcxx/trunk/include/__split_buffer
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/include/__split_buffer?rev=121510&r1=121509&r2=121510&view=diff
==============================================================================
--- libcxx/trunk/include/__split_buffer (original)
+++ libcxx/trunk/include/__split_buffer Fri Dec 10 13:47:54 2010
@@ -85,12 +85,14 @@
void shrink_to_fit();
void push_front(const_reference __x);
void push_back(const_reference __x);
-#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+#if !defined(_LIBCPP_HAS_NO_RVALUE_REFERENCES)
void push_front(value_type&& __x);
void push_back(value_type&& __x);
+#if !defined(_LIBCPP_HAS_NO_VARIADICS)
template <class... _Args>
void emplace_back(_Args&&... __args);
-#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+#endif // !defined(_LIBCPP_HAS_NO_VARIADICS)
+#endif // !defined(_LIBCPP_HAS_NO_RVALUE_REFERENCES)
_LIBCPP_INLINE_VISIBILITY void pop_front() {__destruct_at_begin(__begin_+1);}
_LIBCPP_INLINE_VISIBILITY void pop_back() {__destruct_at_end(__end_-1);}
Modified: libcxx/trunk/include/locale
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/include/locale?rev=121510&r1=121509&r2=121510&view=diff
==============================================================================
--- libcxx/trunk/include/locale (original)
+++ libcxx/trunk/include/locale Fri Dec 10 13:47:54 2010
@@ -265,7 +265,10 @@
}
#else // __APPLE__
-inline _LIBCPP_INLINE_VISIBILITY
+inline
+#ifndef _LIBCPP_HAS_NO_ALWAYS_INLINE_VARIADICS
+_LIBCPP_INLINE_VISIBILITY
+#endif
int
__nolocale_sprintf(char* __restrict __str,
const char* __restrict __format, ...)
@@ -276,7 +279,10 @@
va_end(__ap);
return __result;
}
-inline _LIBCPP_INLINE_VISIBILITY
+inline
+#ifndef _LIBCPP_HAS_NO_ALWAYS_INLINE_VARIADICS
+_LIBCPP_INLINE_VISIBILITY
+#endif
int
__nolocale_snprintf(char* __restrict __str, size_t __size,
const char* __restrict __format, ...)
@@ -287,7 +293,10 @@
va_end(__ap);
return __result;
}
-inline _LIBCPP_INLINE_VISIBILITY
+inline
+#ifndef _LIBCPP_HAS_NO_ALWAYS_INLINE_VARIADICS
+_LIBCPP_INLINE_VISIBILITY
+#endif
int
__nolocale_asprintf(char** __ret,
const char* __restrict __format, ...)
@@ -298,7 +307,10 @@
va_end(__ap);
return __result;
}
-inline _LIBCPP_INLINE_VISIBILITY
+inline
+#ifndef _LIBCPP_HAS_NO_ALWAYS_INLINE_VARIADICS
+_LIBCPP_INLINE_VISIBILITY
+#endif
int
__nolocale_sscanf(const char* __restrict __str,
const char* __restrict __format, ...)
Modified: libcxx/trunk/include/memory
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/include/memory?rev=121510&r1=121509&r2=121510&view=diff
==============================================================================
--- libcxx/trunk/include/memory (original)
+++ libcxx/trunk/include/memory Fri Dec 10 13:47:54 2010
@@ -1487,7 +1487,7 @@
{
};
-#if !defined(_LIBCPP_HAS_NO_RVALUE_REFERENCES)
+#if !defined(_LIBCPP_HAS_NO_RVALUE_REFERENCES) && !defined(_LIBCPP_HAS_NO_VARIADICS)
// uses-allocator construction
@@ -1505,7 +1505,7 @@
: integral_constant<int, __uses_alloc_ctor_imp<_Tp, _Alloc, _Args...>::value>
{};
-#endif // !defined(_LIBCPP_HAS_NO_RVALUE_REFERENCES)
+#endif // !defined(_LIBCPP_HAS_NO_RVALUE_REFERENCES) && !defined(_LIBCPP_HAS_NO_VARIADICS)
// allocator
@@ -1546,6 +1546,7 @@
{
::new((void*)__p) _Tp();
}
+# if defined(_LIBCPP_HAS_NO_RVALUE_REFERENCES)
template <class _A0>
_LIBCPP_INLINE_VISIBILITY
typename enable_if
@@ -1579,6 +1580,7 @@
{
::new((void*)__p) _Tp(_STD::move(__a0));
}
+# endif // defined(_LIBCPP_HAS_NO_RVALUE_REFERENCES)
template <class _A0, class _A1>
_LIBCPP_INLINE_VISIBILITY
void
Modified: libcxx/trunk/include/utility
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/include/utility?rev=121510&r1=121509&r2=121510&view=diff
==============================================================================
--- libcxx/trunk/include/utility (original)
+++ libcxx/trunk/include/utility Fri Dec 10 13:47:54 2010
@@ -222,6 +222,8 @@
second(_STD::forward<_U2>(__u2))
{}
+#ifndef _LIBCPP_HAS_NO_VARIADICS
+
template<class _Tuple,
class = typename enable_if<__tuple_convertible<_Tuple, pair>::value>::type>
_LIBCPP_INLINE_VISIBILITY
@@ -232,7 +234,7 @@
typename __make_tuple_types<_Tuple>::type>::type>(get<1>(__p)))
{}
-#ifndef _LIBCPP_HAS_NO_VARIADICS
+
template <class... _Args1, class... _Args2, size_t... _I1, size_t... _I2>
_LIBCPP_INLINE_VISIBILITY
@@ -243,8 +245,6 @@
typename __make_tuple_indices<sizeof...(_Args2) >::type())
{}
-#endif // _LIBCPP_HAS_NO_VARIADICS
-
template <class _Tuple,
class = typename enable_if<__tuple_assignable<_Tuple, pair>::value>::type>
_LIBCPP_INLINE_VISIBILITY
@@ -259,6 +259,8 @@
return *this;
}
+#endif // _LIBCPP_HAS_NO_VARIADICS
+
#else // _LIBCPP_HAS_NO_RVALUE_REFERENCES
template<class _U1, class _U2>
_LIBCPP_INLINE_VISIBILITY pair(const pair<_U1, _U2>& __p)
Added: libcxx/trunk/lib/CMakeLists.txt
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/lib/CMakeLists.txt?rev=121510&view=auto
==============================================================================
--- libcxx/trunk/lib/CMakeLists.txt (added)
+++ libcxx/trunk/lib/CMakeLists.txt Fri Dec 10 13:47:54 2010
@@ -0,0 +1,56 @@
+# Get sources
+file(GLOB_RECURSE sources ../src/*.cpp)
+
+# Add all the headers to the project for IDEs.
+if (MSVC_IDE OR XCODE)
+ file(GLOB_RECURSE headers ../include/*)
+ # Force them all into the headers dir on MSVC, otherwise they end up at
+ # project scope because they don't have extensions.
+ if (MSVC_IDE)
+ source_group("Header Files" FILES ${headers})
+ endif()
+endif()
+
+if (LIBCXX_ENABLE_SHARED)
+ add_library(cxx SHARED
+ ${sources}
+ ${headers}
+ )
+else()
+ add_library(cxx STATIC
+ ${sources}
+ ${headers}
+ )
+endif()
+
+# Generate library list.
+append_if(libraries LIBCXX_HAS_PTHREAD_LIB pthread)
+append_if(libraries LIBCXX_HAS_C_LIB c)
+append_if(libraries LIBCXX_HAS_M_LIB m)
+append_if(libraries LIBCXX_HAS_GCC_S_LIB gcc_s)
+
+target_link_libraries(cxx ${libraries})
+
+# Setup flags.
+append_if(compile_flags LIBCXX_HAS_FPIC_FLAG -fPIC)
+append_if(link_flags LIBCXX_HAS_NODEFAULTLIBS_FLAG -nodefaultlibs)
+
+set_target_properties(cxx
+ PROPERTIES
+ COMPILE_FLAGS "${compile_flags}"
+ LINK_FLAGS "${link_flags}"
+ OUTPUT_NAME "c++"
+ VERSION "1.0"
+ SOVERSION "1"
+ )
+
+install(TARGETS cxx
+ LIBRARY DESTINATION lib
+ ARCHIVE DESTINATION lib
+ )
+
+install(DIRECTORY ../include/
+ DESTINATION include/c++/v1
+ FILES_MATCHING
+ PATTERN "*"
+ )
Modified: libcxx/trunk/lib/buildit
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/lib/buildit?rev=121510&r1=121509&r2=121510&view=diff
==============================================================================
--- libcxx/trunk/lib/buildit (original)
+++ libcxx/trunk/lib/buildit Fri Dec 10 13:47:54 2010
@@ -2,7 +2,7 @@
#
# Set the $TRIPLE environment variable to your system's triple before
# running this script. If you set $CXX, that will be used to compile
-# the library. Otherwise we'll use g++.
+# the library. Otherwise we'll use clang++.
set -e
@@ -74,7 +74,7 @@
done
-cc *.o $RC_CFLAGS $LDSHARED_FLAGS
+cc *.o $RC_CFLAGS $LDSHARED_FLAGS
#libtool -static -o libc++.a *.o
Modified: libcxx/trunk/src/locale.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/src/locale.cpp?rev=121510&r1=121509&r2=121510&view=diff
==============================================================================
--- libcxx/trunk/src/locale.cpp (original)
+++ libcxx/trunk/src/locale.cpp Fri Dec 10 13:47:54 2010
@@ -21,8 +21,6 @@
#include <langinfo.h>
#include <stdlib.h>
-// FIXME: Locales are hard.
-#if __APPLE__
_LIBCPP_BEGIN_NAMESPACE_STD
namespace {
@@ -676,61 +674,93 @@
bool
ctype<wchar_t>::do_is(mask m, char_type c) const
{
+#ifdef __APPLE__
return isascii(c) ? _DefaultRuneLocale.__runetype[c] & m : false;
+#else
+ return false;
+#endif
}
const wchar_t*
ctype<wchar_t>::do_is(const char_type* low, const char_type* high, mask* vec) const
{
+#ifdef __APPLE__
for (; low != high; ++low, ++vec)
*vec = static_cast<mask>(isascii(*low) ? _DefaultRuneLocale.__runetype[*low] : 0);
return low;
+#else
+ return NULL;
+#endif
}
const wchar_t*
ctype<wchar_t>::do_scan_is(mask m, const char_type* low, const char_type* high) const
{
+#ifdef __APPLE__
for (; low != high; ++low)
if (isascii(*low) && (_DefaultRuneLocale.__runetype[*low] & m))
break;
return low;
+#else
+ return NULL;
+#endif
}
const wchar_t*
ctype<wchar_t>::do_scan_not(mask m, const char_type* low, const char_type* high) const
{
+#ifdef __APPLE__
for (; low != high; ++low)
if (!(isascii(*low) && (_DefaultRuneLocale.__runetype[*low] & m)))
break;
return low;
+#else
+ return NULL;
+#endif
}
wchar_t
ctype<wchar_t>::do_toupper(char_type c) const
{
+#ifdef __APPLE__
return isascii(c) ? _DefaultRuneLocale.__mapupper[c] : c;
+#else
+ return 0;
+#endif
}
const wchar_t*
ctype<wchar_t>::do_toupper(char_type* low, const char_type* high) const
{
+#ifdef __APPLE__
for (; low != high; ++low)
*low = isascii(*low) ? _DefaultRuneLocale.__mapupper[*low] : *low;
return low;
+#else
+ return NULL;
+#endif
}
wchar_t
ctype<wchar_t>::do_tolower(char_type c) const
{
+#ifdef __APPLE__
return isascii(c) ? _DefaultRuneLocale.__maplower[c] : c;
+#else
+ return 0;
+#endif
}
const wchar_t*
ctype<wchar_t>::do_tolower(char_type* low, const char_type* high) const
{
+#ifdef __APPLE__
for (; low != high; ++low)
*low = isascii(*low) ? _DefaultRuneLocale.__maplower[*low] : *low;
return low;
+#else
+ return NULL;
+#endif
}
wchar_t
@@ -775,8 +805,10 @@
__tab_(tab),
__del_(del)
{
+#ifdef __APPLE__
if (__tab_ == 0)
__tab_ = _DefaultRuneLocale.__runetype;
+#endif
}
ctype<char>::~ctype()
@@ -788,29 +820,45 @@
char
ctype<char>::do_toupper(char_type c) const
{
+#ifdef __APPLE__
return isascii(c) ? _DefaultRuneLocale.__mapupper[c] : c;
+#else
+ return 0;
+#endif
}
const char*
ctype<char>::do_toupper(char_type* low, const char_type* high) const
{
+#ifdef __APPLE__
for (; low != high; ++low)
*low = isascii(*low) ? _DefaultRuneLocale.__mapupper[*low] : *low;
return low;
+#else
+ return NULL;
+#endif
}
char
ctype<char>::do_tolower(char_type c) const
{
+#ifdef __APPLE__
return isascii(c) ? _DefaultRuneLocale.__maplower[c] : c;
+#else
+ return 0;
+#endif
}
const char*
ctype<char>::do_tolower(char_type* low, const char_type* high) const
{
+#ifdef __APPLE__
for (; low != high; ++low)
*low = isascii(*low) ? _DefaultRuneLocale.__maplower[*low] : *low;
return low;
+#else
+ return NULL;
+#endif
}
char
@@ -849,7 +897,11 @@
const ctype<char>::mask*
ctype<char>::classic_table() throw()
{
+#ifdef __APPLE__
return _DefaultRuneLocale.__runetype;
+#else
+ return NULL;
+#endif
}
// template <> class ctype_byname<char>
@@ -947,6 +999,7 @@
const wchar_t*
ctype_byname<wchar_t>::do_is(const char_type* low, const char_type* high, mask* vec) const
{
+#ifdef __APPLE__
for (; low != high; ++low, ++vec)
{
if (isascii(*low))
@@ -975,6 +1028,9 @@
}
}
return low;
+#else
+ return NULL;
+#endif
}
const wchar_t*
@@ -1026,33 +1082,49 @@
wchar_t
ctype_byname<wchar_t>::do_widen(char c) const
{
+#ifdef __APPLE__
return btowc_l(c, __l);
+#else
+ return 0;
+#endif
}
const char*
ctype_byname<wchar_t>::do_widen(const char* low, const char* high, char_type* dest) const
{
+#ifdef __APPLE__
for (; low != high; ++low, ++dest)
*dest = btowc_l(*low, __l);
return low;
+#else
+ return NULL;
+#endif
}
char
ctype_byname<wchar_t>::do_narrow(char_type c, char dfault) const
{
+#ifdef __APPLE__
int r = wctob_l(c, __l);
return r != WEOF ? static_cast<char>(r) : dfault;
+#else
+ return 0;
+#endif
}
const wchar_t*
ctype_byname<wchar_t>::do_narrow(const char_type* low, const char_type* high, char dfault, char* dest) const
{
+#ifdef __APPLE__
for (; low != high; ++low, ++dest)
{
int r = wctob_l(*low, __l);
*dest = r != WEOF ? static_cast<char>(r) : dfault;
}
return low;
+#else
+ return NULL;
+#endif
}
// template <> class codecvt<char, char, mbstate_t>
@@ -1148,6 +1220,7 @@
const intern_type* frm, const intern_type* frm_end, const intern_type*& frm_nxt,
extern_type* to, extern_type* to_end, extern_type*& to_nxt) const
{
+#ifdef __APPLE__
// look for first internal null in frm
const intern_type* fend = frm;
for (; fend != frm_end; ++fend)
@@ -1197,6 +1270,9 @@
}
}
return frm_nxt == frm_end ? ok : partial;
+#else
+ return error;
+#endif
}
codecvt<wchar_t, char, mbstate_t>::result
@@ -1204,6 +1280,7 @@
const extern_type* frm, const extern_type* frm_end, const extern_type*& frm_nxt,
intern_type* to, intern_type* to_end, intern_type*& to_nxt) const
{
+#ifdef __APPLE__
// look for first internal null in frm
const extern_type* fend = frm;
for (; fend != frm_end; ++fend)
@@ -1261,12 +1338,16 @@
}
}
return frm_nxt == frm_end ? ok : partial;
+#else
+ return error;
+#endif
}
codecvt<wchar_t, char, mbstate_t>::result
codecvt<wchar_t, char, mbstate_t>::do_unshift(state_type& st,
extern_type* to, extern_type* to_end, extern_type*& to_nxt) const
{
+#ifdef __APPLE__
to_nxt = to;
extern_type tmp[MB_LEN_MAX];
size_t n = wcrtomb_l(tmp, intern_type(), &st, __l);
@@ -1278,11 +1359,15 @@
for (extern_type* p = tmp; n; --n) // write it
*to_nxt++ = *p++;
return ok;
+#else
+ return error;
+#endif
}
int
codecvt<wchar_t, char, mbstate_t>::do_encoding() const throw()
{
+#ifdef __APPLE__
if (mbtowc_l(0, 0, MB_LEN_MAX, __l) == 0)
{
// stateless encoding
@@ -1291,6 +1376,9 @@
return 0;
}
return -1;
+#else
+ return 0;
+#endif
}
bool
@@ -1303,6 +1391,7 @@
codecvt<wchar_t, char, mbstate_t>::do_length(state_type& st,
const extern_type* frm, const extern_type* frm_end, size_t mx) const
{
+#ifdef __APPLE__
int nbytes = 0;
for (size_t nwchar_t = 0; nwchar_t < mx && frm != frm_end; ++nwchar_t)
{
@@ -1323,12 +1412,19 @@
}
}
return nbytes;
+#else
+ return 0;
+#endif
}
int
codecvt<wchar_t, char, mbstate_t>::do_max_length() const throw()
{
+#ifdef __APPLE__
return __l == 0 ? 1 : MB_CUR_MAX_L(__l);
+#else
+ return 0;
+#endif
}
// Valid UTF ranges
@@ -3869,6 +3965,7 @@
void
numpunct_byname<char>::__init(const char* nm)
{
+#ifdef __APPLE__
if (strcmp(nm, "C") != 0)
{
unique_ptr<_xlocale, int(*)(locale_t)> loc(newlocale(LC_ALL_MASK, nm, 0), freelocale);
@@ -3885,6 +3982,7 @@
__grouping_ = lc->grouping;
// locallization for truename and falsename is not available
}
+#endif
}
// numpunct_byname<wchar_t>
@@ -3908,6 +4006,7 @@
void
numpunct_byname<wchar_t>::__init(const char* nm)
{
+#ifdef __APPLE__
if (strcmp(nm, "C") != 0)
{
unique_ptr<_xlocale, int(*)(locale_t)> loc(newlocale(LC_ALL_MASK, nm, 0), freelocale);
@@ -3924,6 +4023,7 @@
__grouping_ = lc->grouping;
// locallization for truename and falsename is not available
}
+#endif
}
// num_get helpers
@@ -4488,6 +4588,7 @@
wstring
__time_get_storage<wchar_t>::__analyze(char fmt, const ctype<wchar_t>& ct)
{
+#ifdef __APPLE__
tm t;
t.tm_sec = 59;
t.tm_min = 55;
@@ -4632,6 +4733,9 @@
++wbb;
}
return result;
+#else
+ return wstring();
+#endif
}
template <>
@@ -4675,6 +4779,7 @@
void
__time_get_storage<wchar_t>::init(const ctype<wchar_t>& ct)
{
+#ifdef __APPLE__
tm t = {0};
char buf[100];
size_t be;
@@ -4746,6 +4851,7 @@
__r_ = __analyze('r', ct);
__x_ = __analyze('x', ct);
__X_ = __analyze('X', ct);
+#endif
}
template <class CharT>
@@ -5007,6 +5113,7 @@
__time_put::__do_put(wchar_t* __wb, wchar_t*& __we, const tm* __tm,
char __fmt, char __mod) const
{
+#ifdef __APPLE__
char __nar[100];
char* __ne = __nar + 100;
__do_put(__nar, __ne, __tm, __fmt, __mod);
@@ -5016,6 +5123,7 @@
if (j == -1)
__throw_runtime_error("locale not supported");
__we = __wb + j;
+#endif
}
// moneypunct_byname
@@ -5260,6 +5368,7 @@
void
moneypunct_byname<char, false>::init(const char* nm)
{
+#ifdef __APPLE__
typedef moneypunct<char, false> base;
unique_ptr<_xlocale, int(*)(locale_t)> loc(newlocale(LC_ALL_MASK, nm, 0), freelocale);
#ifndef _LIBCPP_NO_EXCEPTIONS
@@ -5292,12 +5401,14 @@
__negative_sign_ = lc->negative_sign;
__init_pat(__pos_format_, lc->p_cs_precedes, lc->p_sep_by_space, lc->p_sign_posn);
__init_pat(__neg_format_, lc->n_cs_precedes, lc->n_sep_by_space, lc->n_sign_posn);
+#endif
}
template<>
void
moneypunct_byname<char, true>::init(const char* nm)
{
+#ifdef __APPLE__
typedef moneypunct<char, true> base;
unique_ptr<_xlocale, int(*)(locale_t)> loc(newlocale(LC_ALL_MASK, nm, 0), freelocale);
#ifndef _LIBCPP_NO_EXCEPTIONS
@@ -5330,12 +5441,14 @@
__negative_sign_ = lc->negative_sign;
__init_pat(__pos_format_, lc->int_p_cs_precedes, lc->int_p_sep_by_space, lc->int_p_sign_posn);
__init_pat(__neg_format_, lc->int_n_cs_precedes, lc->int_n_sep_by_space, lc->int_n_sign_posn);
+#endif
}
template<>
void
moneypunct_byname<wchar_t, false>::init(const char* nm)
{
+#ifdef __APPLE__
typedef moneypunct<wchar_t, false> base;
unique_ptr<_xlocale, int(*)(locale_t)> loc(newlocale(LC_ALL_MASK, nm, 0), freelocale);
#ifndef _LIBCPP_NO_EXCEPTIONS
@@ -5391,12 +5504,14 @@
}
__init_pat(__pos_format_, lc->p_cs_precedes, lc->p_sep_by_space, lc->p_sign_posn);
__init_pat(__neg_format_, lc->n_cs_precedes, lc->n_sep_by_space, lc->n_sign_posn);
+#endif
}
template<>
void
moneypunct_byname<wchar_t, true>::init(const char* nm)
{
+#ifdef __APPLE__
typedef moneypunct<wchar_t, true> base;
unique_ptr<_xlocale, int(*)(locale_t)> loc(newlocale(LC_ALL_MASK, nm, 0), freelocale);
#ifndef _LIBCPP_NO_EXCEPTIONS
@@ -5452,6 +5567,7 @@
}
__init_pat(__pos_format_, lc->int_p_cs_precedes, lc->int_p_sep_by_space, lc->int_p_sign_posn);
__init_pat(__neg_format_, lc->int_n_cs_precedes, lc->int_n_sep_by_space, lc->int_n_sign_posn);
+#endif
}
void __do_nothing(void*) {}
@@ -5526,4 +5642,3 @@
template class __vector_base_common<true>;
_LIBCPP_END_NAMESPACE_STD
-#endif // __APPLE__
Added: libcxx/trunk/test/CMakeLists.txt
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/CMakeLists.txt?rev=121510&view=auto
==============================================================================
--- libcxx/trunk/test/CMakeLists.txt (added)
+++ libcxx/trunk/test/CMakeLists.txt Fri Dec 10 13:47:54 2010
@@ -0,0 +1,44 @@
+macro(pythonize_bool var)
+ if (${var})
+ set(${var} True)
+ else()
+ set(${var} False)
+ endif()
+endmacro()
+
+include(FindPythonInterp)
+if(PYTHONINTERP_FOUND)
+ set(LIT_EXECUTABLE "" CACHE FILEPATH "Path to LLVM's lit.py.")
+ set(LIT_ARGS_DEFAULT "-sv")
+ if (MSVC OR XCODE)
+ set(LIT_ARGS_DEFAULT "${LIT_ARGS_DEFAULT} --no-progress-bar")
+ endif()
+ set(LLVM_LIT_ARGS "${LIT_ARGS_DEFAULT}"
+ CACHE STRING "Default options for lit")
+ set(LIT_ARGS "${LLVM_LIT_ARGS}")
+ separate_arguments(LIT_ARGS)
+
+ set(LIBCXX_COMPILER ${CMAKE_CXX_COMPILER})
+ set(LIBCXX_SOURCE_DIR ${CMAKE_SOURCE_DIR})
+ set(LIBCXX_BINARY_DIR ${CMAKE_BINARY_DIR})
+ set(PYTHON_EXECUTABLE ${PYTHON_EXECUTABLE})
+ pythonize_bool(LIBCXX_ENABLE_SHARED)
+ pythonize_bool(LIBCXX_HAS_STDCXX0X_FLAG)
+
+ set(AUTO_GEN_COMMENT "## Autogenerated by libcxx configuration.\n# Do not edit!")
+
+ configure_file(
+ ${CMAKE_CURRENT_SOURCE_DIR}/lit.site.cfg.in
+ ${CMAKE_CURRENT_BINARY_DIR}/lit.site.cfg
+ @ONLY)
+
+ add_custom_target(check
+ COMMAND ${PYTHON_EXECUTABLE}
+ ${LIT_EXECUTABLE}
+ ${LIT_ARGS}
+ ${CMAKE_CURRENT_BINARY_DIR}
+ DEPENDS
+ COMMENT "Running libcxx tests")
+else()
+ message(WARNING "Could not find Python, no check target will be available!")
+endif()
Modified: libcxx/trunk/test/lit.cfg
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/lit.cfg?rev=121510&r1=121509&r2=121510&view=diff
==============================================================================
--- libcxx/trunk/test/lit.cfg (original)
+++ libcxx/trunk/test/lit.cfg Fri Dec 10 13:47:54 2010
@@ -3,6 +3,7 @@
# Configuration file for the 'lit' test runner.
import os
+import sys
import platform
import tempfile
import signal
@@ -66,8 +67,9 @@
exec_file.close()
try:
- cmd = [self.cxx_under_test, '-o', exec_path,
+ compile_cmd = [self.cxx_under_test, '-o', exec_path,
source_path] + self.cpp_flags + self.ld_flags
+ cmd = compile_cmd
out, err, exitCode = self.execute_command(cmd)
if exitCode != 0:
report = """Command: %s\n""" % ' '.join(["'%s'" % a
@@ -83,7 +85,9 @@
cmd = [exec_path]
out, err, exitCode = self.execute_command(cmd)
if exitCode != 0:
- report = """Command: %s\n""" % ' '.join(["'%s'" % a
+ report = """Compiled With: %s\n""" % ' '.join(["'%s'" % a
+ for a in compile_cmd])
+ report += """Command: %s\n""" % ' '.join(["'%s'" % a
for a in cmd])
report += """Exit Code: %d\n""" % exitCode
if out:
@@ -111,12 +115,35 @@
# FIXME: Would be nice to Use -stdlib=libc++ option with Clang's that accept it.
cxx_under_test = lit.params.get('cxx_under_test', None)
if cxx_under_test is None:
- lit.fatal('must specify user parameter cxx_under_test '
- '(e.g., --param=cxx_under_test=clang++)')
+ cxx_under_test = getattr(config, 'cxx_under_test', None)
+ if cxx_under_test is None:
+ lit.fatal('must specify user parameter cxx_under_test '
+ '(e.g., --param=cxx_under_test=clang++)')
+include_paths = []
+library_paths = []
+
+libcxx_src_root = getattr(config, 'libcxx_src_root', None)
+if libcxx_src_root is not None:
+ include_paths += ['-I' + libcxx_src_root + '/include']
+else:
+ include_paths += ['-I/usr/include/c++/v1']
+
+libcxx_obj_root = getattr(config, 'libcxx_obj_root', None)
+if libcxx_obj_root is not None:
+ library_paths += ['-L' + libcxx_obj_root + '/lib']
+else:
+ libcxx_obj_root = "/usr"
+
+# Configure extra libraries.
+libraries = []
+if sys.platform == 'darwin':
+ libraries += ['-lSystem']
+if sys.platform == 'linux2':
+ libraries += ['-lgcc_eh', '-lsupc++', '-lc', '-lm', '-lgcc_s']
+ libraries += ['-Wl,-R', libcxx_obj_root + '/lib']
+
config.test_format = LibcxxTestFormat(cxx_under_test,
- cpp_flags = ['-nostdinc++',
- '-I/usr/include/c++/v1'],
- ld_flags = ['-nodefaultlibs', '-lc++',
- '-lSystem'])
+ cpp_flags = ['-nostdinc++'] + include_paths,
+ ld_flags = ['-nodefaultlibs'] + library_paths + ['-lc++'] + libraries)
config.target_triple = None
Added: libcxx/trunk/test/lit.site.cfg.in
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/lit.site.cfg.in?rev=121510&view=auto
==============================================================================
--- libcxx/trunk/test/lit.site.cfg.in (added)
+++ libcxx/trunk/test/lit.site.cfg.in Fri Dec 10 13:47:54 2010
@@ -0,0 +1,10 @@
+ at AUTO_GEN_COMMENT@
+config.cxx_under_test = "@LIBCXX_COMPILER@"
+config.cxx_has_stdcxx0x_flag = @LIBCXX_HAS_STDCXX0X_FLAG@
+config.libcxx_src_root = "@LIBCXX_SOURCE_DIR@"
+config.libcxx_obj_root = "@LIBCXX_BINARY_DIR@"
+config.python_executable = "@PYTHON_EXECUTABLE@"
+config.enable_shared = @LIBCXX_ENABLE_SHARED@
+
+# Let the main config do the real work.
+lit.load_config(config, "@LIBCXX_SOURCE_DIR@/test/lit.cfg")
More information about the cfe-commits
mailing list