Compiling collectd with CONFIG_SRC_TREE_OVERRIDE fails

I have the following symlink:

/workdir/openwrt/package/feeds/packages/collectd/git-src -> /workdir/custom-packages/collectd-nate/src/.git

and am running:
make -C openwrt package/collectd/{clean,compile} V=s

I get the following error:

/bin/bash ./libtool  --tag=CC   --mode=compile aarch64-openwrt-linux-musl-gcc -DHAVE_CONFIG_H -I. -I./src  -I./src -I./src/daemon -DPREFIX='"/usr"' -DCONFIGFILE='"/etc/collectd.conf"' -DLOCALSTATEDIR='"/var"' -DPKGLOCALSTATEDIR='"/var/lib/collectd"' -DPLUGINDIR='"/usr/lib/collectd"' -DPKGDATADIR='"/usr/share/collectd"'  -I/workdir/openwrt/staging_dir/toolchain-aarch64_cortex-a53_gcc-13.3.0_musl/usr/include -I/workdir/openwrt/staging_dir/toolchain-aarch64_cortex-a53_gcc-13.3.0_musl/include -I/workdir/openwrt/staging_dir/toolchain-aarch64_cortex-a53_gcc-13.3.0_musl/include/fortify    -Wall -I/workdir/openwrt/staging_dir/target-aarch64_cortex-a53_musl/usr/include -Os -pipe -mcpu=cortex-a53 -fno-caller-saves -fno-plt -fhonour-copts -fmacro-prefix-map=/workdir/openwrt/build_dir/target-aarch64_cortex-a53_musl/collectd-5.12.0=collectd-5.12.0 -flto=auto -fno-fat-lto-objects -Wformat -Werror=format-security -DPIC -fPIC -fstack-protector-strong -D_FORTIFY_SOURCE=2 -Wl,-z,now -Wl,-z,relro    -DPIC -fPIC -c -o src/netlink_la-netlink.lo `test -f 'src/netlink.c' || echo './'`src/netlink.c
OpenWrt-libtool: compile:  aarch64-openwrt-linux-musl-gcc -DHAVE_CONFIG_H -I. -I./src -I./src -I./src/daemon -DPREFIX=\"/usr\" -DCONFIGFILE=\"/etc/collectd.conf\" -DLOCALSTATEDIR=\"/var\" -DPKGLOCALSTATEDIR=\"/var/lib/collectd\" -DPLUGINDIR=\"/usr/lib/collectd\" -DPKGDATADIR=\"/usr/share/collectd\" -I/workdir/openwrt/staging_dir/toolchain-aarch64_cortex-a53_gcc-13.3.0_musl/usr/include -I/workdir/openwrt/staging_dir/toolchain-aarch64_cortex-a53_gcc-13.3.0_musl/include -I/workdir/openwrt/staging_dir/toolchain-aarch64_cortex-a53_gcc-13.3.0_musl/include/fortify -Wall -I/workdir/openwrt/staging_dir/target-aarch64_cortex-a53_musl/usr/include -Os -pipe -mcpu=cortex-a53 -fno-caller-saves -fno-plt -fhonour-copts -fmacro-prefix-map=/workdir/openwrt/build_dir/target-aarch64_cortex-a53_musl/collectd-5.12.0=collectd-5.12.0 -flto=auto -fno-fat-lto-objects -Wformat -Werror=format-security -DPIC -fPIC -fstack-protector-strong -D_FORTIFY_SOURCE=2 -Wl,-z,now -Wl,-z,relro -DPIC -fPIC -c src/netlink.c  -fPIC -DPIC -o src/.libs/netlink_la-netlink.o
src/netlink.c: In function 'check_ignorelist':
src/netlink.c:243:51: error: 'REG_NOERROR' undeclared (first use in this function)
  243 |       if (regexec(i->rdevice, dev, 0, NULL, 0) != REG_NOERROR)
      |                                                   ^~~~~~~~~~~
src/netlink.c:243:51: note: each undeclared identifier is reported only once for each function it appears in
make[4]: *** [Makefile:8294: src/netlink_la-netlink.lo] Error 1

I also had to modify the Makefile in feeds/feeds/packages/collectd/Makefile to remove iwinfo in COLLECTD_PLUGINS_SELECTED because it was failing to find iwinfo.so (I tried compiling that package too standalone but it didn’t help).

My Git HEAD is collectd-5.12.0which is the same version as the package in OpenWRT repo.

I realized that this is because patches aren’t applied.

collectd includes the following patch:

collectd/patches/920-backport-netlink-reg-noerror.patch 
4:Subject: [PATCH] src/netlink.c: remove REG_NOERROR 

but when I have this symlink: ln -s /workdir/custom-packages/collectd/.git feeds/packages/utils/collectd/git-src the patch isn't applied while building:

make package/collectd/{clean,compile} V=sc
...
src/netlink.c:243:51: error: 'REG_NOERROR' undeclared (first use in this function)
  243 |       if (regexec(i->rdevice, dev, 0, NULL, 0) != REG_NOERROR)
      |                                                   ^~~~~~~~~~~

How can I get patches to apply to the build when using git-src?

patches should go in a folder named as such in the root dir of the package... ie

/workdir/custom-packages/collectd/patches/920-backport-netlink-reg-noerror.patch

or apply them/it manually

git apply <path/of/patch>/<name-of-patch-file>.patch

1 Like