Skip to content

Commit

Permalink
fix(driver/bpf): KBUILD_CPPFLAGS
Browse files Browse the repository at this point in the history
Signed-off-by: Angelo Puglisi <[email protected]>
  • Loading branch information
deepskyblue86 authored and poiana committed Mar 15, 2024
1 parent b78fc06 commit 7de3404
Showing 1 changed file with 21 additions and 21 deletions.
42 changes: 21 additions & 21 deletions driver/bpf/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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 \
Expand All @@ -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
endif # $(strip $(MAKEFILE_LIST)),Makefile

0 comments on commit 7de3404

Please sign in to comment.