daeuniverse / dae

eBPF-based Linux high-performance transparent proxy solution.
GNU Affero General Public License v3.0
3.34k stars 205 forks source link

[Bug Report] Build error on riscv64 #696

Closed CAB233 closed 2 days ago

CAB233 commented 2 weeks ago

Checks

Current Behavior

在 riscv64 上尝试构建 latest(0.8.0) dae,虽然能编译出二进制文件,但部分模块无法编译。 相关日志(在本仓库 Action 中也存在相同日志):

built on riscv64 ``` go: downloading github.com/sirupsen/logrus v1.9.3 /var/cache/acbs/build/acbs.4uyem51s/dae/trace/kern/trace.c:137:23: error: no member named 'a1' in 'struct user_regs_struct' 137 | meta->second_param = PT_REGS_PARM2(ctx); | ^~~~~~~~~~~~~~~~~~ /var/cache/acbs/build/acbs.4uyem51s/dae/trace/kern/headers/bpf_tracing.h:486:46: note: expanded from macro 'PT_REGS_PARM2' 486 | #define PT_REGS_PARM2(x) (__PT_REGS_CAST(x)->__PT_PARM2_REG) | ~~~~~~~~~~~~~~~~~ ^ /var/cache/acbs/build/acbs.4uyem51s/dae/trace/kern/headers/bpf_tracing.h:357:24: note: expanded from macro '__PT_PARM2_REG' 357 | #define __PT_PARM2_REG a1 | ^ /var/cache/acbs/build/acbs.4uyem51s/dae/trace/kern/trace.c:227:1: error: no member named 'a0' in 'struct user_regs_struct' 227 | KPROBE_SKB_AT(1) | ^~~~~~~~~~~~~~~~ /var/cache/acbs/build/acbs.4uyem51s/dae/trace/kern/trace.c:223:46: note: expanded from macro 'KPROBE_SKB_AT' 223 | struct sk_buff *skb = (struct sk_buff *) PT_REGS_PARM##X(ctx); \ | ^~~~~~~~~~~~~~~~~~~~ :169:1: note: expanded from here 169 | PT_REGS_PARM1 | ^ /var/cache/acbs/build/acbs.4uyem51s/dae/trace/kern/headers/bpf_tracing.h:485:46: note: expanded from macro 'PT_REGS_PARM1' 485 | #define PT_REGS_PARM1(x) (__PT_REGS_CAST(x)->__PT_PARM1_REG) | ~~~~~~~~~~~~~~~~~ ^ /var/cache/acbs/build/acbs.4uyem51s/dae/trace/kern/headers/bpf_tracing.h:356:24: note: expanded from macro '__PT_PARM1_REG' 356 | #define __PT_PARM1_REG a0 | ^ /var/cache/acbs/build/acbs.4uyem51s/dae/trace/kern/trace.c:228:1: error: no member named 'a1' in 'struct user_regs_struct' 228 | KPROBE_SKB_AT(2) | ^~~~~~~~~~~~~~~~ /var/cache/acbs/build/acbs.4uyem51s/dae/trace/kern/trace.c:223:46: note: expanded from macro 'KPROBE_SKB_AT' 223 | struct sk_buff *skb = (struct sk_buff *) PT_REGS_PARM##X(ctx); \ | ^~~~~~~~~~~~~~~~~~~~ :178:1: note: expanded from here 178 | PT_REGS_PARM2 | ^ /var/cache/acbs/build/acbs.4uyem51s/dae/trace/kern/headers/bpf_tracing.h:486:46: note: expanded from macro 'PT_REGS_PARM2' 486 | #define PT_REGS_PARM2(x) (__PT_REGS_CAST(x)->__PT_PARM2_REG) | ~~~~~~~~~~~~~~~~~ ^ /var/cache/acbs/build/acbs.4uyem51s/dae/trace/kern/headers/bpf_tracing.h:357:24: note: expanded from macro '__PT_PARM2_REG' 357 | #define __PT_PARM2_REG a1 | ^ /var/cache/acbs/build/acbs.4uyem51s/dae/trace/kern/trace.c:229:1: error: no member named 'a2' in 'struct user_regs_struct' 229 | KPROBE_SKB_AT(3) | ^~~~~~~~~~~~~~~~ /var/cache/acbs/build/acbs.4uyem51s/dae/trace/kern/trace.c:223:46: note: expanded from macro 'KPROBE_SKB_AT' 223 | struct sk_buff *skb = (struct sk_buff *) PT_REGS_PARM##X(ctx); \ | ^~~~~~~~~~~~~~~~~~~~ :187:1: note: expanded from here 187 | PT_REGS_PARM3 | ^ /var/cache/acbs/build/acbs.4uyem51s/dae/trace/kern/headers/bpf_tracing.h:487:46: note: expanded from macro 'PT_REGS_PARM3' 487 | #define PT_REGS_PARM3(x) (__PT_REGS_CAST(x)->__PT_PARM3_REG) | ~~~~~~~~~~~~~~~~~ ^ /var/cache/acbs/build/acbs.4uyem51s/dae/trace/kern/headers/bpf_tracing.h:358:24: note: expanded from macro '__PT_PARM3_REG' 358 | #define __PT_PARM3_REG a2 | ^ /var/cache/acbs/build/acbs.4uyem51s/dae/trace/kern/trace.c:230:1: error: no member named 'a3' in 'struct user_regs_struct' 230 | KPROBE_SKB_AT(4) | ^~~~~~~~~~~~~~~~ /var/cache/acbs/build/acbs.4uyem51s/dae/trace/kern/trace.c:223:46: note: expanded from macro 'KPROBE_SKB_AT' 223 | struct sk_buff *skb = (struct sk_buff *) PT_REGS_PARM##X(ctx); \ | ^~~~~~~~~~~~~~~~~~~~ :196:1: note: expanded from here 196 | PT_REGS_PARM4 | ^ /var/cache/acbs/build/acbs.4uyem51s/dae/trace/kern/headers/bpf_tracing.h:488:46: note: expanded from macro 'PT_REGS_PARM4' 488 | #define PT_REGS_PARM4(x) (__PT_REGS_CAST(x)->__PT_PARM4_REG) | ~~~~~~~~~~~~~~~~~ ^ /var/cache/acbs/build/acbs.4uyem51s/dae/trace/kern/headers/bpf_tracing.h:359:24: note: expanded from macro '__PT_PARM4_REG' 359 | #define __PT_PARM4_REG a3 | ^ /var/cache/acbs/build/acbs.4uyem51s/dae/trace/kern/trace.c:231:1: error: no member named 'a4' in 'struct user_regs_struct' 231 | KPROBE_SKB_AT(5) | ^~~~~~~~~~~~~~~~ /var/cache/acbs/build/acbs.4uyem51s/dae/trace/kern/trace.c:223:46: note: expanded from macro 'KPROBE_SKB_AT' 223 | struct sk_buff *skb = (struct sk_buff *) PT_REGS_PARM##X(ctx); \ | ^~~~~~~~~~~~~~~~~~~~ :205:1: note: expanded from here 205 | PT_REGS_PARM5 | ^ /var/cache/acbs/build/acbs.4uyem51s/dae/trace/kern/headers/bpf_tracing.h:489:46: note: expanded from macro 'PT_REGS_PARM5' 489 | #define PT_REGS_PARM5(x) (__PT_REGS_CAST(x)->__PT_PARM5_REG) | ~~~~~~~~~~~~~~~~~ ^ /var/cache/acbs/build/acbs.4uyem51s/dae/trace/kern/headers/bpf_tracing.h:360:24: note: expanded from macro '__PT_PARM5_REG' 360 | #define __PT_PARM5_REG a4 | ^ /var/cache/acbs/build/acbs.4uyem51s/dae/trace/kern/trace.c:236:18: error: no member named 'a0' in 'struct user_regs_struct' 236 | u64 skb = (u64) PT_REGS_PARM1(ctx); | ^~~~~~~~~~~~~~~~~~ /var/cache/acbs/build/acbs.4uyem51s/dae/trace/kern/headers/bpf_tracing.h:485:46: note: expanded from macro 'PT_REGS_PARM1' 485 | #define PT_REGS_PARM1(x) (__PT_REGS_CAST(x)->__PT_PARM1_REG) | ~~~~~~~~~~~~~~~~~ ^ /var/cache/acbs/build/acbs.4uyem51s/dae/trace/kern/headers/bpf_tracing.h:356:24: note: expanded from macro '__PT_PARM1_REG' 356 | #define __PT_PARM1_REG a0 | ^ 7 errors generated. Error: can't execute clang: exit status 1 exit status 1 ```

