Skip to content

Commit

Permalink
Added a test that the C++ runtime is really useable (i.e. exports the…
Browse files Browse the repository at this point in the history
… symbols that we need).
  • Loading branch information
theraven committed Jun 21, 2013
1 parent 3b9bbf2 commit 60a3605
Show file tree
Hide file tree
Showing 3 changed files with 75 additions and 1 deletion.
7 changes: 7 additions & 0 deletions CMake/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
cmake_minimum_required(VERSION 2.8)

add_executable(test_cxx_runtime typeinfo_test.cc)
set(CMAKE_CXX_IMPLICIT_LINK_LIBRARIES "")
target_link_libraries(test_cxx_runtime ${CXX_RUNTIME})
set_target_properties(test_cxx_runtime PROPERTIES
LINKER_LANGUAGE C)
61 changes: 61 additions & 0 deletions CMake/typeinfo_test.cc
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
#include <stdint.h>

namespace __cxxabiv1
{
struct __class_type_info;
}

using __cxxabiv1::__class_type_info;

namespace std
{
/**
* std::type_info defined with the GCC ABI. This may not be exposed in
* public headers, but is required for correctly implementing the unified
* exception model.
*/
class type_info
{
public:
virtual ~type_info();
bool operator==(const type_info &) const;
bool operator!=(const type_info &) const;
bool before(const type_info &) const;
type_info();
private:
type_info(const type_info& rhs);
type_info& operator= (const type_info& rhs);
const char *__type_name;
protected:
type_info(const char *name): __type_name(name) { }
public:
const char* name() const { return __type_name; }
virtual bool __is_pointer_p() const;
virtual bool __is_function_p() const;
virtual bool __do_catch(const type_info *thrown_type,
void **thrown_object,
unsigned outer) const;
virtual bool __do_upcast(
const __class_type_info *target,
void **thrown_object) const;
};
}

class type_info2 : public std::type_info
{
public:
virtual bool __is_pointer_p() const;
virtual bool __is_function_p() const { return true; }
virtual bool __do_catch(const type_info *thrown_type,
void **thrown_object,
unsigned outer) const { return true; }
virtual bool __do_upcast(
const __class_type_info *target,
void **thrown_object) const { return true; }
};
bool type_info2::__is_pointer_p() const { return true; }

int main()
{
return 0;
}
8 changes: 7 additions & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -193,7 +193,13 @@ if (ENABLE_OBJCXX)
# a separate libobjcxx.
if (CXX_RUNTIME)
message(STATUS "Using ${CXX_RUNTIME} as the C++ runtime library")
if (FORCE_LIBOBJCXX)
try_compile( USERUNTIME
"${CMAKE_BINARY_DIR}/CMake"
"${CMAKE_SOURCE_DIR}/CMake"
test_cxx_runtime
CMAKE_FLAGS "-DCXX_RUNTIME=${CXX_RUNTIME}")
message(STATUS "Is runtime useable? ${USERUNTIME}")
if (${FORCE_LIBOBJCXX} OR NOT ${USERUNTIME})
message(STATUS "Forcing build of stand-alone libobjcxx")
add_library(objcxx SHARED ${libobjcxx_CXX_SRCS})
set_target_properties(objcxx PROPERTIES
Expand Down

0 comments on commit 60a3605

Please sign in to comment.