From d609c9fbec254fccd179f5214b112bba93be8dbf Mon Sep 17 00:00:00 2001 From: Phoebe Chen Date: Sun, 28 Jan 2024 05:49:21 -0800 Subject: [PATCH] Fix Flatbuffer build issue. Building on g++ 13.2.0 results in -Wstringop-overread errors. This PR addresses the flatbuffer build issue with the following changes: 1. Remove Werror flag in flarbuffer patch. 2. Add a compilation option to suppress the 'stringop-overflow' error in the Flatbuffers within the xnnpack provider. Signed-off-by: Phoebe Chen --- cmake/onnxruntime_providers_xnnpack.cmake | 3 +++ cmake/patches/flatbuffers/flatbuffers.patch | 2 +- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/cmake/onnxruntime_providers_xnnpack.cmake b/cmake/onnxruntime_providers_xnnpack.cmake index 9c00703ca0846..1b04639965852 100644 --- a/cmake/onnxruntime_providers_xnnpack.cmake +++ b/cmake/onnxruntime_providers_xnnpack.cmake @@ -19,6 +19,9 @@ flatbuffers::flatbuffers Boost::mp11 safeint_interface ) + # Add compile option to suppress stringop-overflow error in Flatbuffers. + target_compile_options(onnxruntime_providers_xnnpack PRIVATE -Wno-error=stringop-overflow) + add_dependencies(onnxruntime_providers_xnnpack onnx ${onnxruntime_EXTERNAL_DEPENDENCIES}) set_target_properties(onnxruntime_providers_xnnpack PROPERTIES FOLDER "ONNXRuntime") diff --git a/cmake/patches/flatbuffers/flatbuffers.patch b/cmake/patches/flatbuffers/flatbuffers.patch index fb2678ef1bdce..f141d358c54b6 100644 --- a/cmake/patches/flatbuffers/flatbuffers.patch +++ b/cmake/patches/flatbuffers/flatbuffers.patch @@ -7,7 +7,7 @@ index 3987eac9..5e5462f1 100644 endif(CYGWIN) set(CMAKE_CXX_FLAGS - "${CMAKE_CXX_FLAGS} -Wall -pedantic -Werror -Wextra -Werror=shadow") -+ "${CMAKE_CXX_FLAGS} -Wall -pedantic -Werror -Wextra -Werror=shadow -Wno-error=stringop-overflow") ++ "${CMAKE_CXX_FLAGS} -Wall -pedantic -Wextra -Werror=shadow -Wno-error=stringop-overflow") set(FLATBUFFERS_PRIVATE_CXX_FLAGS "-Wold-style-cast") if (CMAKE_CXX_COMPILER_VERSION VERSION_GREATER 4.4) if (CMAKE_CXX_COMPILER_VERSION VERSION_GREATER 7.0)