google / flatbuffers

FlatBuffers: Memory Efficient Serialization Library
https://flatbuffers.dev/
Apache License 2.0
23.17k stars 3.24k forks source link

Fix build on musl #8198

Open ibc opened 9 months ago

ibc commented 9 months ago

Build of applications using flatbuffers such as mediasoup (see related issue https://github.com/versatica/mediasoup/issues/1223) are broken on musl (such as in Alpine Linux) since version 1.11.0 and google@5f32f94 because strtoll_l (and strtoull_l) are not available on musl.

flatbuffers checks for the availability of strtoull_l in CMakeLists.txt so flatbuffers builds successfully, but for applications using flatbuffers the result of this check is not available and FLATBUFFERS_LOCALE_INDEPENDENT is set to 1 resulting in the following build failure:

In file included from ../../../subprojects/flatbuffers-23.3.3/include/flatbuffers/minireflect.h:21,
  from ../../../include/Channel/ChannelRequest.hpp:8,
  from ../../../include/Settings.hpp:6,
  from ../../../include/Logger.hpp:91,
  from ../../../src/RTC/RTCP/XrReceiverReferenceTime.cpp:5:
  ../../../subprojects/flatbuffers-23.3.3/include/flatbuffers/util.h: In function 'void flatbuffers::strtoval_impl(int64_t, const char*, char**, int)':
  ../../../subprojects/flatbuffers-23.3.3/include/flatbuffers/util.h:229:38: error: 'strtoll_l' was not declared in this scope; did you mean 'strtold_l'?
  229 | #define __strtoll_impl(s, pe, b) strtoll_l(s, pe, b, ClassicLocale::Get())
      |         ^~~~~~~~~~~~~~

This issue was reported in https://github.com/google/flatbuffers/pull/6773 but was closed without a solution. Then a flatbuffers fork made this exact commit: https://github.com/sartura/flatbuffers/commit/92bd62407329caacd66e92e5bfd2949f2f137bfe

Due to rationale given in the closed issue, I'm not sure this PR will be accepted. If not, I strongly think that flatbuffers documentation should say that applications using it in musl environments must define FLATBUFFERS_LOCALE_INDEPENDENT=0 in their main project.

google-cla[bot] commented 9 months ago

Thanks for your pull request! It looks like this may be your first contribution to a Google open source project. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA).

View this failed invocation of the CLA check for more information.

For the most up to date status, view the checks section at the bottom of the pull request.

github-actions[bot] commented 1 week ago

This pull request is stale because it has been open 6 months with no activity. Please comment or label not-stale, or this will be closed in 14 days.

ibc commented 1 week ago

not-stale

ibc commented 1 week ago

I've signed the Google Individual Contributor License Agreement.

ibc commented 1 week ago

@dbaileychess @aardappel (just mentioning some maintainers randomly), could you please approve CI workflows of this PR?