Added LLVM_ENABLE_RTTI and LLVM_ENABLE_EH options that allow RTTI and EH

to globally be controlled. Individual targets (e.g.  ExceptionDemo) can
still override this by using LLVM_REQUIRE_RTTI and LLVM_REQUIRE_EH if
they need to be compiled with RTTI or exception handling respectively.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@213663 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Dan Liew
2014-07-22 15:41:18 +00:00
parent 578c74e35d
commit 976824a7a4
4 changed files with 27 additions and 3 deletions

View File

@@ -8,8 +8,13 @@ function(llvm_update_compile_flags name)
set(update_src_props ON)
endif()
if(LLVM_REQUIRES_EH)
set(LLVM_REQUIRES_RTTI ON)
# LLVM_REQUIRES_EH is an internal flag that individual
# targets can use to force EH
if(LLVM_REQUIRES_EH OR LLVM_ENABLE_EH)
if(NOT (LLVM_REQUIRES_RTTI OR LLVM_ENABLE_RTTI))
message(AUTHOR_WARNING "Exception handling requires RTTI. Enabling RTTI for ${name}")
set(LLVM_REQUIRES_RTTI ON)
endif()
else()
if(LLVM_COMPILER_IS_GCC_COMPATIBLE)
list(APPEND LLVM_COMPILE_FLAGS "-fno-exceptions")
@@ -19,7 +24,9 @@ function(llvm_update_compile_flags name)
endif()
endif()
if(NOT LLVM_REQUIRES_RTTI)
# LLVM_REQUIRES_RTTI is an internal flag that individual
# targets can use to force RTTI
if(NOT (LLVM_REQUIRES_RTTI OR LLVM_ENABLE_RTTI))
list(APPEND LLVM_COMPILE_DEFINITIONS GTEST_HAS_RTTI=0)
if (LLVM_COMPILER_IS_GCC_COMPATIBLE)
list(APPEND LLVM_COMPILE_FLAGS "-fno-rtti")

View File

@@ -408,6 +408,13 @@ if(MSVC)
string(REGEX REPLACE "(^| ) */GR-? *( |$)" "\\1 \\2" CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}")
endif()
# Provide public options to globally control RTTI and EH
option(LLVM_ENABLE_EH "Enable Exception handling" OFF)
option(LLVM_ENABLE_RTTI "Enable run time type information" OFF)
if(LLVM_ENABLE_EH AND NOT LLVM_ENABLE_RTTI)
message(FATAL_ERROR "Exception handling requires RTTI. You must set LLVM_ENABLE_RTTI to ON")
endif()
# Plugin support
# FIXME: Make this configurable.
if(WIN32 OR CYGWIN)