Enable BOOST_NO_EXCEPTIONS for codegened code BOOST_NO_EXCEPTIONS lets us provide an handler for errors instead of having boost throw exceptions. This lets us crash the process in a slightly nicer way and also greatly reduces the number of static exception objects littering the cross-compiled IR module, which helps with codegen time.
Also turn on colour diagnostics for cross-compiled clang (it's already enabled for ASAN clang). Change-Id: Iaff17b502a752963346b3a2f17fc58d22e778d50 Reviewed-on: http://gerrit.cloudera.org:8080/2909 Reviewed-by: Tim Armstrong <[email protected]> Tested-by: Internal Jenkins Project: http://git-wip-us.apache.org/repos/asf/incubator-impala/repo Commit: http://git-wip-us.apache.org/repos/asf/incubator-impala/commit/01baf57a Tree: http://git-wip-us.apache.org/repos/asf/incubator-impala/tree/01baf57a Diff: http://git-wip-us.apache.org/repos/asf/incubator-impala/diff/01baf57a Branch: refs/heads/master Commit: 01baf57aa4ca82acb0967ffaca5165ab0572ee59 Parents: a41710a Author: Tim Armstrong <[email protected]> Authored: Fri Apr 29 11:50:16 2016 -0700 Committer: Tim Armstrong <[email protected]> Committed: Thu May 12 14:17:51 2016 -0700 ---------------------------------------------------------------------- be/CMakeLists.txt | 4 +++- be/src/codegen/llvm-codegen.cc | 11 +++++++++++ 2 files changed, 14 insertions(+), 1 deletion(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/incubator-impala/blob/01baf57a/be/CMakeLists.txt ---------------------------------------------------------------------- diff --git a/be/CMakeLists.txt b/be/CMakeLists.txt index 4f7620f..1c63903 100644 --- a/be/CMakeLists.txt +++ b/be/CMakeLists.txt @@ -135,9 +135,11 @@ add_definitions(-DHAVE_INTTYPES_H -DHAVE_NETINET_IN_H -DHAVE_NETDB_H) # -Wno-c++11-extensions: c++11 extensions are ok as long as clang supports them # -Wno-return-type-c-linkage: UDFs return C++ classes but use C linkage to prevent # mangling +# -DBOOST_NO_EXCEPTIONS: call a custom error handler for exceptions in codegen'd code. set(CLANG_IR_CXX_FLAGS "-emit-llvm" "-c" "-DIR_COMPILE" "-DNDEBUG" "-DHAVE_INTTYPES_H" "-DHAVE_NETINET_IN_H" "-DBOOST_DATE_TIME_POSIX_TIME_STD_CONFIG" - "-Wno-deprecated" "-Wno-c++11-extensions" "-Wno-return-type-c-linkage" "-O1") + "-DBOOST_NO_EXCEPTIONS" "-fcolor-diagnostics" "-Wno-deprecated" "-Wno-c++11-extensions" + "-Wno-return-type-c-linkage" "-O1") if (IMPALA_TOOLCHAIN) # -Werror: compile warnings should be errors when using the toolchain compiler. SET(CLANG_IR_CXX_FLAGS "${CLANG_IR_CXX_FLAGS}" "-Werror") http://git-wip-us.apache.org/repos/asf/incubator-impala/blob/01baf57a/be/src/codegen/llvm-codegen.cc ---------------------------------------------------------------------- diff --git a/be/src/codegen/llvm-codegen.cc b/be/src/codegen/llvm-codegen.cc index 0e82bde..bbfd419 100644 --- a/be/src/codegen/llvm-codegen.cc +++ b/be/src/codegen/llvm-codegen.cc @@ -1145,3 +1145,14 @@ Value* LlvmCodeGen::GetPtrTo(LlvmBuilder* builder, Value* v, const char* name) { } } + +namespace boost { + +/// Handler for exceptions in cross-compiled functions. +/// When boost is configured with BOOST_NO_EXCEPTIONS, it calls this handler instead of +/// throwing the exception. +void throw_exception(std::exception const &e) { + LOG(FATAL) << "Cannot handle exceptions in codegen'd code " << e.what(); +} + +}
