Skip to content

[net_watcher] 编译错误 #993

@houlifei328

Description

@houlifei328

readme文档只有示例unbunt系统的编译方法,我是centos8系统,内核版本:4.18.0-553.6.1.el8.x86_64
相关组件版本
clang -v
clang version 17.0.6 (Red Hat 17.0.6-1.module_el8+767+9fa966b8)
gcc -v
gcc 版本 8.5.0 20210514 (Red Hat 8.5.0-22) (GCC)
gcc -m32 -v
gcc 版本 8.5.0 20210514 (Red Hat 8.5.0-22) (GCC)
gcc -m64 -v
gcc 版本 8.5.0 20210514 (Red Hat 8.5.0-22) (GCC)

编译目录:
lmp/eBPF_Supermarket/Network_Subsystem/net_watcher

修改点:
我修改了Makefile。只修改了依赖包,不让他窒息apt install -y gcc-multilib g++-multilib
check_multilib:
#@if [ ! -f /usr/include/x86_64-linux-gnu/gnu/stubs-32.h ]; then
@if [ ! -f /usr/include/gnu/stubs-32.h ]; then
echo "multilib 未安装,正在安装...";
sudo apt-get update;
sudo apt-get install -y gcc-multilib g++-multilib;
else
echo "multilib 已经安装";
fi
我手动安装了yum install glibc-devel.i686 libstdc++-devel.i686

