Error compiling perl/ext/Errno with prebuilt toolchain


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
Cannot find errno.h at Errno_pm.PL line 138.
make[4]: *** [Makefile:429:] 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 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 openwrt
cd openwrt
git pull
git fetch -t
git checkout v23.05.3

wget -O .config

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

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/ --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

tar xaf llvm-bpf-15.0.7.Linux-x86_64.tar.xz && rm llvm-bpf-15.0.7.Linux-x86_64.tar.xz

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:


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


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


So I fear that prebuilt toolchains are not correctly supported even when setup through the script scripts/