1*4882a593SmuzhiyunFrom 0315cef04a5a8a953072691faa48af9acb6009bd Mon Sep 17 00:00:00 2001 2*4882a593SmuzhiyunFrom: Fabrice Fontaine <fontaine.fabrice@gmail.com> 3*4882a593SmuzhiyunDate: Tue, 10 Aug 2021 13:39:58 +0200 4*4882a593SmuzhiyunSubject: [PATCH] include/flatbuffers/base.h: fix build on musl 5*4882a593Smuzhiyun 6*4882a593SmuzhiyunBuild of applications using flatbuffers such as snort3 are broken on 7*4882a593Smuzhiyunmusl since version 1.11.0 and 8*4882a593Smuzhiyunhttps://github.com/google/flatbuffers/commit/5f32f948102e65eaeea461b44f3b43f96c7a7a5a 9*4882a593Smuzhiyunbecause strtoll_l (and strtoull_l) are not available on musl. 10*4882a593Smuzhiyunflatbuffers checks for the availability of strtoull_l in CMakeLists.txt 11*4882a593Smuzhiyunso flatbuffers builds successfully but for applications using 12*4882a593Smuzhiyunflatbuffers, the result of this check is not available and 13*4882a593SmuzhiyunFLATBUFFERS_LOCALE_INDEPENDENT is set to 1 resulting in the following 14*4882a593Smuzhiyunbuild failure: 15*4882a593Smuzhiyun 16*4882a593SmuzhiyunIn file included from /tmp/instance-0/output-1/host/x86_64-buildroot-linux-musl/sysroot/usr/include/flatbuffers/flexbuffers.h:24, 17*4882a593Smuzhiyun from /tmp/instance-0/output-1/host/x86_64-buildroot-linux-musl/sysroot/usr/include/flatbuffers/idl.h:26, 18*4882a593Smuzhiyun from /tmp/instance-0/output-1/build/snort3-3.1.6.0/src/network_inspectors/perf_monitor/fbs_formatter.cc:29: 19*4882a593Smuzhiyun/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)': 20*4882a593Smuzhiyun/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'? 21*4882a593Smuzhiyun 258 | *val = __strtoll_impl(str, endptr, base); 22*4882a593Smuzhiyun | ^~~~~~~~~~~~~~ 23*4882a593Smuzhiyun 24*4882a593SmuzhiyunFix this failure by checking if __GNUC__ is defined before setting 25*4882a593SmuzhiyunFLATBUFFERS_LOCALE_INDEPENDENT to 1. 26*4882a593Smuzhiyun 27*4882a593SmuzhiyunFixes: 28*4882a593Smuzhiyun - http://autobuild.buildroot.org/results/68045b83e94f8caa337b1af7ed5f493ac1a55c47 29*4882a593Smuzhiyun 30*4882a593SmuzhiyunSigned-off-by: Fabrice Fontaine <fontaine.fabrice@gmail.com> 31*4882a593Smuzhiyun[Upstream status: https://github.com/google/flatbuffers/pull/6773] 32*4882a593Smuzhiyun--- 33*4882a593Smuzhiyun include/flatbuffers/base.h | 2 +- 34*4882a593Smuzhiyun 1 file changed, 1 insertion(+), 1 deletion(-) 35*4882a593Smuzhiyun 36*4882a593Smuzhiyundiff --git a/include/flatbuffers/base.h b/include/flatbuffers/base.h 37*4882a593Smuzhiyunindex de7898dc..101c7598 100644 38*4882a593Smuzhiyun--- a/include/flatbuffers/base.h 39*4882a593Smuzhiyun+++ b/include/flatbuffers/base.h 40*4882a593Smuzhiyun@@ -266,7 +266,7 @@ namespace flatbuffers { 41*4882a593Smuzhiyun #ifndef FLATBUFFERS_LOCALE_INDEPENDENT 42*4882a593Smuzhiyun // Enable locale independent functions {strtof_l, strtod_l,strtoll_l, strtoull_l}. 43*4882a593Smuzhiyun #if ((defined(_MSC_VER) && _MSC_VER >= 1800) || \ 44*4882a593Smuzhiyun- (defined(_XOPEN_VERSION) && (_XOPEN_VERSION>=700)) && (!defined(__ANDROID_API__) || (defined(__ANDROID_API__) && (__ANDROID_API__>=21)))) 45*4882a593Smuzhiyun+ (defined(__GLIBC__) && defined(_XOPEN_VERSION) && (_XOPEN_VERSION>=700)) && (!defined(__ANDROID_API__) || (defined(__ANDROID_API__) && (__ANDROID_API__>=21)))) 46*4882a593Smuzhiyun #define FLATBUFFERS_LOCALE_INDEPENDENT 1 47*4882a593Smuzhiyun #else 48*4882a593Smuzhiyun #define FLATBUFFERS_LOCALE_INDEPENDENT 0 49*4882a593Smuzhiyun-- 50*4882a593Smuzhiyun2.30.2 51*4882a593Smuzhiyun 52