Hifive unleased SDK buildroot build errors

When trying to build the SDK for the Hifive unleased (as per the getting started guide the git master branch, currently at 54786842821b2bbe39385dd7361abb638a2c298f) the build fails during buildroot build. The following is a make attempt (after it already failed, but the error message are the same):

 % time make -j32                                                                       (master)* [14:44]
make -C /data/src/freedom-u-sdk/buildroot RISCV=/data/src/freedom-u-sdk/toolchain PATH=/data/src/freedom-u-sdk/toolchain/bin:/home/dullfire/bin:/usr/local/bin:/home/dullfire/bin:/usr/local/bin:/usr/x86_64-pc-linux-gnu/gcc-bin/7.3.0:/usr/x86_64-pc-linux-gnu/aarch64-linux-gnu/gcc-bin/4.9.4:/usr/x86_64-pc-linux-gnu/aarch64-oneplus-linux-musl/gcc-bin/6.4.0:/usr/x86_64-pc-linux-gnu/arm-hardfloat-linux-gnueabi/gcc-bin/7.3.0:/usr/x86_64-pc-linux-gnu/arm-linux-gnueabi/gcc-bin/4.9.4:/usr/x86_64-pc-linux-gnu/arm-none-eabi/gcc-bin/7.3.0:/usr/x86_64-pc-linux-gnu/riscv64-hifive-linux-gnu/gcc-bin/7.3.0:/usr/x86_64-pc-linux-gnu/x86_64-initrd-linux-musl/gcc-bin/7.3.0:/usr/lib/llvm/6/bin:/usr/local/bin:/usr/bin:/bin:/opt/bin:/usr/games/bin:/sbin:/usr/sbin:/usr/games/bin:/sbin:/usr/sbin:/usr/games/bin O=/data/src/freedom-u-sdk/work/buildroot_initramfs
make[1]: Entering directory '/data/src/freedom-u-sdk/buildroot'
>>> libtirpc 1.0.1 Building
PATH="/data/src/freedom-u-sdk/work/buildroot_initramfs/host/bin:/data/src/freedom-u-sdk/work/buildroot_initramfs/host/sbin:/data/src/freedom-u-sdk/work/buildroot_initramfs/host/usr/bin:/data/src/freedom-u-sdk/work/buildroot_initramfs/host/usr/sbin:/data/src/freedom-u-sdk/toolchain/bin:/home/dullfire/bin:/usr/local/bin:/home/dullfire/bin:/usr/local/bin:/usr/x86_64-pc-linux-gnu/gcc-bin/7.3.0:/usr/x86_64-pc-linux-gnu/aarch64-linux-gnu/gcc-bin/4.9.4:/usr/x86_64-pc-linux-gnu/aarch64-oneplus-linux-musl/gcc-bin/6.4.0:/usr/x86_64-pc-linux-gnu/arm-hardfloat-linux-gnueabi/gcc-bin/7.3.0:/usr/x86_64-pc-linux-gnu/arm-linux-gnueabi/gcc-bin/4.9.4:/usr/x86_64-pc-linux-gnu/arm-none-eabi/gcc-bin/7.3.0:/usr/x86_64-pc-linux-gnu/riscv64-hifive-linux-gnu/gcc-bin/7.3.0:/usr/x86_64-pc-linux-gnu/x86_64-initrd-linux-musl/gcc-bin/7.3.0:/usr/lib/llvm/6/bin:/usr/local/bin:/usr/bin:/bin:/opt/bin:/usr/games/bin:/sbin:/usr/sbin:/usr/games/bin:/sbin:/usr/sbin:/usr/games/bin"  /usr/bin/make   -C /data/src/freedom-u-sdk/work/buildroot_initramfs/build/libtirpc-1.0.1/
make[2]: Entering directory '/data/src/freedom-u-sdk/work/buildroot_initramfs/build/libtirpc-1.0.1'
cd rpcgen && /usr/bin/make
make[3]: Entering directory '/data/src/freedom-u-sdk/work/buildroot_initramfs/build/libtirpc-1.0.1/rpcgen'
  CC       rpc_clntout.o
  CC       rpc_parse.o
  CC       rpc_util.o
rpc_clntout.c:39:10: fatal error: rpc/types.h: No such file or directory
 #include <rpc/types.h>
compilation terminated.
make[3]: *** [Makefile:412: rpc_clntout.o] Error 1
make[3]: *** Waiting for unfinished jobs....
rpc_parse.c:39:10: fatal error: rpc/types.h: No such file or directory
 #include "rpc/types.h"
compilation terminated.
make[3]: *** [Makefile:412: rpc_parse.o] Error 1
make[3]: Leaving directory '/data/src/freedom-u-sdk/work/buildroot_initramfs/build/libtirpc-1.0.1/rpcgen'
make[2]: *** [Makefile:985: rpcgen/rpcgen] Error 2
make[2]: Leaving directory '/data/src/freedom-u-sdk/work/buildroot_initramfs/build/libtirpc-1.0.1'
make[1]: *** [package/pkg-generic.mk:198: /data/src/freedom-u-sdk/work/buildroot_initramfs/build/libtirpc-1.0.1/.stamp_built] Error 2
make[1]: Leaving directory '/data/src/freedom-u-sdk/buildroot'
make: *** [Makefile:90: /data/src/freedom-u-sdk/work/buildroot_initramfs/images/rootfs.tar] Error 2
make -j32  3.94s user 0.43s system 68% cpu 6.385 total

I have tried running the build without a job count specifier (’-j) however the result is the same. Any help would be much appreciated.
Additionally: is the master branch of the SDK repo supposed to be in a buildable state?

rpcgen is a utility built for the host machine. It looks like you are missing the file /usr/include/rpc/types.h. I would expect this to be part of the libc6-dev package, but if you did not have that package installed, you wouldn’t have gotten this far. The file /usr/include/stdio.h is part of the same package for instance. The exact package a file is in depends on what linux distro you are using, and what version. I have Ubuntu 18.04LTS. You may have a different OS on your machine. You will have to figure out what package the missing header file is in and install it.

The master branch should be buildable.

Thanks for pointing out it was a host package. I can’t believe I missed that :frowning: .
Yeah I’m using Gentoo, so Ubuntu packages wont really correlate lol.
I’ll see about getting that header.

So for people who also see this issue:
I found out it wasn’t really a lack of headers/packages on my system so much as the version of buildroot that the sdk uses is too old.
See http://buildroot-busybox.2317881.n4.nabble.com/Fixes-for-RPC-support-td34516.html
I was able to successfully get the full sdk to build (using the make format-boot-loader to install it to an sd card boots and works) by merging in the upstream buildroot tag 2018.05 (I did not check which tags would work, only that that was the lastest release tag). Obviously it was not a clean merge, and the SDK’s main repo had a ‘defconfig’ for the buildroot that needed updating. After that it seems to work fine. It would probably be good if the SDK’s buildroot repo is update/merged to work on newer systems (I don’t use Ubuntu systems so I have not tested it, but I think it’s likely 18.04 would see the same issue).

libtirpc is an optional replacement for glibc Sun rpc. Ubuntu 18.04 looks OK, it has glibc Sun rpc. Though I see in the glibc release notes that Sun rpc was deprecated in version 2.26, and is now only built if --enable-obsolete-rpc is enabled. Ubuntu glibc must be built with that configure flag, and gentoo glibc without it.