integration-test: avoid reliance on kernel headers

This should allow us to build on any system.
pull/727/head
Tamir Duberstein 1 year ago
parent b46fb616be
commit 71bc3ea0b5
No known key found for this signature in database

@ -1,5 +1,5 @@
// clang-format off
#include <linux/bpf.h>
#include <vmlinux.h>
#include <bpf/bpf_helpers.h>
// clang-format on

@ -1,5 +1,5 @@
// clang-format off
#include <linux/bpf.h>
#include <vmlinux.h>
#include <bpf/bpf_helpers.h>
// clang-format on

@ -1,5 +1,5 @@
// clang-format off
#include <linux/bpf.h>
#include <vmlinux.h>
#include <bpf/bpf_helpers.h>
// clang-format on

@ -1,5 +1,5 @@
// clang-format off
#include <linux/bpf.h>
#include <vmlinux.h>
#include <bpf/bpf_helpers.h>
#include <bpf/bpf_core_read.h>
// clang-format on

@ -1,5 +1,5 @@
// clang-format off
#include <linux/bpf.h>
#include <vmlinux.h>
#include <bpf/bpf_helpers.h>
#include <bpf/bpf_core_read.h>
// clang-format on

@ -1,5 +1,5 @@
// clang-format off
#include <linux/bpf.h>
#include <vmlinux.h>
#include <bpf/bpf_helpers.h>
// clang-format on

@ -116,10 +116,22 @@ fn main() {
target_arch.push(arch);
};
// NB: libbpf's documentation suggests that vmlinux.h be generated by running `bpftool btf
// dump file /sys/kernel/btf/vmlinux format c`; this allows CO-RE to work.
//
// However in our tests we do not make use of kernel data structures, and so any vmlinux.h
// which defines the constants we need (e.g. `__u8`, `__u64`, `BPF_MAP_TYPE_ARRAY`,
// `BPF_ANY`, `XDP_PASS`, `XDP_DROP`, etc.) will suffice. Since we already have a libbpf
// submodule which happens to include such a file, we use it.
let libbpf_vmlinux_dir = libbpf_dir.join(".github/actions/build-selftests");
let clang = || {
let mut cmd = Command::new("clang");
cmd.arg("-I")
cmd.arg("-nostdlibinc")
.arg("-I")
.arg(&libbpf_headers_dir)
.arg("-I")
.arg(&libbpf_vmlinux_dir)
.args(["-g", "-O2", "-target", target, "-c"])
.arg(&target_arch);
cmd

Loading…
Cancel
Save