Skip to content

Commit

Permalink
[Enhancement] patching flatbuffers CMakeLists.txt
Browse files Browse the repository at this point in the history
Signed-off-by: Kevin Xiaohua Cai <[email protected]>
  • Loading branch information
kevincai committed Jan 2, 2025
1 parent e494f6e commit db35d49
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 6 deletions.
6 changes: 0 additions & 6 deletions thirdparty/build-thirdparty.sh
Original file line number Diff line number Diff line change
Expand Up @@ -652,18 +652,12 @@ build_flatbuffers() {
cd $BUILD_DIR
rm -rf CMakeCache.txt CMakeFiles/

# reset the optimization level to O2 to avoid "stringop-overread" warnings/errors
export CXXFLAGS="$CXXFLAGS -O2"
export CPPFLAGS="$CPPFLAGS -O2"

LDFLAGS="-static-libstdc++ -static-libgcc" \
${CMAKE_CMD} .. -G "${CMAKE_GENERATOR}" -DFLATBUFFERS_BUILD_TESTS=OFF
${BUILD_SYSTEM} -j$PARALLEL
cp flatc $TP_INSTALL_DIR/bin/flatc
cp -r ../include/flatbuffers $TP_INCLUDE_DIR/flatbuffers
cp libflatbuffers.a $TP_LIB_DIR/libflatbuffers.a

restore_compile_flags
}

build_brotli() {
Expand Down
11 changes: 11 additions & 0 deletions thirdparty/download-thirdparty.sh
Original file line number Diff line number Diff line change
Expand Up @@ -545,6 +545,17 @@ if [[ -d $TP_SOURCE_DIR/$BITSHUFFLE_SOURCE ]] ; then
echo "Finished patching $BITSHUFFLE_SOURCE"
fi

# patch flatbuffers
if [[ -d $TP_SOURCE_DIR/$FLATBUFFERS_SOURCE ]] ; then
cd $TP_SOURCE_DIR/$FLATBUFFERS_SOURCE
if [ ! -f "$PATCHED_MARK" ] && [[ $FLATBUFFERS_SOURCE == "flatbuffers-1.10.0" ]] ; then
patch -p1 < "$TP_PATCH_DIR/flat-buffers-1.10.0-no-stringop-overread.patch"
touch "$PATCHED_MARK"
fi
cd -
echo "Finished patching $FLATBUFFERS_SOURCE"
fi

#patch clucene
if [[ -d $TP_SOURCE_DIR/$CLUCENE_SOURCE ]] ; then
cd $TP_SOURCE_DIR/$CLUCENE_SOURCE
Expand Down
15 changes: 15 additions & 0 deletions thirdparty/patches/flat-buffers-1.10.0-no-stringop-overread.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 76619dc..7603a72 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -139,6 +139,10 @@ elseif(CMAKE_COMPILER_IS_GNUCXX)
set(CMAKE_CXX_FLAGS
"${CMAKE_CXX_FLAGS} -faligned-new")
endif()
+ if (CMAKE_CXX_COMPILER_VERSION VERSION_GREATER 11.0)
+ # disable stringop-overread for gcc >= 11.0
+ set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-stringop-overread")
+ endif()
set(CMAKE_CXX_FLAGS
"${CMAKE_CXX_FLAGS} -Wunused-result -Werror=unused-result -Wunused-parameter -Werror=unused-parameter")
endif()

0 comments on commit db35d49

Please sign in to comment.