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

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


The following commit(s) were added to refs/heads/main by this push:
     new a970fd72b3 GH-43688: [C++] Prevent Snappy from disabling RTTI when 
bundled (#43706)
a970fd72b3 is described below

commit a970fd72b3debbaf4ef797025e06efa45ba588f8
Author: Antoine Pitrou <[email protected]>
AuthorDate: Fri Aug 16 04:32:25 2024 +0200

    GH-43688: [C++] Prevent Snappy from disabling RTTI when bundled (#43706)
    
    ### Rationale for this change
    
    Snappy's CMakeLists.txt unconditionally disables RTTI. This is incompatible 
with some other options, such as activating UBSAN for a fuzzing build:
    https://github.com/google/snappy/issues/189
    
    ### What changes are included in this PR?
    
    Add `-frtti` at the end of compiler options when compiling a bundled Snappy 
build.
    
    ### Are these changes tested?
    
    On CI; also manually checked that this allows enabling Snappy on OSS-Fuzz 
builds.
    
    ### Are there any user-facing changes?
    
    No.
    
    * GitHub Issue: #43688
    
    Lead-authored-by: Antoine Pitrou <[email protected]>
    Co-authored-by: Antoine Pitrou <[email protected]>
    Co-authored-by: Sutou Kouhei <[email protected]>
    Co-authored-by: Sutou Kouhei <[email protected]>
    Signed-off-by: Sutou Kouhei <[email protected]>
---
 cpp/cmake_modules/ThirdpartyToolchain.cmake | 22 +++++++++++++++-------
 1 file changed, 15 insertions(+), 7 deletions(-)

diff --git a/cpp/cmake_modules/ThirdpartyToolchain.cmake 
b/cpp/cmake_modules/ThirdpartyToolchain.cmake
index 495aa70483..bc3a3a2249 100644
--- a/cpp/cmake_modules/ThirdpartyToolchain.cmake
+++ b/cpp/cmake_modules/ThirdpartyToolchain.cmake
@@ -1355,16 +1355,24 @@ macro(build_snappy)
       "-DCMAKE_INSTALL_PREFIX=${SNAPPY_PREFIX}")
   # Snappy unconditionally enables -Werror when building with clang this can 
lead
   # to build failures by way of new compiler warnings. This adds a flag to 
disable
-  # Werror to the very end of the invocation to override the snappy internal 
setting.
+  # -Werror to the very end of the invocation to override the snappy internal 
setting.
+  set(SNAPPY_ADDITIONAL_CXX_FLAGS "")
   if(CMAKE_CXX_COMPILER_ID MATCHES "Clang")
-    foreach(CONFIG DEBUG MINSIZEREL RELEASE RELWITHDEBINFO)
-      list(APPEND
-           SNAPPY_CMAKE_ARGS
-           
"-DCMAKE_CXX_FLAGS_${UPPERCASE_BUILD_TYPE}=${EP_CXX_FLAGS_${CONFIG}} -Wno-error"
-      )
-    endforeach()
+    string(APPEND SNAPPY_ADDITIONAL_CXX_FLAGS " -Wno-error")
+  endif()
+  # Snappy unconditionally disables RTTI, which is incompatible with some other
+  # build settings (https://github.com/apache/arrow/issues/43688).
+  if(NOT MSVC)
+    string(APPEND SNAPPY_ADDITIONAL_CXX_FLAGS " -frtti")
   endif()
 
+  foreach(CONFIG DEBUG MINSIZEREL RELEASE RELWITHDEBINFO)
+    list(APPEND
+         SNAPPY_CMAKE_ARGS
+         "-DCMAKE_CXX_FLAGS_${CONFIG}=${EP_CXX_FLAGS_${CONFIG}} 
${SNAPPY_ADDITIONAL_CXX_FLAGS}"
+    )
+  endforeach()
+
   if(APPLE AND CMAKE_HOST_SYSTEM_VERSION VERSION_LESS 20)
     # On macOS 10.13 we need to explicitly add <functional> to avoid a missing 
include error
     # This can be removed once CRAN no longer checks on macOS 10.13

Reply via email to