Various build problems on openwrt buildroot
Similar problems that I had with alpine as host os for building, are usually related to building on musl host. Also some strange issues have existed, on Arch I had trouble with multiple kernel modules to build, and on alpine I had one kernel module that did not build: kmod-ipt-coova
There are some strange problems on openwrt buildroot that happen on some build hosts, and others then do not have same issues on a same os at all, likely these issues are related on your build config and your host system config in symbiosis. This does and does not have anything to do with host using either musl or glibc, or whether it was ArchLinux, Alpine Linux - or even openwrt.
One of being that building of git required some extra love to succeed.. It is not related per-se to building openwrt-on-openwrt; it's something else, I had problem to build git-http-fetch on ArchLinux at one time too and it used glibc, not musl.
My fixes for git might not be perfect, but if someone needs it- it's available here: https://github.com/oskarirauta/local-overrides/tree/main/net/git
Problems and solutions during build
libc-stubs: package that I previously provided, needed one more stub for libresolv.a, I updated package.
libc-stubs package source is available at https://github.com/oskarirauta/packages2/tree/main/devel/libc-stubs
Edit: I also added libcrypt.a, libutil.a, libxnet.a and libm.a, that should cover all that were missing.
After these, both refpolicy and policycoreutils compile without issues.
buildroot-env: I provided another package that selects necessary depends to build openwrt on openwrt and adds required header files as well. Package uses also 2 other provided packages, libuargp and musl-obstack from same repository; needed missing packages. But for these to work properly, package is available only when CONFIG_NO_STRIP is enabled. One could also make a post-install script to it to build 4 packages in /tmp if CONFIG_NO_STRIP is not enabled, but I did not do that.
Package is available at here.
fail2ban:
fail2ban failed with 2to3, first because of it was missing from built hostpkgs, I then attempted to build it manually but failed for some reason, every time. So I removed fail2ban from my packages for now, and focused on building other stuff- since I don't include it as default to my system anyway; eventually 2to3 did build, but still, command 2to3 was missing; instead I had 2to3-3.10 where 3.10 stands for used python version. So I made a symlink from 2to3-3.10 to 2to3 just to find out that I failed again due to some missing python stuff. Then I installed 2to3 on building host, it does not include 2to3 command, but that didn't matter, it included everything required to run 2to3 symlink, I restarted fail2ban build and it succeeded.
libxcrypt, needs more perl modules on host: perlbase-open, perlbase-if
backuppc needs perl module: perlbase-digest
mosh requires perl module perlbase-diagnostics - but it isn't enough, as it wants also file
/usr/lib/perl5/5.28/pod/perldiag.pod which isn't included in package; but if you have built perl,
you can find it in your build directory and copy from there.. After this mosh build succeeds.
privoxy required user privoxy(uid 8118) and group privoxy(gid 8118) adding to system to be able to build.
boinc failed to build, configure thought that libcurl is unusable, fix it by adding this to CONFIGURE_ARGS: _libcurl_try_link=no
and libcurl_cv_lib_curl_usable=yes
libv4l failed to build, it wanted to link with libargp, but it wasn't available as dynamic library, so I statically linked it. Check this Makefile if necessary. libv4l must be compiled before mjpg-streamer.
pdns once again is one of packages that have a issue with curl-config; configure thinks curl is un-usable. Adding libcurl_cv_lib_curl_usable=yes
to configure args, fixes this. Seems to be pretty common problem with many applications linking to libcurl. https://github.com/oskarirauta/local-overrides/blob/main/net/pdns/Makefile
shorewall needs more perl modules: perlbase-autouse, perlbase-sys and perlbase-sort
yubiko-pam needed additional configure argument ac_cv_libykclient=yes
Some packages needed updating and minor fixes, I made PRs on those packages and they were merged to mainstream, list of updated packages is here: nfs-kernel-server, libtirc, open-vm-tools.
won't-fix - or what I didn't/couldn't fix.
- cjdns: failed, first to missing cflag and then to error of missing .a on it's own files. I didn't fix it.
- ruby: won't build, configure had issue with cflags validity, I made a patch that overrided it, then build failed. Hopefully someone else will take a look at this.
- avahi-compat + shairplay: avahi-compat is needed by shairplay. avahi-compat does not want to build. Not related to musl/openwrt-on-openwrt - issue exists on ArchLinux and Alpine as well.
- frr failed to build. Though it propably has nothing to do with building on openwrt. It does not link vty.o to libfrr.so which leaves undefined reference, build system is that complicated that I skipped it for the moment. Should propably check if there's update available that would fix it..
- lxc refused to build with complex errors
- vallumd, look next chapter
- schroot: linking error, possibly not related to building on openwrt-on-openwrt, same issue was with alpine linux, possibly musl related?
- sing-box failed to build, errors in build process
I recommend all perl modules that I get listed as missing, will be added as requirements to avoid surprises mid build.
ATTENTION - WARNING
While building, I constantly arrived point where my host lost it's network connection and became unresponsive, I first thought that this is because of cpu overheating, or filesystem error or something, but finally I found out the cause.
This occurred every time when build system attempted build vallumd - for unknown reason, as it begun perfectly normally, but soon init restarted and I got choice to press F for safemode etc and only thing system responded was using keyboard and pressing ctrl+alt+del.
I tested this several times, even by trying to compile vallumd as a single package and yet it happened again every time without process having enough time to print to screen what the issue could be.
Finally I gave up on vallumd, after all, I haven't ever even tested it or really know what it is and what it can be archieved with it- I disabled it in my config and used ./scripts/feeds uninstall vallumd
to avoid it's build in future.
If your system hangs during build, check if you have tried to build vallumd.
Some details on my build configuration
My build is near full feature build, meaning that most optional features are enabled, if SSL is used, always choose openssl; and with full language support(iconv). My build is also unstripped, which grows binary size substantially while retaining possibility to link to shared libraries when building natively.
My local-overrides repository mostly contains fixes regarding iconv issues + other stuff, like changes enabling musl-host compilation. It's private while publicly available, so I am resposible over it's being up-to-date for only myself.
Build progress
My attempt to build openwrt-on-openwrt has finished with about 99% of packages in default repositories. Including succesful build of all kernel modules.
Build statistics
root@media:/usr/src/openwrt# pkgcount
3.3G total
6114 packages / 6153 files
root@media:/usr/src# df -h
Filesystem Size Used Available Use% Mounted on
/dev/root 977.3M 471.4M 438.5M 52% /
devtmpfs 512.0K 0 512.0K 0% /dev
tmpfs 7.8G 712.0K 7.8G 0% /tmp
tmpfs 512.0K 0 512.0K 0% /dev
/dev/sda2 64.9M 25.9M 39.0M 40% /boot
/dev/sda9 198.6G 120.4G 68.1G 64% /usr/src
Build tree's total size is around 120gb, I have about 500mb of stuff like npm cache, etc that is on /usr/src but not in /usr/src/openwrt. I have completely excluded repositories telephony and video.
Openwrt can very well be built on openwrt. To build all this, including setting up environment; it took 3 days. If someone else attempts it with similar hardware effieciency, and uses tips I gave, skips vallumd attempts after failing the first time and accepts my patches, propably it will be complete way faster.
I also built rust toolchain and few packages for it succesfully; repository is here - main rust Makefile has some commented out parts which need to be un-commented in case your build host and target are not the same.
Note
Since I use unstripped in my config to be able to use shared libraries when compiling natively, my build grew fast, so, I decided to strip some packages, so on most of my packages, binary stripping is used if no stripping is selected, for executables. It is ignored, if stripping in general is enabled. Stripping is most effective on huge go binaries.
Final thoughts
I cannot say, do I recommend this or not- but I can verify, that it isn't the foolest choice either.
Personally I have no regrets on walking through this, and very likely, I am going to use my current build tree for some time, after fixing some issues, I am quite happy on openwrt that was built on openwrt.