报错:
然后make执行报错如下:
In file included from netwatcher.bpf.c:25:
./tcp.bpf.h:27:5: error: invalid application of 'typeof' to bit-field
27 | CONN_INIT // 初始化conn_t结构中基本信息
| ^
./common.bpf.h:424:20: note: expanded from macro 'CONN_INIT'
424 | u16 protocol = BPF_CORE_READ(sk, sk_protocol);
| ^
.output/bpf/bpf_core_read.h:520:2: note: expanded from macro 'BPF_CORE_READ'
520 | ___type((src), a, ##VA_ARGS) __r;
| ^
.output/bpf/bpf_core_read.h:391:28: note: expanded from macro '___type'
391 | #define ___type(...) typeof(___arrow(VA_ARGS))
| ^
In file included from netwatcher.bpf.c:25:
./tcp.bpf.h:27:5: error: address of bit-field requested
27 | CONN_INIT // 初始化conn_t结构中基本信息
| ^~~~~~~~~
./common.bpf.h:424:20: note: expanded from macro 'CONN_INIT'
424 | u16 protocol = BPF_CORE_READ(sk, sk_protocol);
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
.output/bpf/bpf_core_read.h:521:2: note: expanded from macro 'BPF_CORE_READ'
521 | BPF_CORE_READ_INTO(&__r, (src), a, ##VA_ARGS);
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
.output/bpf/bpf_core_read.h:428:2: note: expanded from macro 'BPF_CORE_READ_INTO'
428 | ___core_read(bpf_core_read, bpf_core_read,
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
429 | dst, (src), a, ##VA_ARGS)
| ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
note: (skipping 4 expansions in backtrace; use -fmacro-backtrace-limit=0 to see all)
.output/bpf/bpf_core_read.h:413:2: note: expanded from macro '___core_read0'
413 | ___read(fn, dst, ___type(src), src, a);
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
.output/bpf/bpf_core_read.h:394:41: note: expanded from macro '___read'
394 | read_fn((void )(dst), sizeof((dst)), &((src_type)(src))->accessor)
| ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~
.output/bpf/bpf_core_read.h:312:79: note: expanded from macro 'bpf_core_read'
312 | bpf_probe_read_kernel(dst, sz, (const void *)__builtin_preserve_access_index(src))
| ^~~
In file included from netwatcher.bpf.c:25:
./tcp.bpf.h:71:5: error: invalid application of 'typeof' to bit-field
71 | CONN_INIT // 初始化conn_t结构中基本信息
| ^
./common.bpf.h:424:20: note: expanded from macro 'CONN_INIT'
424 | u16 protocol = BPF_CORE_READ(sk, sk_protocol);
| ^
.output/bpf/bpf_core_read.h:520:2: note: expanded from macro 'BPF_CORE_READ'
520 | ___type((src), a, ##VA_ARGS) __r;
| ^
.output/bpf/bpf_core_read.h:391:28: note: expanded from macro '___type'
391 | #define ___type(...) typeof(___arrow(VA_ARGS))
| ^
In file included from netwatcher.bpf.c:25:
./tcp.bpf.h:71:5: error: address of bit-field requested
71 | CONN_INIT // 初始化conn_t结构中基本信息
| ^~~~~~~~~
./common.bpf.h:424:20: note: expanded from macro 'CONN_INIT'
424 | u16 protocol = BPF_CORE_READ(sk, sk_protocol);
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
.output/bpf/bpf_core_read.h:521:2: note: expanded from macro 'BPF_CORE_READ'
521 | BPF_CORE_READ_INTO(&__r, (src), a, ##VA_ARGS);
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
.output/bpf/bpf_core_read.h:428:2: note: expanded from macro 'BPF_CORE_READ_INTO'
428 | ___core_read(bpf_core_read, bpf_core_read,
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
429 | dst, (src), a, ##VA_ARGS)
| ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
note: (skipping 4 expansions in backtrace; use -fmacro-backtrace-limit=0 to see all)
.output/bpf/bpf_core_read.h:413:2: note: expanded from macro '___core_read0'
413 | ___read(fn, dst, ___type(src), src, a);
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
.output/bpf/bpf_core_read.h:394:41: note: expanded from macro '___read'
394 | read_fn((void )(dst), sizeof((dst)), &((src_type)(src))->accessor)
| ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~
.output/bpf/bpf_core_read.h:312:79: note: expanded from macro 'bpf_core_read'
312 | bpf_probe_read_kernel(dst, sz, (const void *)__builtin_preserve_access_index(src))
| ^~~
In file included from netwatcher.bpf.c:25:
./tcp.bpf.h:111:5: error: invalid application of 'typeof' to bit-field
111 | CONN_INIT // 初始化conn_t结构中基本信息
| ^
./common.bpf.h:424:20: note: expanded from macro 'CONN_INIT'
424 | u16 protocol = BPF_CORE_READ(sk, sk_protocol);
| ^
.output/bpf/bpf_core_read.h:520:2: note: expanded from macro 'BPF_CORE_READ'
520 | ___type((src), a, ##VA_ARGS) __r;
| ^
.output/bpf/bpf_core_read.h:391:28: note: expanded from macro '___type'
391 | #define ___type(...) typeof(___arrow(VA_ARGS))
| ^
In file included from netwatcher.bpf.c:25:
./tcp.bpf.h:111:5: error: address of bit-field requested
111 | CONN_INIT // 初始化conn_t结构中基本信息
| ^~~~~~~~~
./common.bpf.h:424:20: note: expanded from macro 'CONN_INIT'
424 | u16 protocol = BPF_CORE_READ(sk, sk_protocol);
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
.output/bpf/bpf_core_read.h:521:2: note: expanded from macro 'BPF_CORE_READ'
521 | BPF_CORE_READ_INTO(&__r, (src), a, ##VA_ARGS);
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
.output/bpf/bpf_core_read.h:428:2: note: expanded from macro 'BPF_CORE_READ_INTO'
428 | ___core_read(bpf_core_read, bpf_core_read,
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
429 | dst, (src), a, ##VA_ARGS)
| ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
note: (skipping 4 expansions in backtrace; use -fmacro-backtrace-limit=0 to see all)
.output/bpf/bpf_core_read.h:413:2: note: expanded from macro '___core_read0'
413 | ___read(fn, dst, ___type(src), src, a);
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
.output/bpf/bpf_core_read.h:394:41: note: expanded from macro '___read'
394 | read_fn((void )(dst), sizeof((dst)), &((src_type)(src))->accessor)
| ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~
.output/bpf/bpf_core_read.h:312:79: note: expanded from macro 'bpf_core_read'
312 | bpf_probe_read_kernel(dst, sz, (const void *)__builtin_preserve_access_index(src))
| ^~~
6 errors generated.
make: *** [Makefile:147:.output/netwatcher.bpf.o] 错误 1

资源:https://lists.llvm.org/pipermail/cfe-commits/Week-of-Mon-20151109/142911.html 改链接应该是相关的修改,我理解应该是clang版本可能不对

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions