bpf-sys does not check the exit code of make command so that an
worse error occurs and users get in trouble to figure out a root cause.
make fails if libelf header files (libelf-dev or
elfutils-libelf-devel package) do not exist. However without the
checking of exit code, the build script of bpf-sys succeeds and
another error occurs while compiling bpf-sys:
error: could not find native static library bpf, perhaps an -L flag is missing?
error: could not compile bpf-sys due to previous error
With this error message, it is not easy to understand the root cause and
users can not come up with what they should do next.
So it is better to check the exit code of make and panic unless it
succeeds. This behavior produces more comprehensive error messages:
make: Entering directory '/home/esrse/opensource/redbpf/bpf-sys/libbpf/src'
MKDIR staticobjs
CC bpf.o
CC btf.o
make: Leaving directory '/home/esrse/opensource/redbpf/bpf-sys/libbpf/src'
--- stderr
btf.c:18:10: fatal error: gelf.h: No such file or directory
18 | #include
| ^~~~
compilation terminated.
make: *** [Makefile:113: /home/esrse/opensource/redbpf/target/debug/build/bpf-sys-adb9a2ddcc715ce3/out/libbpf/staticobjs/btf.o] Error 1
thread 'main' panicked at 'failed to build libbpf static library', bpf-sys/build.rs:56:9
bpf-sys
does not check the exit code ofmake
command so that an worse error occurs and users get in trouble to figure out a root cause.make
fails iflibelf
header files (libelf-dev or elfutils-libelf-devel package) do not exist. However without the checking of exit code, the build script ofbpf-sys
succeeds and another error occurs while compiling bpf-sys:With this error message, it is not easy to understand the root cause and users can not come up with what they should do next.
So it is better to check the exit code of
make
and panic unless it succeeds. This behavior produces more comprehensive error messages:Signed-off-by: Junyeong Jeong rhdxmr@gmail.com
This PR alleviates #177 problem case.