Hello. I am working on cross compilation using musl toolchains. I've failed to cross compile sys-devel/flex. Please see build log here https://gist.github.com/andrew-aladev/d16e4c39c2f7940b86d08fbccfecdb17.
The reason of this segfault was well defined by Florian Weimer in the following post. https://developers.redhat.com/blog/2019/04/22/implicit-function-declarations-flexs-use-of-reallocarray/
I've investigated this bug and found that it is not related to flex, it is related to autotools itself. Autotools just adds "#define malloc rpl_malloc" and "#define realloc rpl_realloc" into config. It looks like nobody knows why and nobody will fix it https://lists.gnu.org/archive/html/automake/2003-05/msg00017.html. Autotools are abandoned and broken by design.
This issue can be fixed properly by core flex developer only by moving from autotools to other build system. But we need some fix for now. I will attach my proposed workaround here.
Created attachment 603698 [details, diff]
rpl malloc and realloc declarations
thank you so much for the patch, it really saved the day!
if you want to, please try to push the patched ebuild to the overlay for the time being, thanks