cilium: "'stddef.h' file not found" in dev. VM
Issue
Trying to run the unit tests from inside the dev. VM results in the following error:
In file included from unit-test.c:8:
/usr/include/stdlib.h:31:10: fatal error: 'stddef.h' file not found
#include <stddef.h>
That error is happening because we recently switched the compiler for the BPF unit tests to Clang. The dev. VM images (4.9 and net-next) don’t include a full Clang, but only the strict minimum required to compile BPF programs.
Workaround
The following steps, proposed by André for a similar issue on v1.7, work as a quick fix:
sudo mv /usr/bin/clang{,.bak}
sudo mv /usr/bin/llc{,.bak}
sudo apt-get install -y clang-7 llvm-7
sudo update-alternatives --install /usr/bin/clang clang /usr/lib/llvm-7/bin/clang 1000
sudo update-alternatives --install /usr/bin/llc llc /usr/lib/llvm-7/bin/llc 1000
To revert:
sudo mv /usr/bin/clang{.bak,}
sudo mv /usr/bin/llc{.bak,}
Proper Fix
The proper fix requires to revert part of cilium/packer-ci-build#200, to be able to compile on x86 with Clang.
Reported-by: Nate Sweet nathanjsweet@pm.me
About this issue
- Original URL
- State: closed
- Created 4 years ago
- Comments: 27 (27 by maintainers)
Commits related to this issue
- bpf: fix test/bpf/unit-test segfault due to memcmp looping Jarno and Paul reported a segfault in the memcmp() test case for older clang: test/bpf/unit-test Makefile:216: recipe for target 'unit-... — committed to cilium/cilium by borkmann 4 years ago
- bpf: fix test/bpf/unit-test segfault due to memcmp looping Jarno and Paul reported a segfault in the memcmp() test case for older clang: test/bpf/unit-test Makefile:216: recipe for target 'unit-... — committed to cilium/cilium by borkmann 4 years ago
- vagrant: bump all vagrant box versions These include a fix for #11255. Fixes: #11255 Signed-off-by: Paul Chaignon <paul@cilium.io> — committed to cilium/cilium by pchaigno 4 years ago
- vagrant: bump all vagrant box versions These include a fix for #11255. Fixes: #11255 Signed-off-by: Paul Chaignon <paul@cilium.io> — committed to cilium/cilium by pchaigno 4 years ago
- provision: Install headers required for Clang We need these header files to compile the BPF unit tests inside the development VMs. Related: https://github.com/cilium/cilium/issues/11255 Fixes: 1717c... — committed to cilium/packer-ci-build by pchaigno 4 years ago
- provision: Install headers required for Clang We need these header files to compile the BPF unit tests inside the development VMs. Related: https://github.com/cilium/cilium/issues/11255 Fixes: 1717c... — committed to cilium/packer-ci-build by pchaigno 4 years ago
- provision: Install headers required for Clang We need these header files to compile the BPF unit tests inside the development VMs. Related: https://github.com/cilium/cilium/issues/11255 Fixes: 1717c... — committed to cilium/packer-ci-build by pchaigno 4 years ago
The fix for this is currently blocked by https://github.com/cilium/packer-ci-build/issues/230. I’ll try to update the 4.9 and 4.19 VM images to unblock at least these.
Got it, just reproduced locally, will look into it.
Using the precompiled clang-10 version “fixes” the segfault. Not sure what is happening here. I’ll try to send the PR to update the VM image today.