mirror of
https://github.com/AuxXxilium/linux_dsm_epyc7002.git
synced 2024-12-19 16:06:45 +07:00
Merge branch 'samples-cross-compile'
Ivan Khoronzhuk says: ==================== This series contains mainly fixes/improvements for cross-compilation but not only, tested for arm, arm64, and intended for any arch. Also verified on native build (not cross compilation) for x86_64 and arm, arm64. Initial RFC link: https://lkml.org/lkml/2019/8/29/1665 Prev. version: https://lkml.org/lkml/2019/10/9/1045 Besides the patches given here, the RFC also contains couple patches related to llvm clang arm: include: asm: swab: mask rev16 instruction for clang arm: include: asm: unified: mask .syntax unified for clang They are necessarily to verify arm 32 build. Also, couple more fixes were added but are not merged in bpf-next yet, they can be needed for verification/configuration steps, if not in your tree the fixes can be taken here: https://www.spinics.net/lists/netdev/msg601716.html https://www.spinics.net/lists/netdev/msg601714.html https://www.spinics.net/lists/linux-kbuild/msg23468.html Now, to build samples, SAMPLE_BPF should be enabled in config. The change touches not only cross-compilation and can have impact on other archs and build environments, so might be good idea to verify it in order to add appropriate changes, some warn options could be tuned also. All is tested on x86-64 with clang installed (has to be built containing targets for arm, arm64..., see llc --version, usually it's present already) Instructions to test native on x86_64 ================================================= Native build on x86_64 is done in usual way and shouldn't have difference except HOSTCC is now printed as CC wile building the samples. Instructions to test cross compilation on arm64 ================================================= gcc version 8.3.0 (GNU Toolchain for the A-profile Architecture 8.3-2019.03 (arm-rel-8.36)) I've used sdk for TI am65x got here: http://downloads.ti.com/processor-sdk-linux/esd/AM65X/latest/exports/\ ti-processor-sdk-linux-am65xx-evm-06.00.00.07-Linux-x86-Install.bin make ARCH=arm64 -C tools/ clean make ARCH=arm64 -C samples/bpf clean make ARCH=arm64 clean make ARCH=arm64 defconfig make ARCH=arm64 headers_install make ARCH=arm64 INSTALL_HDR_PATH=/../sdk/\ ti-processor-sdk-linux-am65xx-evm-06.00.00.07/linux-devkit/sysroots/\ aarch64-linux/usr headers_install make samples/bpf/ ARCH=arm64 CROSS_COMPILE="aarch64-linux-gnu-"\ SYSROOT="/../sdk/ti-processor-sdk-linux-am65xx-evm-06.00.00.07/\ linux-devkit/sysroots/aarch64-linux" Instructions to test cross compilation on arm ================================================= arm-linux-gnueabihf-gcc (Linaro GCC 7.2-2017.11) 7.2.1 20171011 or arm-linux-gnueabihf-gcc (GNU Toolchain for the A-profile Architecture 8.3-2019.03 \ (arm-rel-8.36)) 8.3.0 http://downloads.ti.com/processor-sdk-linux/esd/AM57X/05_03_00_07/exports/\ ti-processor-sdk-linux-am57xx-evm-05.03.00.07-Linux-x86-Install.bin make ARCH=arm -C tools/ clean make ARCH=arm -C samples/bpf clean make ARCH=arm clean make ARCH=arm omap2plus_defconfig make ARCH=arm headers_install make ARCH=arm INSTALL_HDR_PATH=/../sdk/\ ti-processor-sdk-linux-am57xx-evm-05.03.00.07/linux-devkit/sysroots/\ armv7ahf-neon-linux-gnueabi/usr headers_install make samples/bpf/ ARCH=arm CROSS_COMPILE="arm-linux-gnueabihf-"\ SYSROOT="/../sdk/ti-processor-sdk-linux-am57xx-evm-05.03\ .00.07/linux-devkit/sysroots/armv7ahf-neon-linux-gnueabi" Based on bpf-next/master v5..v4: - any changes, only missed SOBs are added v4..v3: - renamed CLANG_EXTRA_CFLAGS on BPF_EXTRA_CFLAGS - used filter for ARCH_ARM_SELECTOR - omit "-fomit-frame-pointer" and use same flags for native and "cross" - used sample/bpf prefixes - use C instead of C++ compiler for test_libbpf target v3..v2: - renamed makefile.progs to makeifle.target, as more appropriate - left only __LINUX_ARM_ARCH__ for D options for arm - for host build - left options from KBUILD_HOST for compatibility reasons - split patch adding c/cxx/ld flags to libbpf by modules - moved readme change to separate patch - added patch setting options for cross-compile - fixed issue with option error for syscall_nrs.S, avoiding overlap for ccflags-y. v2..v1: - restructured patches order - split "samples: bpf: Makefile: base progs build on Makefile.progs" to make change more readable. It added couple nice extra patches. - removed redundant patch: "samples: bpf: Makefile: remove target for native build" - added fix: "samples: bpf: makefile: fix cookie_uid_helper_example obj build" - limited -D option filter only for arm - improved comments - added couple instructions to verify cross compilation for arm and arm64 arches based on TI am57xx and am65xx sdks. - corrected include a little order ==================== Tested-by: Ilias Apalodimas <ilias.apalodimas@linaro.org> Signed-off-by: Alexei Starovoitov <ast@kernel.org>
This commit is contained in:
commit
c2383d398e
@ -4,55 +4,53 @@ BPF_SAMPLES_PATH ?= $(abspath $(srctree)/$(src))
|
||||
TOOLS_PATH := $(BPF_SAMPLES_PATH)/../../tools
|
||||
|
||||
# List of programs to build
|
||||
hostprogs-y := test_lru_dist
|
||||
hostprogs-y += sock_example
|
||||
hostprogs-y += fds_example
|
||||
hostprogs-y += sockex1
|
||||
hostprogs-y += sockex2
|
||||
hostprogs-y += sockex3
|
||||
hostprogs-y += tracex1
|
||||
hostprogs-y += tracex2
|
||||
hostprogs-y += tracex3
|
||||
hostprogs-y += tracex4
|
||||
hostprogs-y += tracex5
|
||||
hostprogs-y += tracex6
|
||||
hostprogs-y += tracex7
|
||||
hostprogs-y += test_probe_write_user
|
||||
hostprogs-y += trace_output
|
||||
hostprogs-y += lathist
|
||||
hostprogs-y += offwaketime
|
||||
hostprogs-y += spintest
|
||||
hostprogs-y += map_perf_test
|
||||
hostprogs-y += test_overhead
|
||||
hostprogs-y += test_cgrp2_array_pin
|
||||
hostprogs-y += test_cgrp2_attach
|
||||
hostprogs-y += test_cgrp2_sock
|
||||
hostprogs-y += test_cgrp2_sock2
|
||||
hostprogs-y += xdp1
|
||||
hostprogs-y += xdp2
|
||||
hostprogs-y += xdp_router_ipv4
|
||||
hostprogs-y += test_current_task_under_cgroup
|
||||
hostprogs-y += trace_event
|
||||
hostprogs-y += sampleip
|
||||
hostprogs-y += tc_l2_redirect
|
||||
hostprogs-y += lwt_len_hist
|
||||
hostprogs-y += xdp_tx_iptunnel
|
||||
hostprogs-y += test_map_in_map
|
||||
hostprogs-y += per_socket_stats_example
|
||||
hostprogs-y += xdp_redirect
|
||||
hostprogs-y += xdp_redirect_map
|
||||
hostprogs-y += xdp_redirect_cpu
|
||||
hostprogs-y += xdp_monitor
|
||||
hostprogs-y += xdp_rxq_info
|
||||
hostprogs-y += syscall_tp
|
||||
hostprogs-y += cpustat
|
||||
hostprogs-y += xdp_adjust_tail
|
||||
hostprogs-y += xdpsock
|
||||
hostprogs-y += xdp_fwd
|
||||
hostprogs-y += task_fd_query
|
||||
hostprogs-y += xdp_sample_pkts
|
||||
hostprogs-y += ibumad
|
||||
hostprogs-y += hbm
|
||||
tprogs-y := test_lru_dist
|
||||
tprogs-y += sock_example
|
||||
tprogs-y += fds_example
|
||||
tprogs-y += sockex1
|
||||
tprogs-y += sockex2
|
||||
tprogs-y += sockex3
|
||||
tprogs-y += tracex1
|
||||
tprogs-y += tracex2
|
||||
tprogs-y += tracex3
|
||||
tprogs-y += tracex4
|
||||
tprogs-y += tracex5
|
||||
tprogs-y += tracex6
|
||||
tprogs-y += tracex7
|
||||
tprogs-y += test_probe_write_user
|
||||
tprogs-y += trace_output
|
||||
tprogs-y += lathist
|
||||
tprogs-y += offwaketime
|
||||
tprogs-y += spintest
|
||||
tprogs-y += map_perf_test
|
||||
tprogs-y += test_overhead
|
||||
tprogs-y += test_cgrp2_array_pin
|
||||
tprogs-y += test_cgrp2_attach
|
||||
tprogs-y += test_cgrp2_sock
|
||||
tprogs-y += test_cgrp2_sock2
|
||||
tprogs-y += xdp1
|
||||
tprogs-y += xdp2
|
||||
tprogs-y += xdp_router_ipv4
|
||||
tprogs-y += test_current_task_under_cgroup
|
||||
tprogs-y += trace_event
|
||||
tprogs-y += sampleip
|
||||
tprogs-y += tc_l2_redirect
|
||||
tprogs-y += lwt_len_hist
|
||||
tprogs-y += xdp_tx_iptunnel
|
||||
tprogs-y += test_map_in_map
|
||||
tprogs-y += xdp_redirect_map
|
||||
tprogs-y += xdp_redirect_cpu
|
||||
tprogs-y += xdp_monitor
|
||||
tprogs-y += xdp_rxq_info
|
||||
tprogs-y += syscall_tp
|
||||
tprogs-y += cpustat
|
||||
tprogs-y += xdp_adjust_tail
|
||||
tprogs-y += xdpsock
|
||||
tprogs-y += xdp_fwd
|
||||
tprogs-y += task_fd_query
|
||||
tprogs-y += xdp_sample_pkts
|
||||
tprogs-y += ibumad
|
||||
tprogs-y += hbm
|
||||
|
||||
# Libbpf dependencies
|
||||
LIBBPF = $(TOOLS_PATH)/lib/bpf/libbpf.a
|
||||
@ -111,7 +109,7 @@ ibumad-objs := bpf_load.o ibumad_user.o $(TRACE_HELPERS)
|
||||
hbm-objs := bpf_load.o hbm.o $(CGROUP_HELPERS)
|
||||
|
||||
# Tell kbuild to always build the programs
|
||||
always := $(hostprogs-y)
|
||||
always := $(tprogs-y)
|
||||
always += sockex1_kern.o
|
||||
always += sockex2_kern.o
|
||||
always += sockex3_kern.o
|
||||
@ -145,7 +143,6 @@ always += sampleip_kern.o
|
||||
always += lwt_len_hist_kern.o
|
||||
always += xdp_tx_iptunnel_kern.o
|
||||
always += test_map_in_map_kern.o
|
||||
always += cookie_uid_helper_example.o
|
||||
always += tcp_synrto_kern.o
|
||||
always += tcp_rwnd_kern.o
|
||||
always += tcp_bufs_kern.o
|
||||
@ -171,20 +168,38 @@ always += ibumad_kern.o
|
||||
always += hbm_out_kern.o
|
||||
always += hbm_edt_kern.o
|
||||
|
||||
KBUILD_HOSTCFLAGS += -I$(objtree)/usr/include
|
||||
KBUILD_HOSTCFLAGS += -I$(srctree)/tools/lib/bpf/
|
||||
KBUILD_HOSTCFLAGS += -I$(srctree)/tools/testing/selftests/bpf/
|
||||
KBUILD_HOSTCFLAGS += -I$(srctree)/tools/lib/ -I$(srctree)/tools/include
|
||||
KBUILD_HOSTCFLAGS += -I$(srctree)/tools/perf
|
||||
ifeq ($(ARCH), arm)
|
||||
# Strip all except -D__LINUX_ARM_ARCH__ option needed to handle linux
|
||||
# headers when arm instruction set identification is requested.
|
||||
ARM_ARCH_SELECTOR := $(filter -D__LINUX_ARM_ARCH__%, $(KBUILD_CFLAGS))
|
||||
BPF_EXTRA_CFLAGS := $(ARM_ARCH_SELECTOR)
|
||||
TPROGS_CFLAGS += $(ARM_ARCH_SELECTOR)
|
||||
endif
|
||||
|
||||
HOSTCFLAGS_bpf_load.o += -I$(objtree)/usr/include -Wno-unused-variable
|
||||
TPROGS_CFLAGS += -Wall -O2
|
||||
TPROGS_CFLAGS += -Wmissing-prototypes
|
||||
TPROGS_CFLAGS += -Wstrict-prototypes
|
||||
|
||||
KBUILD_HOSTLDLIBS += $(LIBBPF) -lelf
|
||||
HOSTLDLIBS_tracex4 += -lrt
|
||||
HOSTLDLIBS_trace_output += -lrt
|
||||
HOSTLDLIBS_map_perf_test += -lrt
|
||||
HOSTLDLIBS_test_overhead += -lrt
|
||||
HOSTLDLIBS_xdpsock += -pthread
|
||||
TPROGS_CFLAGS += -I$(objtree)/usr/include
|
||||
TPROGS_CFLAGS += -I$(srctree)/tools/lib/bpf/
|
||||
TPROGS_CFLAGS += -I$(srctree)/tools/testing/selftests/bpf/
|
||||
TPROGS_CFLAGS += -I$(srctree)/tools/lib/
|
||||
TPROGS_CFLAGS += -I$(srctree)/tools/include
|
||||
TPROGS_CFLAGS += -I$(srctree)/tools/perf
|
||||
|
||||
ifdef SYSROOT
|
||||
TPROGS_CFLAGS += --sysroot=$(SYSROOT)
|
||||
TPROGS_LDFLAGS := -L$(SYSROOT)/usr/lib
|
||||
endif
|
||||
|
||||
TPROGCFLAGS_bpf_load.o += -Wno-unused-variable
|
||||
|
||||
TPROGS_LDLIBS += $(LIBBPF) -lelf
|
||||
TPROGLDLIBS_tracex4 += -lrt
|
||||
TPROGLDLIBS_trace_output += -lrt
|
||||
TPROGLDLIBS_map_perf_test += -lrt
|
||||
TPROGLDLIBS_test_overhead += -lrt
|
||||
TPROGLDLIBS_xdpsock += -pthread
|
||||
|
||||
# Allows pointing LLC/CLANG to a LLVM backend with bpf support, redefine on cmdline:
|
||||
# make samples/bpf/ LLC=~/git/llvm/build/bin/llc CLANG=~/git/llvm/build/bin/clang
|
||||
@ -195,15 +210,14 @@ BTF_PAHOLE ?= pahole
|
||||
|
||||
# Detect that we're cross compiling and use the cross compiler
|
||||
ifdef CROSS_COMPILE
|
||||
HOSTCC = $(CROSS_COMPILE)gcc
|
||||
CLANG_ARCH_ARGS = -target $(ARCH)
|
||||
CLANG_ARCH_ARGS = --target=$(notdir $(CROSS_COMPILE:%-=%))
|
||||
endif
|
||||
|
||||
# Don't evaluate probes and warnings if we need to run make recursively
|
||||
ifneq ($(src),)
|
||||
HDR_PROBE := $(shell echo "\#include <linux/types.h>\n struct list_head { int a; }; int main() { return 0; }" | \
|
||||
$(HOSTCC) $(KBUILD_HOSTCFLAGS) -x c - -o /dev/null 2>/dev/null && \
|
||||
echo okay)
|
||||
HDR_PROBE := $(shell printf "\#include <linux/types.h>\n struct list_head { int a; }; int main() { return 0; }" | \
|
||||
$(CC) $(TPROGS_CFLAGS) $(TPROGS_LDFLAGS) -x c - \
|
||||
-o /dev/null 2>/dev/null && echo okay)
|
||||
|
||||
ifeq ($(HDR_PROBE),)
|
||||
$(warning WARNING: Detected possible issues with include path.)
|
||||
@ -219,10 +233,10 @@ BTF_LLVM_PROBE := $(shell echo "int main() { return 0; }" | \
|
||||
/bin/rm -f ./llvm_btf_verify.o)
|
||||
|
||||
ifneq ($(BTF_LLVM_PROBE),)
|
||||
EXTRA_CFLAGS += -g
|
||||
BPF_EXTRA_CFLAGS += -g
|
||||
else
|
||||
ifneq ($(and $(BTF_LLC_PROBE),$(BTF_PAHOLE_PROBE),$(BTF_OBJCOPY_PROBE)),)
|
||||
EXTRA_CFLAGS += -g
|
||||
BPF_EXTRA_CFLAGS += -g
|
||||
LLC_FLAGS += -mattr=dwarfris
|
||||
DWARF2BTF = y
|
||||
endif
|
||||
@ -239,7 +253,8 @@ clean:
|
||||
|
||||
$(LIBBPF): FORCE
|
||||
# Fix up variables inherited from Kbuild that tools/ build system won't like
|
||||
$(MAKE) -C $(dir $@) RM='rm -rf' LDFLAGS= srctree=$(BPF_SAMPLES_PATH)/../../ O=
|
||||
$(MAKE) -C $(dir $@) RM='rm -rf' EXTRA_CFLAGS="$(TPROGS_CFLAGS)" \
|
||||
LDFLAGS=$(TPROGS_LDFLAGS) srctree=$(BPF_SAMPLES_PATH)/../../ O=
|
||||
|
||||
$(obj)/syscall_nrs.h: $(obj)/syscall_nrs.s FORCE
|
||||
$(call filechk,offsets,__SYSCALL_NRS_H__)
|
||||
@ -276,13 +291,16 @@ $(obj)/hbm_out_kern.o: $(src)/hbm.h $(src)/hbm_kern.h
|
||||
$(obj)/hbm.o: $(src)/hbm.h
|
||||
$(obj)/hbm_edt_kern.o: $(src)/hbm.h $(src)/hbm_kern.h
|
||||
|
||||
-include $(BPF_SAMPLES_PATH)/Makefile.target
|
||||
|
||||
# asm/sysreg.h - inline assembly used by it is incompatible with llvm.
|
||||
# But, there is no easy way to fix it, so just exclude it since it is
|
||||
# useless for BPF samples.
|
||||
$(obj)/%.o: $(src)/%.c
|
||||
@echo " CLANG-bpf " $@
|
||||
$(Q)$(CLANG) $(NOSTDINC_FLAGS) $(LINUXINCLUDE) $(EXTRA_CFLAGS) -I$(obj) \
|
||||
-I$(srctree)/tools/testing/selftests/bpf/ -I$(srctree)/tools/lib/bpf/ \
|
||||
$(Q)$(CLANG) $(NOSTDINC_FLAGS) $(LINUXINCLUDE) $(BPF_EXTRA_CFLAGS) \
|
||||
-I$(obj) -I$(srctree)/tools/testing/selftests/bpf/ \
|
||||
-I$(srctree)/tools/lib/bpf/ \
|
||||
-D__KERNEL__ -D__BPF_TRACING__ -Wno-unused-value -Wno-pointer-sign \
|
||||
-D__TARGET_ARCH_$(SRCARCH) -Wno-compare-distinct-pointer-types \
|
||||
-Wno-gnu-variable-sized-type-not-at-end \
|
||||
|
75
samples/bpf/Makefile.target
Normal file
75
samples/bpf/Makefile.target
Normal file
@ -0,0 +1,75 @@
|
||||
# SPDX-License-Identifier: GPL-2.0
|
||||
# ==========================================================================
|
||||
# Building binaries on the host system
|
||||
# Binaries are not used during the compilation of the kernel, and intended
|
||||
# to be build for target board, target board can be host of course. Added to
|
||||
# build binaries to run not on host system.
|
||||
#
|
||||
# Sample syntax
|
||||
# tprogs-y := xsk_example
|
||||
# Will compile xsk_example.c and create an executable named xsk_example
|
||||
#
|
||||
# tprogs-y := xdpsock
|
||||
# xdpsock-objs := xdpsock_1.o xdpsock_2.o
|
||||
# Will compile xdpsock_1.c and xdpsock_2.c, and then link the executable
|
||||
# xdpsock, based on xdpsock_1.o and xdpsock_2.o
|
||||
#
|
||||
# Derived from scripts/Makefile.host
|
||||
#
|
||||
__tprogs := $(sort $(tprogs-y))
|
||||
|
||||
# C code
|
||||
# Executables compiled from a single .c file
|
||||
tprog-csingle := $(foreach m,$(__tprogs), \
|
||||
$(if $($(m)-objs),,$(m)))
|
||||
|
||||
# C executables linked based on several .o files
|
||||
tprog-cmulti := $(foreach m,$(__tprogs),\
|
||||
$(if $($(m)-objs),$(m)))
|
||||
|
||||
# Object (.o) files compiled from .c files
|
||||
tprog-cobjs := $(sort $(foreach m,$(__tprogs),$($(m)-objs)))
|
||||
|
||||
tprog-csingle := $(addprefix $(obj)/,$(tprog-csingle))
|
||||
tprog-cmulti := $(addprefix $(obj)/,$(tprog-cmulti))
|
||||
tprog-cobjs := $(addprefix $(obj)/,$(tprog-cobjs))
|
||||
|
||||
#####
|
||||
# Handle options to gcc. Support building with separate output directory
|
||||
|
||||
_tprogc_flags = $(TPROGS_CFLAGS) \
|
||||
$(TPROGCFLAGS_$(basetarget).o)
|
||||
|
||||
# $(objtree)/$(obj) for including generated headers from checkin source files
|
||||
ifeq ($(KBUILD_EXTMOD),)
|
||||
ifdef building_out_of_srctree
|
||||
_tprogc_flags += -I $(objtree)/$(obj)
|
||||
endif
|
||||
endif
|
||||
|
||||
tprogc_flags = -Wp,-MD,$(depfile) $(_tprogc_flags)
|
||||
|
||||
# Create executable from a single .c file
|
||||
# tprog-csingle -> Executable
|
||||
quiet_cmd_tprog-csingle = CC $@
|
||||
cmd_tprog-csingle = $(CC) $(tprogc_flags) $(TPROGS_LDFLAGS) -o $@ $< \
|
||||
$(TPROGS_LDLIBS) $(TPROGLDLIBS_$(@F))
|
||||
$(tprog-csingle): $(obj)/%: $(src)/%.c FORCE
|
||||
$(call if_changed_dep,tprog-csingle)
|
||||
|
||||
# Link an executable based on list of .o files, all plain c
|
||||
# tprog-cmulti -> executable
|
||||
quiet_cmd_tprog-cmulti = LD $@
|
||||
cmd_tprog-cmulti = $(CC) $(tprogc_flags) $(TPROGS_LDFLAGS) -o $@ \
|
||||
$(addprefix $(obj)/,$($(@F)-objs)) \
|
||||
$(TPROGS_LDLIBS) $(TPROGLDLIBS_$(@F))
|
||||
$(tprog-cmulti): $(tprog-cobjs) FORCE
|
||||
$(call if_changed,tprog-cmulti)
|
||||
$(call multi_depend, $(tprog-cmulti), , -objs)
|
||||
|
||||
# Create .o file from a single .c file
|
||||
# tprog-cobjs -> .o
|
||||
quiet_cmd_tprog-cobjs = CC $@
|
||||
cmd_tprog-cobjs = $(CC) $(tprogc_flags) -c -o $@ $<
|
||||
$(tprog-cobjs): $(obj)/%.o: $(src)/%.c FORCE
|
||||
$(call if_changed_dep,tprog-cobjs)
|
@ -14,6 +14,20 @@ Compiling requires having installed:
|
||||
Note that LLVM's tool 'llc' must support target 'bpf', list version
|
||||
and supported targets with command: ``llc --version``
|
||||
|
||||
Clean and configuration
|
||||
-----------------------
|
||||
|
||||
It can be needed to clean tools, samples or kernel before trying new arch or
|
||||
after some changes (on demand)::
|
||||
|
||||
make -C tools clean
|
||||
make -C samples/bpf clean
|
||||
make clean
|
||||
|
||||
Configure kernel, defconfig for instance::
|
||||
|
||||
make defconfig
|
||||
|
||||
Kernel headers
|
||||
--------------
|
||||
|
||||
@ -68,9 +82,26 @@ It is also possible to point make to the newly compiled 'llc' or
|
||||
Cross compiling samples
|
||||
-----------------------
|
||||
In order to cross-compile, say for arm64 targets, export CROSS_COMPILE and ARCH
|
||||
environment variables before calling make. This will direct make to build
|
||||
samples for the cross target.
|
||||
environment variables before calling make. But do this before clean,
|
||||
cofiguration and header install steps described above. This will direct make to
|
||||
build samples for the cross target::
|
||||
|
||||
export ARCH=arm64
|
||||
export CROSS_COMPILE="aarch64-linux-gnu-"
|
||||
make samples/bpf/ LLC=~/git/llvm/build/bin/llc CLANG=~/git/llvm/build/bin/clang
|
||||
|
||||
Headers can be also installed on RFS of target board if need to keep them in
|
||||
sync (not necessarily and it creates a local "usr/include" directory also)::
|
||||
|
||||
make INSTALL_HDR_PATH=~/some_sysroot/usr headers_install
|
||||
|
||||
Pointing LLC and CLANG is not necessarily if it's installed on HOST and have
|
||||
in its targets appropriate arm64 arch (usually it has several arches).
|
||||
Build samples::
|
||||
|
||||
make samples/bpf/
|
||||
|
||||
Or build samples with SYSROOT if some header or library is absent in toolchain,
|
||||
say libelf, providing address to file system containing headers and libs,
|
||||
can be RFS of target board::
|
||||
|
||||
make samples/bpf/ SYSROOT=~/some_sysroot
|
||||
|
@ -52,7 +52,7 @@ ifndef VERBOSE
|
||||
endif
|
||||
|
||||
FEATURE_USER = .libbpf
|
||||
FEATURE_TESTS = libelf libelf-mmap bpf reallocarray cxx
|
||||
FEATURE_TESTS = libelf libelf-mmap bpf reallocarray
|
||||
FEATURE_DISPLAY = libelf bpf
|
||||
|
||||
INCLUDES = -I. -I$(srctree)/tools/include -I$(srctree)/tools/arch/$(ARCH)/include/uapi -I$(srctree)/tools/include/uapi
|
||||
@ -142,15 +142,7 @@ GLOBAL_SYM_COUNT = $(shell readelf -s --wide $(BPF_IN) | \
|
||||
VERSIONED_SYM_COUNT = $(shell readelf -s --wide $(OUTPUT)libbpf.so | \
|
||||
grep -Eo '[^ ]+@LIBBPF_' | cut -d@ -f1 | sort -u | wc -l)
|
||||
|
||||
CMD_TARGETS = $(LIB_TARGET) $(PC_FILE)
|
||||
|
||||
CXX_TEST_TARGET = $(OUTPUT)test_libbpf
|
||||
|
||||
ifeq ($(feature-cxx), 1)
|
||||
CMD_TARGETS += $(CXX_TEST_TARGET)
|
||||
endif
|
||||
|
||||
TARGETS = $(CMD_TARGETS)
|
||||
CMD_TARGETS = $(LIB_TARGET) $(PC_FILE) $(OUTPUT)test_libbpf
|
||||
|
||||
all: fixdep
|
||||
$(Q)$(MAKE) all_cmd
|
||||
@ -182,7 +174,8 @@ bpf_helper_defs.h: $(srctree)/include/uapi/linux/bpf.h
|
||||
$(OUTPUT)libbpf.so: $(OUTPUT)libbpf.so.$(LIBBPF_VERSION)
|
||||
|
||||
$(OUTPUT)libbpf.so.$(LIBBPF_VERSION): $(BPF_IN)
|
||||
$(QUIET_LINK)$(CC) --shared -Wl,-soname,libbpf.so.$(LIBBPF_MAJOR_VERSION) \
|
||||
$(QUIET_LINK)$(CC) $(LDFLAGS) \
|
||||
--shared -Wl,-soname,libbpf.so.$(LIBBPF_MAJOR_VERSION) \
|
||||
-Wl,--version-script=$(VERSION_SCRIPT) $^ -lelf -o $@
|
||||
@ln -sf $(@F) $(OUTPUT)libbpf.so
|
||||
@ln -sf $(@F) $(OUTPUT)libbpf.so.$(LIBBPF_MAJOR_VERSION)
|
||||
@ -190,8 +183,8 @@ $(OUTPUT)libbpf.so.$(LIBBPF_VERSION): $(BPF_IN)
|
||||
$(OUTPUT)libbpf.a: $(BPF_IN)
|
||||
$(QUIET_LINK)$(RM) $@; $(AR) rcs $@ $^
|
||||
|
||||
$(OUTPUT)test_libbpf: test_libbpf.cpp $(OUTPUT)libbpf.a
|
||||
$(QUIET_LINK)$(CXX) $(INCLUDES) $^ -lelf -o $@
|
||||
$(OUTPUT)test_libbpf: test_libbpf.c $(OUTPUT)libbpf.a
|
||||
$(QUIET_LINK)$(CC) $(CFLAGS) $(LDFLAGS) $(INCLUDES) $^ -lelf -o $@
|
||||
|
||||
$(OUTPUT)libbpf.pc:
|
||||
$(QUIET_GEN)sed -e "s|@PREFIX@|$(prefix)|" \
|
||||
@ -266,7 +259,7 @@ config-clean:
|
||||
$(Q)$(MAKE) -C $(srctree)/tools/build/feature/ clean >/dev/null
|
||||
|
||||
clean:
|
||||
$(call QUIET_CLEAN, libbpf) $(RM) $(TARGETS) $(CXX_TEST_TARGET) \
|
||||
$(call QUIET_CLEAN, libbpf) $(RM) $(CMD_TARGETS) \
|
||||
*.o *~ *.a *.so *.so.$(LIBBPF_MAJOR_VERSION) .*.d .*.cmd \
|
||||
*.pc LIBBPF-CFLAGS bpf_helper_defs.h
|
||||
$(call QUIET_CLEAN, core-gen) $(RM) $(OUTPUT)FEATURE-DUMP.libbpf
|
||||
|
@ -15,4 +15,6 @@ int main(int argc, char *argv[])
|
||||
|
||||
/* btf.h */
|
||||
btf__new(NULL, 0);
|
||||
|
||||
return 0;
|
||||
}
|
Loading…
Reference in New Issue
Block a user