llvm.org GIT mirror llvm / 7ba0c20
llvm-config: Add --has-rtti option Summary: This prints NO if LLVM was built with -fno-rtti or an equivalent flag and YES otherwise. The reasons to add -has-rtti rather than adding -fno-rtti to --cxxflags are: 1. Building LLVM with -fno-rtti does not always mean that client applications need this flag. 2. Some compilers have a different flag for disabling rtti, and the compiler being used to build LLVM may not be the compiler being used to build the application. Reviewers: echristo, chandlerc, beanz Subscribers: llvm-commits Differential Revision: http://reviews.llvm.org/D11849 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@252075 91177308-0d34-0410-b5e6-96231b3b80d8 Tom Stellard 4 years ago
5 changed file(s) with 15 addition(s) and 0 deletion(s). Raw diff Collapse all Expand all
2525
2626 # LLVM_REQUIRES_RTTI is an internal flag that individual
2727 # targets can use to force RTTI
28 set(LLVM_CONFIG_HAS_RTTI YES CACHE INTERNAL "")
2829 if(NOT (LLVM_REQUIRES_RTTI OR LLVM_ENABLE_RTTI))
30 set(LLVM_CONFIG_HAS_RTTI NO CACHE INTERNAL "")
2931 list(APPEND LLVM_COMPILE_DEFINITIONS GTEST_HAS_RTTI=0)
3032 if (LLVM_COMPILER_IS_GCC_COMPATIBLE)
3133 list(APPEND LLVM_COMPILE_FLAGS "-fno-rtti")
2626 #define LLVM_TARGETS_BUILT "@LLVM_TARGETS_BUILT@"
2727 #define LLVM_SYSTEM_LIBS "@LLVM_SYSTEM_LIBS@"
2828 #define LLVM_BUILD_SYSTEM "@LLVM_BUILD_SYSTEM@"
29 #define LLVM_HAS_RTTI "@LLVM_HAS_RTTI@"
2424 set(LLVM_CFLAGS "${CMAKE_C_FLAGS} ${CMAKE_C_FLAGS_${uppercase_CMAKE_BUILD_TYPE}} ${LLVM_DEFINITIONS}")
2525 set(LLVM_CXXFLAGS "${CMAKE_CXX_FLAGS} ${CMAKE_CXX_FLAGS_${uppercase_CMAKE_BUILD_TYPE}} ${COMPILE_FLAGS} ${LLVM_DEFINITIONS}")
2626 set(LLVM_BUILD_SYSTEM cmake)
27 set(LLVM_HAS_RTTI ${LLVM_CONFIG_HAS_RTTI})
2728
2829 # Use the C++ link flags, since they should be a superset of C link flags.
2930 set(LLVM_LDFLAGS "${CMAKE_CXX_LINK_FLAGS}")
3737 LLVM_SYSTEM_LIBS := $(LIBS)
3838 endif
3939
40 ifneq ($(REQUIRES_RTTI), 1)
41 LLVM_HAS_RTTI := NO
42 else
43 LLVM_HAS_RTTI := YES
44 endif
45
4046 # This is blank for now. We need to be careful about adding stuff here:
4147 # LDFLAGS tend not to be portable, and we don't currently require the
4248 # user to use libtool when linking against LLVM.
6672 >> temp.sed
6773 $(Verb) $(ECHO) 's/@LLVM_BUILD_SYSTEM@/autoconf/' \
6874 >> temp.sed
75 $(Verb) $(ECHO) 's/@LLVM_HAS_RTTI@/$(LLVM_HAS_RTTI)/' \
76 >> temp.sed
6977 $(Verb) $(SED) -f temp.sed < $< > $@
7078 $(Verb) $(RM) temp.sed
7179
157157 --build-mode Print build mode of LLVM tree (e.g. Debug or Release).\n\
158158 --assertion-mode Print assertion mode of LLVM tree (ON or OFF).\n\
159159 --build-system Print the build system used to build LLVM (autoconf or cmake).\n\
160 --has-rtti Print whether or not LLVM was built with rtti (YES or NO).\n\
160161 Typical components:\n\
161162 all All LLVM libraries (default).\n\
162163 engine Either a native JIT or a bitcode interpreter.\n";
325326 #endif
326327 } else if (Arg == "--build-system") {
327328 OS << LLVM_BUILD_SYSTEM << '\n';
329 } else if (Arg == "--has-rtti") {
330 OS << LLVM_HAS_RTTI << '\n';
328331 } else if (Arg == "--obj-root") {
329332 OS << ActivePrefix << '\n';
330333 } else if (Arg == "--src-root") {