0001-include-flatbuffers-base.h-fix-build-on-musl.patch 2.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. From 0315cef04a5a8a953072691faa48af9acb6009bd Mon Sep 17 00:00:00 2001
  2. From: Fabrice Fontaine <fontaine.fabrice@gmail.com>
  3. Date: Tue, 10 Aug 2021 13:39:58 +0200
  4. Subject: [PATCH] include/flatbuffers/base.h: fix build on musl
  5. Build of applications using flatbuffers such as snort3 are broken on
  6. musl since version 1.11.0 and
  7. https://github.com/google/flatbuffers/commit/5f32f948102e65eaeea461b44f3b43f96c7a7a5a
  8. because strtoll_l (and strtoull_l) are not available on musl.
  9. flatbuffers checks for the availability of strtoull_l in CMakeLists.txt
  10. so flatbuffers builds successfully but for applications using
  11. flatbuffers, the result of this check is not available and
  12. FLATBUFFERS_LOCALE_INDEPENDENT is set to 1 resulting in the following
  13. build failure:
  14. In file included from /tmp/instance-0/output-1/host/x86_64-buildroot-linux-musl/sysroot/usr/include/flatbuffers/flexbuffers.h:24,
  15. from /tmp/instance-0/output-1/host/x86_64-buildroot-linux-musl/sysroot/usr/include/flatbuffers/idl.h:26,
  16. from /tmp/instance-0/output-1/build/snort3-3.1.6.0/src/network_inspectors/perf_monitor/fbs_formatter.cc:29:
  17. /tmp/instance-0/output-1/host/x86_64-buildroot-linux-musl/sysroot/usr/include/flatbuffers/util.h: In function 'void flatbuffers::strtoval_impl(int64_t*, const char*, char**, int)':
  18. /tmp/instance-0/output-1/host/x86_64-buildroot-linux-musl/sysroot/usr/include/flatbuffers/util.h:258:12: error: 'strtoll_l' was not declared in this scope; did you mean 'strcoll_l'?
  19. 258 | *val = __strtoll_impl(str, endptr, base);
  20. | ^~~~~~~~~~~~~~
  21. Fix this failure by checking if __GNUC__ is defined before setting
  22. FLATBUFFERS_LOCALE_INDEPENDENT to 1.
  23. Fixes:
  24. - http://autobuild.buildroot.org/results/68045b83e94f8caa337b1af7ed5f493ac1a55c47
  25. Signed-off-by: Fabrice Fontaine <fontaine.fabrice@gmail.com>
  26. [Upstream status: Rejected:
  27. https://github.com/google/flatbuffers/pull/6773]
  28. Signed-off-by: Bernd Kuhls <bernd.kuhls@t-online.de>
  29. (rebased and added fix for uClibc-build)
  30. ---
  31. include/flatbuffers/base.h | 2 +-
  32. 1 file changed, 1 insertion(+), 1 deletion(-)
  33. diff --git a/include/flatbuffers/base.h b/include/flatbuffers/base.h
  34. index de7898dc..101c7598 100644
  35. --- a/include/flatbuffers/base.h
  36. +++ b/include/flatbuffers/base.h
  37. @@ -264,7 +264,8 @@ namespace flatbuffers {
  38. // strtoull_l}.
  39. #if (defined(_MSC_VER) && _MSC_VER >= 1800) || \
  40. (defined(__ANDROID_API__) && __ANDROID_API__>= 21) || \
  41. - (defined(_XOPEN_VERSION) && (_XOPEN_VERSION >= 700)) && \
  42. + (defined(_XOPEN_VERSION) && (_XOPEN_VERSION >= 700) && \
  43. + defined(__GLIBC__) && !defined(__UCLIBC__)) && \
  44. (!defined(__Fuchsia__) && !defined(__ANDROID_API__))
  45. #define FLATBUFFERS_LOCALE_INDEPENDENT 1
  46. #else
  47. --
  48. 2.30.2