Perl string functions broken in some OpenWrt musl builds

A bug in musl and/or perl (where the bug is is a matter of debate) is causing an issue in some OpenWrt builds. In affected builds, the perl string search functions, like index(), are broken.

For example:

#!/usr/bin/perl

my $string1 .= "abcabc";
my $string2 .= $string1;

printf "string1='%s', string2='%s', index=%s\n", $string1, $string2, index($string1, $string2);

On affected builds, you will see index=-<largenum>. On non-affected builds, you will see index=0.

This issue seems to affect all aarch64 builds. It doesn't seem to affect 32 bit arm builds, which probably means there are more overall devices not affected. I don't yet know if it affects mips or x86.
I suspect likely no on the former and yes on the latter.

The issue can be worked around by defining _GNU_SOURCE when perl is built (requires patching OpenWrt). The problem was already corrected by the perl devs for perl >= 5.30, so the issue will go away if we get a new version of perl.

There aren't a whole lot of perl programs that use index() or related functions. But those that do will fail or bug in odd ways.

It looks like the fix has been backported to perl 5.28(.3).