Skip to content

Commit 9160d43

Browse files
committed
add standalone vmlinux.h to compile easier
With the support of CORE, it is not needed to generate vmlinux.h on build time anymore. Signed-off-by: Menglong Dong <imagedong@tencent.com>
1 parent 2b4807e commit 9160d43

5 files changed

Lines changed: 144651 additions & 55 deletions

File tree

.gitignore

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22
__pycache__
33
*.pyc
44
output
5-
vmlinux.h
65
*.skel.h
76
*.o
87
.*

common.mk

Lines changed: 10 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@ include $(ROOT)/script/arch.mk
1818

1919
HEADERS := $(if $(KERNEL),$(KERNEL),/lib/modules/$(shell uname -r)/build/)
2020
NOSTDINC_FLAGS += -nostdinc -isystem $(shell $(CC) -print-file-name=include)
21-
BTF := $(if $(VMLINUX),$(VMLINUX),/sys/kernel/btf/vmlinux)
2221
export HEADERS
2322

2423
USERINCLUDE := \
@@ -42,28 +41,20 @@ KERNEL_CFLAGS += $(NOSTDINC_FLAGS) $(LINUXINCLUDE) \
4241
-Wno-unknown-warning-option -Wno-frame-address
4342

4443
cmd_download = @if [ ! -f $(1) ]; then wget -O $(1) $(REMOTE_ROOT)/$(2); fi
45-
cmd_exist = $(if $(wildcard $(1)),$(2),$(3))
46-
cmd_or_exist = $(call cmd_exist,$(1),$(1),$(2))
47-
ifeq ("$(wildcard $(HEADERS))$(wildcard $(BTF))","")
48-
$(error BTF is not found in your system, please install kernel headers)
49-
endif
5044

51-
ifeq ($(if $(KERNEL),$(wildcard $(KERNEL)),"pass"),)
52-
$(error kernel path not exist)
45+
ifdef KERN_VER
46+
CFLAGS += -DKERN_VER=$(KERN_VER)
5347
endif
5448

55-
ifeq ($(if $(VMLINUX),$(wildcard $(VMLINUX)),"pass"),)
56-
$(error vmlinux path not exist)
49+
ifdef COMPAT
50+
ifeq ($(wildcard $(HEADERS)),)
51+
$(error kernel headers not exist in COMPAT mdoe, please install it)
5752
endif
58-
59-
# preferred to compile from kernel headers, then BTF
60-
mode := $(if $(VMLINUX),'btf',$(call cmd_exist,$(HEADERS),'kernel','btf'))
61-
ifeq ($(mode),'btf')
62-
kheaders_cmd := ln -s vmlinux.h kheaders.h
63-
kheaders_dep := vmlinux.h
64-
else
6553
kheaders_cmd := ln -s vmlinux_header.h kheaders.h
54+
CFLAGS += -DCOMPAT_MODE
6655
BPF_CFLAGS += $(KERNEL_CFLAGS)
56+
else
57+
kheaders_cmd := ln -s ../shared/bpf/vmlinux.h kheaders.h
6758
endif
6859

6960
ifndef BPFTOOL
@@ -74,13 +65,10 @@ else
7465
endif
7566
endif
7667

77-
vmlinux.h:
78-
$(BPFTOOL) btf dump file $(BTF) format c > vmlinux.h
79-
80-
kheaders.h: $(kheaders_dep)
68+
kheaders.h:
8169
$(call kheaders_cmd)
8270

83-
progs/%.o: progs/%.c kheaders.h
71+
progs/%.o: progs/%.c $(BPF_EXTRA_DEP)
8472
clang -O2 -c -g -S -Wall -Wno-pointer-sign -Wno-unused-value \
8573
-Wno-incompatible-pointer-types-discards-qualifiers \
8674
-fno-asynchronous-unwind-tables \

nodetrace/vmlinux_header.h

Lines changed: 0 additions & 11 deletions
This file was deleted.

0 commit comments

Comments
 (0)