File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -7,6 +7,9 @@ compile_commands.json
77# ignore CLANG intermediate compilation tmp files
88* .o.tmp
99
10+ # ignore generated CFLAGS
11+ ** .clang_flags.mk
12+
1013# ignore scapy autgen and python cache
1114tests /scapy /__pycache__ /*
1215tests /output /*
Original file line number Diff line number Diff line change @@ -243,9 +243,9 @@ clean:
243243 $(QUIET ) $(foreach TARGET,$(SUBDIRS ) , \
244244 $(MAKE ) $(SUBMAKEOPTS ) -C $(TARGET ) clean; )
245245 $(QUIET ) rm -fr * .o * .ll * .i * .s
246+ $(QUIET ) rm -f $(CLANG_FLAGS_FILE )
246247 $(QUIET ) rm -f $(TARGET )
247248
248-
249249BEAR_CLI = $(shell which bear 2> /dev/null)
250250gen_compile_commands :
251251ifeq (, $(BEAR_CLI ) )
Original file line number Diff line number Diff line change 33
44FLAGS := -I$(ROOT_DIR)/bpf -I$(ROOT_DIR)/bpf/include -O2 -g
55
6- CLANG_FLAGS := ${FLAGS} --target=bpf -std=gnu99 -nostdinc
7- # eBPF verifier enforces unaligned access checks where necessary, so don't
8- # let clang complain too early.
9- CLANG_FLAGS += -ftrap-function=__undefined_trap
10- CLANG_FLAGS += -Wall -Wextra -Werror -Wshadow
11- CLANG_FLAGS += -Wno-address-of-packed-member
12- CLANG_FLAGS += -Wno-unknown-warning-option
13- CLANG_FLAGS += -Wno-gnu-variable-sized-type-not-at-end
14- CLANG_FLAGS += -Wimplicit-int-conversion -Wenum-conversion
15- CLANG_FLAGS += -Wimplicit-fallthrough
16- CLANG_FLAGS += -mcpu=v3
6+ # Note, FLAGS needs to be defined before inclusion
7+ include $(ROOT_DIR)/bpf/Makefile.clang
178
189LIB := $(shell find $(ROOT_DIR)/bpf -name '*.h')
1910BPF_C := $(patsubst %.o,%.c,$(BPF))
2011BPF_ASM := $(patsubst %.o,%.s,$(BPF))
2112
22- CLANG ?= clang
23- HOST_CC ?= gcc
24- HOST_STRIP ?= strip
25-
2613ifeq ($(CROSS_ARCH),arm64)
2714 HOST_CC = aarch64-linux-gnu-gcc
2815 HOST_STRIP = aarch64-linux-gnu-strip
Original file line number Diff line number Diff line change 1+ CLANG ?= clang
2+ HOST_CC ?= gcc
3+ HOST_STRIP ?= strip
4+
5+ # Base CFLAGS (CLANG_FLAGS) are read from pkg/datapath/loader/compile.go
6+ # to keep them synced with the loader
7+
8+ CLANG_FLAGS_FILE := $(shell realpath --relative-to=$(CURDIR) $(ROOT_DIR)/bpf/.clang_flags.mk)
9+ CLANG_CFLAGS_GO := $(ROOT_DIR)/pkg/datapath/loader/tools/clang_cflags.go
10+ LOADER_GO_FILES := $(shell find $(ROOT_DIR)/pkg/datapath/loader -type f -name '*.go')
11+
12+ # Rebuild only when go files are modified in the loader
13+ $(CLANG_FLAGS_FILE): $(LOADER_GO_FILES)
14+ $(QUIET) echo 'CLANG_FLAGS := $(FLAGS) '`$(GO) run $(CLANG_CFLAGS_GO)` > $@
15+
16+ -include $(CLANG_FLAGS_FILE)
17+
18+ # Mimics the mcpu values set by cilium-agent. See GetBPFCPU().
19+ CLANG_FLAGS += -mcpu=v3
Original file line number Diff line number Diff line change @@ -5,20 +5,14 @@ include ../../Makefile.defs
55
66MAKEFLAGS += -r
77
8- CLANG ?= clang
9-
108FLAGS := -I$(ROOT_DIR ) /bpf -I$(ROOT_DIR ) /bpf/include -g
119
12- # Base CFLAGS (CLANG_FLAGS) are read from pkg/datapath/loader/compile.go
13- # to keep them synced with the loader
14- CLANG_FLAGS := $(FLAGS ) $(shell $(GO ) run $(ROOT_DIR ) /pkg/datapath/loader/tools/clang_cflags.go)
10+ # Note, FLAGS needs to be defined before inclusion
11+ include ../Makefile.clang
1512
1613# Create dependency files for each .o file.
1714CLANG_FLAGS += -MD
1815
19- # Mimics the mcpu values set by cilium-agent. See GetBPFCPU().
20- CLANG_FLAGS += -mcpu=v3
21-
2216# Autogenerated scapy pkts
2317SCAPY_HDR := $(ROOT_DIR ) /bpf/tests/output/gen_pkts.h
2418SCAPY_HDR_TS := $(ROOT_DIR ) /bpf/tests/output/gen_pkts.h.stamp
You can’t perform that action at this time.
0 commit comments