diff --git a/driver/bpf/Makefile b/driver/bpf/Makefile index 9b6a2ee39f..58d1b11165 100644 --- a/driver/bpf/Makefile +++ b/driver/bpf/Makefile @@ -13,29 +13,11 @@ always = $(always-y) LLC ?= llc CLANG ?= clang -ifeq ($(strip $(MAKEFILE_LIST)),Makefile) - -KERNELDIR ?= /lib/modules/$(shell uname -r)/build - # DEBUG = -DBPF_DEBUG -# -# https://chromium.googlesource.com/chromiumos/third_party/kernel/+/096925a44076ba5c52faa84d255a847130ff341e%5E%21/#F2 -# This commit diverged the ChromiumOS kernel from stock in the area of audit information, which this probe accesses. -# -# This enables the workaround for this divergence. -# -NEEDS_COS_73_WORKAROUND = $(shell expr `grep -sc "^\s*struct\s\+audit_task_info\s\+\*audit;\s*$$" $(KERNELDIR)/include/linux/sched.h` = 1) -ifeq ($(NEEDS_COS_73_WORKAROUND), 1) - KBUILD_CPPFLAGS += -DCOS_73_WORKAROUND -endif +ifeq ($(strip $(MAKEFILE_LIST)),Makefile) -# -fmacro-prefix-map is not supported on version of clang older than 10 -# so remove it if necessary. -IS_CLANG_OLDER_THAN_10 := $(shell expr `$(CLANG) -dumpversion | cut -f1 -d.` \<= 10) -ifeq ($(IS_CLANG_OLDER_THAN_10), 1) - KBUILD_CPPFLAGS := $(filter-out -fmacro-prefix-map=%,$(KBUILD_CPPFLAGS)) -endif +KERNELDIR ?= /lib/modules/$(shell uname -r)/build all: $(MAKE) -C $(KERNELDIR) M=$$PWD @@ -61,6 +43,24 @@ $(info [configure-bpf] Including $(MAKEFILE_INC_FILES)) include $(MAKEFILE_INC_FILES) endif +# +# https://chromium.googlesource.com/chromiumos/third_party/kernel/+/096925a44076ba5c52faa84d255a847130ff341e%5E%21/#F2 +# This commit diverged the ChromiumOS kernel from stock in the area of audit information, which this probe accesses. +# +# This enables the workaround for this divergence. +# +NEEDS_COS_73_WORKAROUND = $(shell expr `grep -sc "^\s*struct\s\+audit_task_info\s\+\*audit;\s*$$" $(KERNELDIR)/include/linux/sched.h` = 1) +ifeq ($(NEEDS_COS_73_WORKAROUND), 1) + KBUILD_CPPFLAGS += -DCOS_73_WORKAROUND +endif + +# -fmacro-prefix-map is not supported on version of clang older than 10 +# so remove it if necessary. +IS_CLANG_OLDER_THAN_10 := $(shell expr `$(CLANG) -dumpversion | cut -f1 -d.` \<= 10) +ifeq ($(IS_CLANG_OLDER_THAN_10), 1) + KBUILD_CPPFLAGS := $(filter-out -fmacro-prefix-map=%,$(KBUILD_CPPFLAGS)) +endif + $(obj)/probe.o: $(src)/probe.c \ $(src)/bpf_helpers.h \ $(src)/filler_helpers.h \ @@ -86,4 +86,4 @@ $(obj)/probe.o: $(src)/probe.c \ -O2 -g -emit-llvm -c $< -o $(patsubst %.o,%.ll,$@) $(LLC) -march=bpf -filetype=obj -o $@ $(patsubst %.o,%.ll,$@) -endif # $(strip $(MAKEFILE_LIST)),Makefile \ No newline at end of file +endif # $(strip $(MAKEFILE_LIST)),Makefile