Error compiling perl/ext/Errno with prebuilt toolchain

Hello,

I'm trying to re-build OpenWrt 23.05.3 (using prebuilt toolchain) to add some kernel configs related to multipath TCP.
I can build the kernel, but the build of userspace packages fails on a perl extension, which is not able to find errno.h include file:

make[4]: Entering directory '/home/debian/openwrt2/build_dir/target-aarch64-openwrt-linux-musl_musl/perl/perl-5.28.1/ext/Errno'
"../../../../../../staging_dir/hostpkg/usr/bin/perl" "-I../../lib" Errno_pm.PL Errno.pm
Cannot find errno.h at Errno_pm.PL line 138.
make[4]: *** [Makefile:429: Errno.pm] Error 2
make[4]: Leaving directory '/home/debian/openwrt2/build_dir/target-aarch64-openwrt-linux-musl_musl/perl/perl-5.28.1/ext/Errno'
Unsuccessful make(ext/Errno): code=512 at make_ext.pl line 570.
make[3]: *** [makefile:585: ext/Errno/pm_to_blib] Error 2

Anyone has ever faced this problem ? I think it's due to the use of prebuilt toolchain, as this did not happen in my previous (slow) builds without prebuilt toolchain. Looks like the perl extension is not searching for errno.h in the correct paths.

These are my build steps:

rm -rf openwrt
git clone https://git.openwrt.org/openwrt/openwrt.git openwrt
cd openwrt
git pull
git fetch -t
git checkout v23.05.3

wget https://downloads.openwrt.org/releases/23.05.3/targets/armsr/armv8/config.buildinfo -O .config

./scripts/feeds update -a
./scripts/feeds install -a

wget https://downloads.openwrt.org/releases/23.05.3/targets/armsr/armv8/openwrt-toolchain-23.05.3-armsr-armv8_gcc-12.3.0_musl.Linux-x86_64.tar.xz
tar xaf openwrt-toolchain-23.05.3-armsr-armv8_gcc-12.3.0_musl.Linux-x86_64.tar.xz && rm openwrt-toolchain-23.05.3-armsr-armv8_gcc-12.3.0_musl.Linux-x86_64.tar.xz
./scripts/ext-toolchain.sh --toolchain ./openwrt-toolchain-23.05.3-armsr-armv8_gcc-12.3.0_musl.Linux-x86_64/toolchain-aarch64_generic_gcc-12.3.0_musl/ --overwrite-config --config armsr/armv8

wget https://downloads.openwrt.org/releases/23.05.3/targets/armsr/armv8/llvm-bpf-15.0.7.Linux-x86_64.tar.xz
tar xaf llvm-bpf-15.0.7.Linux-x86_64.tar.xz && rm llvm-bpf-15.0.7.Linux-x86_64.tar.xz

# https://github.com/openwrt/packages/issues/23621
sed -i -e 's/CONFIG_PACKAGE_kmod-pf-ring=m/CONFIG_PACKAGE_kmod-pf-ring=n/' .config

make defconfig

make menuconfig
#     1) Disable "Build the LLVM-BPF toolchain tarball (NEW)"
#     2) "Advanced configuration options (for developers)" -> "BPF Toolchain" = "Use Prebuild LLVM Toolchain"

make tools/install
make toolchain/install

echo "CONFIG_MPTCP=y" >> target/linux/armsr/config-5.15
echo "CONFIG_INET_MPTCP_DIAG=y" >> target/linux/armsr/config-5.15
echo "CONFIG_MPTCP_IPV6=y" >> target/linux/armsr/config-5.15

make download

make -j$(nproc) target/linux/{clean,compile} V=s
# kernel correctly built

make -j$(nproc) world V=s
# error on perl extension Errno

I see that perl package is configured with this sysroot, pointing to staging_dir:

build_dir/target-aarch64-openwrt-linux-musl_musl/perl/perl-5.28.1/config.sh:sysroot='/home/debian/openwrt2/staging_dir/toolchain-aarch64-openwrt-linux-musl'

this comes from package/feeds/packages/perl/Makefile:

...
-Dsysroot='$(TOOLCHAIN_DIR)' 
...

However TOOLCHAIN_DIR value is not consistent with the variable CONFIG_TOOLCHAIN_ROOT in .config, which points to where the prebuilt toolchain was unzipped:

CONFIG_TOOLCHAIN_ROOT="/home/debian/openwrt2/openwrt-toolchain-23.05.3-armsr-armv8_gcc-12.3.0_musl.Linux-x86_64/toolchain-aarch64_generic_gcc-12.3.0_musl"

So I fear that prebuilt toolchains are not correctly supported even when setup through the script scripts/ext-toolchain.sh