-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'selftests-net-extract-bpf-building-logic-from-the-makef…
…ile' Jakub Kicinski says: ==================== selftests: net: extract BPF building logic from the Makefile This has been sitting in my tree for a while. I will soon add YNL/libynl support for networking selftests. This prompted a small cleanup of the selftest makefile for net/. We don't want to be piling logic for each library in there. YNL will get its own .mk file which can be included. Do the same for the BPF building section, already. No funcional changes here, just a code move and small rename. ==================== Link: https://lore.kernel.org/r/20240423183542.3807234-1-kuba@kernel.org Signed-off-by: Jakub Kicinski <kuba@kernel.org>
- Loading branch information
Showing
9 changed files
with
64 additions
and
65 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
# SPDX-License-Identifier: GPL-2.0 | ||
# Rules to generate bpf objs | ||
CLANG ?= clang | ||
SCRATCH_DIR := $(OUTPUT)/tools | ||
BUILD_DIR := $(SCRATCH_DIR)/build | ||
BPFDIR := $(top_srcdir)/tools/lib/bpf | ||
APIDIR := $(top_srcdir)/tools/include/uapi | ||
|
||
CCINCLUDE += -I$(selfdir)/bpf | ||
CCINCLUDE += -I$(top_srcdir)/usr/include/ | ||
CCINCLUDE += -I$(SCRATCH_DIR)/include | ||
|
||
BPFOBJ := $(BUILD_DIR)/libbpf/libbpf.a | ||
|
||
MAKE_DIRS := $(BUILD_DIR)/libbpf | ||
$(MAKE_DIRS): | ||
$(call msg,MKDIR,,$@) | ||
$(Q)mkdir -p $@ | ||
|
||
# Get Clang's default includes on this system, as opposed to those seen by | ||
# '--target=bpf'. This fixes "missing" files on some architectures/distros, | ||
# such as asm/byteorder.h, asm/socket.h, asm/sockios.h, sys/cdefs.h etc. | ||
# | ||
# Use '-idirafter': Don't interfere with include mechanics except where the | ||
# build would have failed anyways. | ||
define get_sys_includes | ||
$(shell $(1) $(2) -v -E - </dev/null 2>&1 \ | ||
| sed -n '/<...> search starts here:/,/End of search list./{ s| \(/.*\)|-idirafter \1|p }') \ | ||
$(shell $(1) $(2) -dM -E - </dev/null | grep '__riscv_xlen ' | awk '{printf("-D__riscv_xlen=%d -D__BITS_PER_LONG=%d", $$3, $$3)}') | ||
endef | ||
|
||
ifneq ($(CROSS_COMPILE),) | ||
CLANG_TARGET_ARCH = --target=$(notdir $(CROSS_COMPILE:%-=%)) | ||
endif | ||
|
||
CLANG_SYS_INCLUDES = $(call get_sys_includes,$(CLANG),$(CLANG_TARGET_ARCH)) | ||
|
||
BPF_PROG_OBJS := $(patsubst %.c,$(OUTPUT)/%.o,$(wildcard *.bpf.c)) | ||
|
||
$(BPF_PROG_OBJS): $(OUTPUT)/%.o : %.c $(BPFOBJ) | $(MAKE_DIRS) | ||
$(call msg,BPF_PROG,,$@) | ||
$(Q)$(CLANG) -O2 -g --target=bpf $(CCINCLUDE) $(CLANG_SYS_INCLUDES) \ | ||
-c $< -o $@ | ||
|
||
$(BPFOBJ): $(wildcard $(BPFDIR)/*.[ch] $(BPFDIR)/Makefile) \ | ||
$(APIDIR)/linux/bpf.h \ | ||
| $(BUILD_DIR)/libbpf | ||
$(call msg,MAKE,,$@) | ||
$(Q)$(MAKE) $(submake_extras) -C $(BPFDIR) OUTPUT=$(BUILD_DIR)/libbpf/ \ | ||
EXTRA_CFLAGS='-g -O0' \ | ||
DESTDIR=$(SCRATCH_DIR) prefix= all install_headers | ||
|
||
EXTRA_CLEAN += $(SCRATCH_DIR) |
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.