Fix gcc14 build error on FLATBUFFER
authorChunseok Lee <chunseok.lee@samsung.com>
Mon, 10 Jun 2024 06:01:36 +0000 (15:01 +0900)
committerChunseok Lee <chunseok.lee@samsung.com>
Mon, 10 Jun 2024 06:09:38 +0000 (15:09 +0900)
Signed-off-by: Chunseok Lee <chunseok.lee@samsung.com>
packaging/nnfw.spec
packaging/remove_const.patch [new file with mode: 0644]

index 522d777..3d12895 100644 (file)
@@ -30,6 +30,7 @@ Source3017: VULKAN.tar.gz
 Source3018: XNNPACK.tar.gz
 Source3019: FLATBUFFERS-2.0.tar.gz
 Source3020: NEON2SSE.tar.gz
+Source3021: remove_const.patch
 
 %{!?build_type:     %define build_type      Release}
 %{!?npud_build:     %define npud_build      1}
@@ -214,6 +215,10 @@ tar -xf %{SOURCE3017} -C ./externals
 tar -xf %{SOURCE3018} -C ./externals
 tar -xf %{SOURCE3019} -C ./externals
 tar -xf %{SOURCE3020} -C ./externals
+cp  -xf %{SOURCE3021} ./externals
+cd externals/FLATBUFFERS-2.0
+pwd
+patch -p1 < ../remove_const.patch
 
 %build
 %ifarch arm armv7l armv7hl aarch64 x86_64 %ix86 riscv64
diff --git a/packaging/remove_const.patch b/packaging/remove_const.patch
new file mode 100644 (file)
index 0000000..93b43dd
--- /dev/null
@@ -0,0 +1,37 @@
+--- a/include/flatbuffers/stl_emulation.h
++++ b/include/flatbuffers/stl_emulation.h
+@@ -45,14 +45,18 @@
+   #endif
+ #endif // defined(FLATBUFFERS_USE_STD_OPTIONAL) ...
+-// The __cpp_lib_span is the predefined feature macro.
+-#if defined(FLATBUFFERS_USE_STD_SPAN)
+-    #include <span>
+-#elif defined(__cpp_lib_span) && defined(__has_include)
+-  #if __has_include(<span>)
+-    #include <span>
+-    #define FLATBUFFERS_USE_STD_SPAN
++#ifndef FLATBUFFERS_USE_STD_SPAN
++  // Testing __cpp_lib_span requires including either <version> or <span>,
++  // both of which were added in C++20.
++  // See: https://en.cppreference.com/w/cpp/utility/feature_test
++  #if defined(__cplusplus) && __cplusplus >= 202002L
++    #define FLATBUFFERS_USE_STD_SPAN 1
+   #endif
++#endif // FLATBUFFERS_USE_STD_SPAN
++
++#if defined(FLATBUFFERS_USE_STD_SPAN)
++  #include <array>
++  #include <span>
+ #else
+   // Disable non-trivial ctors if FLATBUFFERS_SPAN_MINIMAL defined.
+   #if !defined(FLATBUFFERS_TEMPLATES_ALIASES) || defined(FLATBUFFERS_CPP98_STL)
+@@ -625,7 +629,7 @@
+  private:
+   // This is a naive implementation with 'count_' member even if (Extent != dynamic_extent).
+   pointer const data_;
+-  const size_type count_;
++  size_type count_;
+ };
+  #if !defined(FLATBUFFERS_SPAN_MINIMAL)