This is an automated email from the ASF dual-hosted git repository.

wesm pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/arrow.git

commit 9265fe35b67db93f5af0b47e92e039c637ad5b3e
Author: praveenbingo <[email protected]>
AuthorDate: Tue Sep 25 14:43:50 2018 +0530

    [Gandiva] Hide stdc++ from being exported.
    
    Statically linked stdc++ causes issues when other libraries load different
    stdc++. Hiding all symbols as local to prevent any conflicts with clients.
---
 cpp/src/gandiva/execution_context.cc | 15 +++++++++++----
 cpp/src/gandiva/execution_context.h  |  3 ++-
 cpp/src/gandiva/jni/CMakeLists.txt   |  6 ++++++
 cpp/src/gandiva/jni/symbols.map      |  4 ++++
 cpp/src/gandiva/symbols-helpers.map  |  4 ++++
 5 files changed, 27 insertions(+), 5 deletions(-)

diff --git a/cpp/src/gandiva/execution_context.cc 
b/cpp/src/gandiva/execution_context.cc
index b3fd149..d54bffd 100644
--- a/cpp/src/gandiva/execution_context.cc
+++ b/cpp/src/gandiva/execution_context.cc
@@ -20,14 +20,21 @@ namespace helpers {
 #endif
 
 void ExecutionContext::set_error_msg(const char *error_msg) {
-  if (error_msg_.empty()) {
-    error_msg_ = std::string(error_msg);
+  if (error_msg_.get() == nullptr) {
+    error_msg_.reset(new std::string(error_msg));
   }
 }
 
-std::string ExecutionContext::get_error() const { return error_msg_; }
+std::string ExecutionContext::get_error() const {
+  if (error_msg_.get() != nullptr) {
+    return *(error_msg_.get());
+  }
+  return std::string("");
+}
 
-bool ExecutionContext::has_error() const { return !error_msg_.empty(); }
+bool ExecutionContext::has_error() const {
+  return error_msg_.get() != nullptr && !(error_msg_.get()->empty());
+}
 
 #ifdef GDV_HELPERS
 }
diff --git a/cpp/src/gandiva/execution_context.h 
b/cpp/src/gandiva/execution_context.h
index 85a82f4..ed90232 100644
--- a/cpp/src/gandiva/execution_context.h
+++ b/cpp/src/gandiva/execution_context.h
@@ -15,6 +15,7 @@
 #ifndef ERROR_HOLDER_H
 #define ERROR_HOLDER_H
 
+#include <memory>
 #include <string>
 
 namespace gandiva {
@@ -31,7 +32,7 @@ class ExecutionContext {
   bool has_error() const;
 
  private:
-  std::string error_msg_;
+  std::unique_ptr<std::string> error_msg_;
 };
 #ifdef GDV_HELPERS
 }
diff --git a/cpp/src/gandiva/jni/CMakeLists.txt 
b/cpp/src/gandiva/jni/CMakeLists.txt
index b41471b..cd20b0e 100644
--- a/cpp/src/gandiva/jni/CMakeLists.txt
+++ b/cpp/src/gandiva/jni/CMakeLists.txt
@@ -72,6 +72,12 @@ target_include_directories(gandiva_jni
     ${CMAKE_SOURCE_DIR}/src
 )
 
+# filter out everything that is not needed for the jni bridge
+# statically linked stdc++ has conflicts with stdc++ loaded by other libraries.
+if (NOT APPLE)
+set_target_properties(gandiva_jni PROPERTIES LINK_FLAGS 
"-Wl,--version-script=${CMAKE_SOURCE_DIR}/src/jni/symbols.map")
+endif()
+
 # PROTOBUF is a private dependency i.e users of gandiva also will not have a 
dependency on protobuf.
 target_link_libraries(gandiva_jni
   PRIVATE
diff --git a/cpp/src/gandiva/jni/symbols.map b/cpp/src/gandiva/jni/symbols.map
new file mode 100644
index 0000000..a228500
--- /dev/null
+++ b/cpp/src/gandiva/jni/symbols.map
@@ -0,0 +1,4 @@
+{
+  global: extern "C++" { gandiva*; Java*; JNI*; };
+  local: *;
+};
diff --git a/cpp/src/gandiva/symbols-helpers.map 
b/cpp/src/gandiva/symbols-helpers.map
new file mode 100644
index 0000000..8f77d16
--- /dev/null
+++ b/cpp/src/gandiva/symbols-helpers.map
@@ -0,0 +1,4 @@
+{
+  global: extern "C++" { gandiva*; like*;};
+  local: *;
+};

Reply via email to