完整构建日志:https://buildit.aosc.io/web-logs/48101-dae-0.8.0-new-riscv64-debian-pisces-04-2024-11-10-00:47:14.txt

Expected Behavior

No response

Steps to Reproduce

构建脚本:https://github.com/AOSC-Dev/aosc-os-abbs/pull/8555/files

Environment

Anything else?

No response

dae-prow[bot] commented 2 weeks ago

Thanks for opening this issue!

Integral-Tech commented 3 days ago

I have just submitted a PR (https://github.com/daeuniverse/dae_bpf_headers/pull/4) in dae_bpf_headers repository, please fetch changes and test whether build error persists.

CAB233 commented 2 days ago

The previous error didn't appear, but a new one appeared.

# github.com/daeuniverse/dae/trace
trace/trace.go:90:71: undefined: bpfObjects
trace/trace.go:91:15: undefined: loadBpf
trace/trace.go:113:10: undefined: bpfObjects
trace/trace.go:189:31: undefined: bpfObjects
trace/trace.go:225:46: undefined: bpfObjects
mzz2017 commented 2 days ago

@CAB233 make ebpf

mzz2017 commented 2 days ago

@CAB233 哦,这可能是 trace 那边的 submodule 没更新,你看看也更新一下,不能只更 kern 里的那个

Integral-Tech commented 2 days ago

@CAB233 Could you please confirm if you have updated the submodule trace/kern/headers?

CAB233 commented 2 days ago

I'm sure that patch is applied in control/kern/headers and trace/kern/headers, and I'm seeing the corresponding message during compilation

after patching ``` [INFO]: Building dae ... -strip=/usr/bin/llvm-strip go: downloading github.com/cilium/ebpf v0.12.3 go: downloading golang.org/x/exp v0.0.0-20240222234643-814bf88cf225 go: downloading golang.org/x/sys v0.20.0 Compiled /var/cache/acbs/build/acbs.imaltk8f/dae/control/bpf_bpfel.o Stripped /var/cache/acbs/build/acbs.imaltk8f/dae/control/bpf_bpfel.o Wrote /var/cache/acbs/build/acbs.imaltk8f/dae/control/bpf_bpfel.go Compiled /var/cache/acbs/build/acbs.imaltk8f/dae/control/bpf_bpfeb.o Stripped /var/cache/acbs/build/acbs.imaltk8f/dae/control/bpf_bpfeb.o Wrote /var/cache/acbs/build/acbs.imaltk8f/dae/control/bpf_bpfeb.go go: downloading github.com/sirupsen/logrus v1.9.3 Compiled /var/cache/acbs/build/acbs.imaltk8f/dae/trace/bpf_bpfel_riscv.o Stripped /var/cache/acbs/build/acbs.imaltk8f/dae/trace/bpf_bpfel_riscv.o Wrote /var/cache/acbs/build/acbs.imaltk8f/dae/trace/bpf_bpfel_riscv.go -DMAX_MATCH_SET_LEN=64 -O2 -Wall -Werror -fno-stack-protector go build -tags=trace -o dae -trimpath -ldflags "-s -w -X github.com/daeuniverse/dae/cmd.Version=0.8.0 -X github.com/daeuniverse/dae/common/consts.MaxMatchSetLen_=64" -trimpath -mod=readonly -modcacherw -buildmode=pie . go: downloading github.com/json-iterator/go v1.1.12 go: downloading github.com/okzk/sdnotify v0.0.0-20180710141335-d9becc38acbd go: downloading github.com/shirou/gopsutil/v4 v4.24.5 go: downloading github.com/daeuniverse/outbound v0.0.0-20240928042419-b1e258193113 go: downloading github.com/mholt/archiver/v3 v3.5.1 go: downloading github.com/mohae/deepcopy v0.0.0-20170929034955-c48cc78d4826 go: downloading github.com/vishvananda/netlink v1.1.0 go: downloading gopkg.in/natefinch/lumberjack.v2 v2.2.1 go: downloading github.com/spf13/cobra v1.7.0 go: downloading github.com/x-cray/logrus-prefixed-formatter v0.5.2 go: downloading github.com/miekg/dns v1.1.58 go: downloading github.com/antlr/antlr4/runtime/Go/antlr/v4 v4.0.0-20230305170008-8188dc5388df go: downloading github.com/daeuniverse/dae-config-dist/go/dae_config v0.0.0-20230604120805-1c27619b592d go: downloading github.com/bits-and-blooms/bloom/v3 v3.5.0 go: downloading github.com/fsnotify/fsnotify v1.7.0 go: downloading github.com/safchain/ethtool v0.3.0 go: downloading github.com/vishvananda/netns v0.0.4 go: downloading github.com/panjf2000/ants v1.3.0 go: downloading github.com/adrg/xdg v0.4.0 go: downloading github.com/v2rayA/ahocorasick-domain v0.0.0-20231231085011-99ceb8ef3208 go: downloading github.com/dlclark/regexp2 v1.11.0 go: downloading google.golang.org/protobuf v1.33.0 go: downloading golang.org/x/crypto v0.21.0 go: downloading github.com/bits-and-blooms/bitset v1.8.0 go: downloading github.com/modern-go/reflect2 v1.0.2 go: downloading github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd go: downloading github.com/spf13/pflag v1.0.5 go: downloading github.com/golang/snappy v0.0.2 go: downloading github.com/klauspost/compress v1.17.4 go: downloading github.com/xi2/xz v0.0.0-20171230120015-48954b6210f8 go: downloading github.com/klauspost/pgzip v1.2.5 go: downloading github.com/nwaples/rardecode v1.1.0 go: downloading github.com/daeuniverse/quic-go v0.0.0-20240413031024-943f218e0810 go: downloading github.com/ulikunitz/xz v0.5.9 go: downloading github.com/pierrec/lz4/v4 v4.1.2 go: downloading google.golang.org/grpc v1.57.0 go: downloading github.com/andybalholm/brotli v1.0.6 go: downloading golang.org/x/net v0.22.0 go: downloading github.com/dsnet/compress v0.0.2-0.20210315054119-f66993602bf5 go: downloading github.com/awnumar/fastrand v0.0.0-20210315215012-30ee0990fa2d go: downloading github.com/mgutz/ansi v0.0.0-20200706080929-d51e80ef957d go: downloading github.com/golang/protobuf v1.5.3 go: downloading github.com/eknkc/basex v1.0.1 go: downloading github.com/dgryski/go-idea v0.0.0-20170306091226-d2fb45a411fb go: downloading github.com/dgryski/go-rc2 v0.0.0-20150621095337-8a9021637152 go: downloading gitlab.com/yawning/chacha20.git v0.0.0-20230427033715-7877545b1b37 go: downloading github.com/google/uuid v1.3.0 go: downloading github.com/gorilla/websocket v1.5.0 go: downloading github.com/dgryski/go-camellia v0.0.0-20191119043421-69a8a13fb23d go: downloading github.com/seiflotfy/cuckoofilter v0.0.0-20220411075957-e3b120b3f5fb go: downloading github.com/mzz2017/disk-bloom v1.0.1 go: downloading github.com/refraction-networking/utls v1.6.4 go: downloading github.com/mattn/go-colorable v0.1.13 go: downloading golang.org/x/term v0.18.0 go: downloading github.com/dgryski/go-metro v0.0.0-20211217172704-adc40b04c140 go: downloading github.com/awnumar/memguard v0.19.1 go: downloading github.com/mattn/go-isatty v0.0.19 go: downloading github.com/cloudflare/circl v1.3.7 go: downloading google.golang.org/genproto/googleapis/rpc v0.0.0-20230807174057-1744710a1577 go: downloading github.com/awnumar/memcall v0.0.0-20190816154910-db5ea08008a3 go: downloading github.com/quic-go/qpack v0.4.0 go: downloading golang.org/x/text v0.14.0 # github.com/daeuniverse/dae/trace trace/trace.go:90:71: undefined: bpfObjects trace/trace.go:91:15: undefined: loadBpf trace/trace.go:113:10: undefined: bpfObjects trace/trace.go:189:31: undefined: bpfObjects trace/trace.go:225:46: undefined: bpfObjects make: *** [Makefile:53: dae] Error 1 ```
CAB233 commented 2 days ago

Then I tried the 0.9.0rc2 version of dae, and it compiles completely.