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

Most upvoted comments

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.

Afaik, for __builtin_memcmp() the compiler could still decide to make a call to glibc’s memcmp(), for example.

Here it’s calling our memcmp() implementation, hence the loop.

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.