blob: d88c012752394d3f5769850dd2c4d684ce661983 [file] [log] [blame]
Greg Kroah-Hartmanb2441312017-11-01 15:07:57 +01001# SPDX-License-Identifier: GPL-2.0
Jakub Kicinski787360f2018-05-14 22:35:04 -07002
3BPF_SAMPLES_PATH ?= $(abspath $(srctree)/$(src))
4TOOLS_PATH := $(BPF_SAMPLES_PATH)/../../tools
5
Alexei Starovoitov3c731eb2014-09-26 00:17:07 -07006# List of programs to build
Ivan Khoronzhuk1d97c6c2019-10-11 03:28:01 +03007tprogs-y := test_lru_dist
8tprogs-y += sock_example
9tprogs-y += fds_example
10tprogs-y += sockex1
11tprogs-y += sockex2
12tprogs-y += sockex3
13tprogs-y += tracex1
14tprogs-y += tracex2
15tprogs-y += tracex3
16tprogs-y += tracex4
17tprogs-y += tracex5
18tprogs-y += tracex6
19tprogs-y += tracex7
20tprogs-y += test_probe_write_user
21tprogs-y += trace_output
22tprogs-y += lathist
23tprogs-y += offwaketime
24tprogs-y += spintest
25tprogs-y += map_perf_test
26tprogs-y += test_overhead
27tprogs-y += test_cgrp2_array_pin
28tprogs-y += test_cgrp2_attach
29tprogs-y += test_cgrp2_sock
30tprogs-y += test_cgrp2_sock2
31tprogs-y += xdp1
32tprogs-y += xdp2
33tprogs-y += xdp_router_ipv4
34tprogs-y += test_current_task_under_cgroup
35tprogs-y += trace_event
36tprogs-y += sampleip
37tprogs-y += tc_l2_redirect
38tprogs-y += lwt_len_hist
39tprogs-y += xdp_tx_iptunnel
40tprogs-y += test_map_in_map
41tprogs-y += xdp_redirect_map
42tprogs-y += xdp_redirect_cpu
43tprogs-y += xdp_monitor
44tprogs-y += xdp_rxq_info
45tprogs-y += syscall_tp
46tprogs-y += cpustat
47tprogs-y += xdp_adjust_tail
48tprogs-y += xdpsock
49tprogs-y += xdp_fwd
50tprogs-y += task_fd_query
51tprogs-y += xdp_sample_pkts
52tprogs-y += ibumad
53tprogs-y += hbm
Alexei Starovoitov3c731eb2014-09-26 00:17:07 -070054
Joe Stringer43371c82016-12-14 14:43:39 -080055# Libbpf dependencies
Jakub Kicinski787360f2018-05-14 22:35:04 -070056LIBBPF = $(TOOLS_PATH)/lib/bpf/libbpf.a
57
Roman Gushchin9d1f1592017-11-05 08:15:33 -050058CGROUP_HELPERS := ../../tools/testing/selftests/bpf/cgroup_helpers.o
Yonghong Song28dbf862018-04-28 22:28:13 -070059TRACE_HELPERS := ../../tools/testing/selftests/bpf/trace_helpers.o
Joe Stringer43371c82016-12-14 14:43:39 -080060
Jakub Kicinski1a9b2682019-02-27 19:04:13 -080061fds_example-objs := fds_example.o
62sockex1-objs := sockex1_user.o
63sockex2-objs := sockex2_user.o
Jakub Kicinski0cc54db2018-05-14 22:35:05 -070064sockex3-objs := bpf_load.o sockex3_user.o
65tracex1-objs := bpf_load.o tracex1_user.o
66tracex2-objs := bpf_load.o tracex2_user.o
67tracex3-objs := bpf_load.o tracex3_user.o
68tracex4-objs := bpf_load.o tracex4_user.o
69tracex5-objs := bpf_load.o tracex5_user.o
70tracex6-objs := bpf_load.o tracex6_user.o
71tracex7-objs := bpf_load.o tracex7_user.o
Jakub Kicinski0cc54db2018-05-14 22:35:05 -070072test_probe_write_user-objs := bpf_load.o test_probe_write_user_user.o
73trace_output-objs := bpf_load.o trace_output_user.o $(TRACE_HELPERS)
74lathist-objs := bpf_load.o lathist_user.o
75offwaketime-objs := bpf_load.o offwaketime_user.o $(TRACE_HELPERS)
76spintest-objs := bpf_load.o spintest_user.o $(TRACE_HELPERS)
77map_perf_test-objs := bpf_load.o map_perf_test_user.o
78test_overhead-objs := bpf_load.o test_overhead_user.o
79test_cgrp2_array_pin-objs := test_cgrp2_array_pin.o
80test_cgrp2_attach-objs := test_cgrp2_attach.o
Jakub Kicinski0cc54db2018-05-14 22:35:05 -070081test_cgrp2_sock-objs := test_cgrp2_sock.o
82test_cgrp2_sock2-objs := bpf_load.o test_cgrp2_sock2.o
83xdp1-objs := xdp1_user.o
Brenden Blanco764cbcce2016-07-19 12:16:57 -070084# reuse xdp1 source intentionally
Jakub Kicinski0cc54db2018-05-14 22:35:05 -070085xdp2-objs := xdp1_user.o
Maciej Fijalkowskibbaf6022019-02-01 22:42:25 +010086xdp_router_ipv4-objs := xdp_router_ipv4_user.o
Jakub Kicinski0cc54db2018-05-14 22:35:05 -070087test_current_task_under_cgroup-objs := bpf_load.o $(CGROUP_HELPERS) \
Sargun Dhillon9e6e60e2016-08-12 08:57:04 -070088 test_current_task_under_cgroup_user.o
Jakub Kicinski0cc54db2018-05-14 22:35:05 -070089trace_event-objs := bpf_load.o trace_event_user.o $(TRACE_HELPERS)
90sampleip-objs := bpf_load.o sampleip_user.o $(TRACE_HELPERS)
91tc_l2_redirect-objs := bpf_load.o tc_l2_redirect_user.o
92lwt_len_hist-objs := bpf_load.o lwt_len_hist_user.o
Maciej Fijalkowskibbaf6022019-02-01 22:42:25 +010093xdp_tx_iptunnel-objs := xdp_tx_iptunnel_user.o
Jakub Kicinski0cc54db2018-05-14 22:35:05 -070094test_map_in_map-objs := bpf_load.o test_map_in_map_user.o
95per_socket_stats_example-objs := cookie_uid_helper_example.o
Maciej Fijalkowskibbaf6022019-02-01 22:42:25 +010096xdp_redirect-objs := xdp_redirect_user.o
97xdp_redirect_map-objs := xdp_redirect_map_user.o
Jakub Kicinski0cc54db2018-05-14 22:35:05 -070098xdp_redirect_cpu-objs := bpf_load.o xdp_redirect_cpu_user.o
99xdp_monitor-objs := bpf_load.o xdp_monitor_user.o
100xdp_rxq_info-objs := xdp_rxq_info_user.o
101syscall_tp-objs := bpf_load.o syscall_tp_user.o
102cpustat-objs := bpf_load.o cpustat_user.o
103xdp_adjust_tail-objs := xdp_adjust_tail_user.o
Jakub Kicinski67481822018-07-26 14:32:21 -0700104xdpsock-objs := xdpsock_user.o
Jakub Kicinskie1a40ef2018-07-26 14:32:20 -0700105xdp_fwd-objs := xdp_fwd_user.o
Yonghong Songecb96f72018-05-24 11:21:56 -0700106task_fd_query-objs := bpf_load.o task_fd_query_user.o $(TRACE_HELPERS)
Toke Høiland-Jørgensen1e54ad22018-06-25 14:25:02 +0200107xdp_sample_pkts-objs := xdp_sample_pkts_user.o $(TRACE_HELPERS)
Ira Weiny0ac01fe2019-03-19 14:11:49 -0700108ibumad-objs := bpf_load.o ibumad_user.o $(TRACE_HELPERS)
brakmoa1270fe2019-03-01 12:38:49 -0800109hbm-objs := bpf_load.o hbm.o $(CGROUP_HELPERS)
Alexei Starovoitov3c731eb2014-09-26 00:17:07 -0700110
111# Tell kbuild to always build the programs
Ivan Khoronzhuk1d97c6c2019-10-11 03:28:01 +0300112always := $(tprogs-y)
Alexei Starovoitova8085782014-12-01 15:06:38 -0800113always += sockex1_kern.o
Alexei Starovoitovfbe33102014-12-01 15:06:39 -0800114always += sockex2_kern.o
Alexei Starovoitov530b2c82015-05-19 16:59:06 -0700115always += sockex3_kern.o
Alexei Starovoitovb896c4f2015-03-25 12:49:23 -0700116always += tracex1_kern.o
Alexei Starovoitovd822a192015-03-25 12:49:24 -0700117always += tracex2_kern.o
Alexei Starovoitov5c7fc2d2015-03-25 12:49:25 -0700118always += tracex3_kern.o
Alexei Starovoitov9811e352015-03-25 12:49:26 -0700119always += tracex4_kern.o
Alexei Starovoitov5bacd782015-05-19 16:59:05 -0700120always += tracex5_kern.o
Kaixu Xia47efb302015-08-06 07:02:36 +0000121always += tracex6_kern.o
Josef Bacik965de872017-12-11 11:36:49 -0500122always += tracex7_kern.o
David Ahern554ae6e2016-12-01 08:48:08 -0800123always += sock_flags_kern.o
Sargun Dhilloncf9b1192016-07-25 05:55:02 -0700124always += test_probe_write_user_kern.o
Alexei Starovoitov39111692015-10-20 20:02:35 -0700125always += trace_output_kern.o
Alexei Starovoitov91bc48222015-04-01 17:12:13 -0700126always += tcbpf1_kern.o
Martin KaFai Lau90e02892016-11-09 15:36:34 -0800127always += tc_l2_redirect_kern.o
Daniel Wagner0fb11702015-06-19 16:00:44 +0200128always += lathist_kern.o
Alexei Starovoitova6ffe7b2016-02-17 19:58:59 -0800129always += offwaketime_kern.o
Alexei Starovoitov9d8b6122016-03-08 15:07:52 -0800130always += spintest_kern.o
Alexei Starovoitov26e90932016-03-08 15:07:54 -0800131always += map_perf_test_kern.o
Alexei Starovoitove3edfde2016-04-06 18:43:31 -0700132always += test_overhead_tp_kern.o
Alexei Starovoitov4662a4e2018-03-28 12:05:39 -0700133always += test_overhead_raw_tp_kern.o
Alexei Starovoitove3edfde2016-04-06 18:43:31 -0700134always += test_overhead_kprobe_kern.o
Alexei Starovoitov65d472f2016-05-05 19:49:14 -0700135always += parse_varlen.o parse_simple.o parse_ldabs.o
Martin KaFai Laua3f74612016-06-30 10:28:45 -0700136always += test_cgrp2_tc_kern.o
Brenden Blanco86af8b42016-07-19 12:16:51 -0700137always += xdp1_kern.o
Brenden Blanco764cbcce2016-07-19 12:16:57 -0700138always += xdp2_kern.o
Christina Jacob3e29cd02017-11-05 08:52:30 +0530139always += xdp_router_ipv4_kern.o
Sargun Dhillon9e6e60e2016-08-12 08:57:04 -0700140always += test_current_task_under_cgroup_kern.o
Alexei Starovoitov1c47910e2016-09-01 18:37:25 -0700141always += trace_event_kern.o
Brendan Gregg72874412016-09-01 18:37:26 -0700142always += sampleip_kern.o
Thomas Graff74599f2016-11-30 17:10:11 +0100143always += lwt_len_hist_kern.o
Martin KaFai Lau12d8bb62016-12-07 15:53:14 -0800144always += xdp_tx_iptunnel_kern.o
Martin KaFai Laufb30d4b2017-03-22 10:00:35 -0700145always += test_map_in_map_kern.o
Lawrence Brakmo61bc4d82017-06-30 20:02:43 -0700146always += tcp_synrto_kern.o
Lawrence Brakmoc4002962017-06-30 20:02:45 -0700147always += tcp_rwnd_kern.o
Lawrence Brakmod99253682017-06-30 20:02:48 -0700148always += tcp_bufs_kern.o
Lawrence Brakmobb56d442017-06-30 20:02:50 -0700149always += tcp_cong_kern.o
Lawrence Brakmo7bc62e22017-06-30 20:02:52 -0700150always += tcp_iw_kern.o
Lawrence Brakmo6c4a01b2017-06-30 20:02:54 -0700151always += tcp_clamp_kern.o
Lawrence Brakmoc8900632017-10-20 11:05:42 -0700152always += tcp_basertt_kern.o
Nikita V. Shirokovacb4ea92018-08-30 07:51:54 -0700153always += tcp_tos_reflect_kern.o
Stanislav Fomichev39533882019-07-02 09:14:02 -0700154always += tcp_dumpstats_kern.o
John Fastabend832622e2017-07-17 09:27:28 -0700155always += xdp_redirect_kern.o
John Fastabend9d6e0052017-07-17 09:30:25 -0700156always += xdp_redirect_map_kern.o
Jesper Dangaard Brouerfad39172017-10-16 12:19:49 +0200157always += xdp_redirect_cpu_kern.o
Jesper Dangaard Brouer3ffab542017-08-29 16:38:11 +0200158always += xdp_monitor_kern.o
Jesper Dangaard Brouer0fca9312018-01-03 11:26:19 +0100159always += xdp_rxq_info_kern.o
Jesper Dangaard Brouer36e04a22018-01-10 18:21:44 +0100160always += xdp2skb_meta_kern.o
Yonghong Song1da236b6b2017-08-04 16:00:10 -0700161always += syscall_tp_kern.o
Leo Yanc5350772018-02-26 09:19:12 +0800162always += cpustat_kern.o
Nikita V. Shirokovc6ffd1f2018-04-17 21:42:23 -0700163always += xdp_adjust_tail_kern.o
David Ahernfe616052018-05-09 20:34:27 -0700164always += xdp_fwd_kern.o
Yonghong Songecb96f72018-05-24 11:21:56 -0700165always += task_fd_query_kern.o
Toke Høiland-Jørgensen1e54ad22018-06-25 14:25:02 +0200166always += xdp_sample_pkts_kern.o
Ira Weiny0ac01fe2019-03-19 14:11:49 -0700167always += ibumad_kern.o
brakmo187d0732019-03-01 12:38:48 -0800168always += hbm_out_kern.o
brakmo71634d72019-07-02 15:09:52 -0700169always += hbm_edt_kern.o
Alexei Starovoitov3c731eb2014-09-26 00:17:07 -0700170
Ivan Khoronzhuk0e865ae2019-10-11 03:27:58 +0300171ifeq ($(ARCH), arm)
172# Strip all except -D__LINUX_ARM_ARCH__ option needed to handle linux
173# headers when arm instruction set identification is requested.
174ARM_ARCH_SELECTOR := $(filter -D__LINUX_ARM_ARCH__%, $(KBUILD_CFLAGS))
175BPF_EXTRA_CFLAGS := $(ARM_ARCH_SELECTOR)
Ivan Khoronzhuk1d97c6c2019-10-11 03:28:01 +0300176TPROGS_CFLAGS += $(ARM_ARCH_SELECTOR)
Ivan Khoronzhuk0e865ae2019-10-11 03:27:58 +0300177endif
178
Ivan Khoronzhuk10cb3d82019-10-11 03:28:02 +0300179TPROGS_CFLAGS += -Wall -O2
180TPROGS_CFLAGS += -Wmissing-prototypes
181TPROGS_CFLAGS += -Wstrict-prototypes
182
Ivan Khoronzhuk1d97c6c2019-10-11 03:28:01 +0300183TPROGS_CFLAGS += -I$(objtree)/usr/include
184TPROGS_CFLAGS += -I$(srctree)/tools/lib/bpf/
185TPROGS_CFLAGS += -I$(srctree)/tools/testing/selftests/bpf/
186TPROGS_CFLAGS += -I$(srctree)/tools/lib/
187TPROGS_CFLAGS += -I$(srctree)/tools/include
188TPROGS_CFLAGS += -I$(srctree)/tools/perf
David S. Miller14684b92019-11-09 11:04:37 -0800189TPROGS_CFLAGS += -DHAVE_ATTR_TEST=0
Ivan Khoronzhuk1d97c6c2019-10-11 03:28:01 +0300190
Ivan Khoronzhukb2327c12019-10-11 03:28:07 +0300191ifdef SYSROOT
192TPROGS_CFLAGS += --sysroot=$(SYSROOT)
193TPROGS_LDFLAGS := -L$(SYSROOT)/usr/lib
194endif
195
Ivan Khoronzhuk1d97c6c2019-10-11 03:28:01 +0300196TPROGCFLAGS_bpf_load.o += -Wno-unused-variable
197
198TPROGS_LDLIBS += $(LIBBPF) -lelf
199TPROGLDLIBS_tracex4 += -lrt
200TPROGLDLIBS_trace_output += -lrt
201TPROGLDLIBS_map_perf_test += -lrt
202TPROGLDLIBS_test_overhead += -lrt
203TPROGLDLIBS_xdpsock += -pthread
204
Jesper Dangaard Brouerbdefbbf2016-04-28 14:21:14 +0200205# Allows pointing LLC/CLANG to a LLVM backend with bpf support, redefine on cmdline:
206# make samples/bpf/ LLC=~/git/llvm/build/bin/llc CLANG=~/git/llvm/build/bin/clang
Jesper Dangaard Brouer6ccfba72016-04-28 14:20:53 +0200207LLC ?= llc
Jesper Dangaard Brouerbdefbbf2016-04-28 14:21:14 +0200208CLANG ?= clang
Taeung Song9778cfd2018-07-26 19:13:44 +0900209LLVM_OBJCOPY ?= llvm-objcopy
210BTF_PAHOLE ?= pahole
Jesper Dangaard Brouer6ccfba72016-04-28 14:20:53 +0200211
Joel Fernandes876e88e2017-09-20 09:11:57 -0700212# Detect that we're cross compiling and use the cross compiler
213ifdef CROSS_COMPILE
Ivan Khoronzhuk518c1342019-10-11 03:27:56 +0300214CLANG_ARCH_ARGS = --target=$(notdir $(CROSS_COMPILE:%-=%))
Joel Fernandes876e88e2017-09-20 09:11:57 -0700215endif
216
Jakub Kicinski0ed3cc42019-06-07 10:11:16 -0700217# Don't evaluate probes and warnings if we need to run make recursively
218ifneq ($(src),)
Ivan Khoronzhukcdd5b2d2019-10-11 03:27:54 +0300219HDR_PROBE := $(shell printf "\#include <linux/types.h>\n struct list_head { int a; }; int main() { return 0; }" | \
Ivan Khoronzhuka833eff2019-10-11 03:28:03 +0300220 $(CC) $(TPROGS_CFLAGS) $(TPROGS_LDFLAGS) -x c - \
221 -o /dev/null 2>/dev/null && echo okay)
Jakub Kicinski07c3bbd2019-06-05 16:47:22 -0700222
223ifeq ($(HDR_PROBE),)
224$(warning WARNING: Detected possible issues with include path.)
225$(warning WARNING: Please install kernel headers locally (make headers_install).)
226endif
227
Taeung Song9778cfd2018-07-26 19:13:44 +0900228BTF_LLC_PROBE := $(shell $(LLC) -march=bpf -mattr=help 2>&1 | grep dwarfris)
229BTF_PAHOLE_PROBE := $(shell $(BTF_PAHOLE) --help 2>&1 | grep BTF)
230BTF_OBJCOPY_PROBE := $(shell $(LLVM_OBJCOPY) --help 2>&1 | grep -i 'usage.*llvm')
Yonghong Song9ce6ae22018-11-19 15:29:17 -0800231BTF_LLVM_PROBE := $(shell echo "int main() { return 0; }" | \
232 $(CLANG) -target bpf -O2 -g -c -x c - -o ./llvm_btf_verify.o; \
233 readelf -S ./llvm_btf_verify.o | grep BTF; \
234 /bin/rm -f ./llvm_btf_verify.o)
Taeung Song9778cfd2018-07-26 19:13:44 +0900235
Yonghong Song9ce6ae22018-11-19 15:29:17 -0800236ifneq ($(BTF_LLVM_PROBE),)
Ivan Khoronzhuk2a560df2019-10-11 03:27:57 +0300237 BPF_EXTRA_CFLAGS += -g
Yonghong Song9ce6ae22018-11-19 15:29:17 -0800238else
Taeung Song9778cfd2018-07-26 19:13:44 +0900239ifneq ($(and $(BTF_LLC_PROBE),$(BTF_PAHOLE_PROBE),$(BTF_OBJCOPY_PROBE)),)
Ivan Khoronzhuk2a560df2019-10-11 03:27:57 +0300240 BPF_EXTRA_CFLAGS += -g
Taeung Song9778cfd2018-07-26 19:13:44 +0900241 LLC_FLAGS += -mattr=dwarfris
242 DWARF2BTF = y
243endif
Yonghong Song9ce6ae22018-11-19 15:29:17 -0800244endif
Jakub Kicinski0ed3cc42019-06-07 10:11:16 -0700245endif
Taeung Song9778cfd2018-07-26 19:13:44 +0900246
Jesper Dangaard Brouerb62a7962016-04-28 14:21:09 +0200247# Trick to allow make to be run from this directory
Jakub Kicinski787360f2018-05-14 22:35:04 -0700248all:
249 $(MAKE) -C ../../ $(CURDIR)/ BPF_SAMPLES_PATH=$(CURDIR)
Jesper Dangaard Brouerb62a7962016-04-28 14:21:09 +0200250
251clean:
Uwe Kleine-Könige19b7ce2016-11-22 09:30:26 +0100252 $(MAKE) -C ../../ M=$(CURDIR) clean
Jesper Dangaard Brouerb62a7962016-04-28 14:21:09 +0200253 @rm -f *~
254
Mickaël Salaünc25ef6a2018-01-26 01:39:30 +0100255$(LIBBPF): FORCE
Jakub Kicinski787360f2018-05-14 22:35:04 -0700256# Fix up variables inherited from Kbuild that tools/ build system won't like
Ivan Khoronzhukd8ceae92019-10-11 03:28:06 +0300257 $(MAKE) -C $(dir $@) RM='rm -rf' EXTRA_CFLAGS="$(TPROGS_CFLAGS)" \
258 LDFLAGS=$(TPROGS_LDFLAGS) srctree=$(BPF_SAMPLES_PATH)/../../ O=
Mickaël Salaünc25ef6a2018-01-26 01:39:30 +0100259
David Daney4b7190e2017-06-13 16:49:38 -0700260$(obj)/syscall_nrs.h: $(obj)/syscall_nrs.s FORCE
261 $(call filechk,offsets,__SYSCALL_NRS_H__)
262
Masahiro Yamada2c667d72018-12-22 18:50:34 +0900263targets += syscall_nrs.s
David Daney4b7190e2017-06-13 16:49:38 -0700264clean-files += syscall_nrs.h
265
266FORCE:
267
268
Jesper Dangaard Brouerbdefbbf2016-04-28 14:21:14 +0200269# Verify LLVM compiler tools are available and bpf target is supported by llc
270.PHONY: verify_cmds verify_target_bpf $(CLANG) $(LLC)
Jesper Dangaard Brouer7b01dd52016-04-28 14:20:58 +0200271
Jesper Dangaard Brouerbdefbbf2016-04-28 14:21:14 +0200272verify_cmds: $(CLANG) $(LLC)
273 @for TOOL in $^ ; do \
274 if ! (which -- "$${TOOL}" > /dev/null 2>&1); then \
275 echo "*** ERROR: Cannot find LLVM tool $${TOOL}" ;\
276 exit 1; \
277 else true; fi; \
278 done
Jesper Dangaard Brouer7b01dd52016-04-28 14:20:58 +0200279
Jesper Dangaard Brouerbdefbbf2016-04-28 14:21:14 +0200280verify_target_bpf: verify_cmds
Jesper Dangaard Brouer7b01dd52016-04-28 14:20:58 +0200281 @if ! (${LLC} -march=bpf -mattr=help > /dev/null 2>&1); then \
282 echo "*** ERROR: LLVM (${LLC}) does not support 'bpf' target" ;\
283 echo " NOTICE: LLVM version >= 3.7.1 required" ;\
284 exit 2; \
285 else true; fi
286
Jakub Kicinski787360f2018-05-14 22:35:04 -0700287$(BPF_SAMPLES_PATH)/*.c: verify_target_bpf $(LIBBPF)
288$(src)/*.c: verify_target_bpf $(LIBBPF)
Jesper Dangaard Brouer7b01dd52016-04-28 14:20:58 +0200289
David Daney4b7190e2017-06-13 16:49:38 -0700290$(obj)/tracex5_kern.o: $(obj)/syscall_nrs.h
brakmo187d0732019-03-01 12:38:48 -0800291$(obj)/hbm_out_kern.o: $(src)/hbm.h $(src)/hbm_kern.h
brakmoa1270fe2019-03-01 12:38:49 -0800292$(obj)/hbm.o: $(src)/hbm.h
brakmo71634d72019-07-02 15:09:52 -0700293$(obj)/hbm_edt_kern.o: $(src)/hbm.h $(src)/hbm_kern.h
David Daney4b7190e2017-06-13 16:49:38 -0700294
Ivan Khoronzhuk1d97c6c2019-10-11 03:28:01 +0300295-include $(BPF_SAMPLES_PATH)/Makefile.target
296
Naveen N. Rao128d1512016-04-04 22:31:33 +0530297# asm/sysreg.h - inline assembly used by it is incompatible with llvm.
298# But, there is no easy way to fix it, so just exclude it since it is
Yang Shi30b50aa2015-11-12 14:07:46 -0800299# useless for BPF samples.
Brenden Blancob88c06e2015-05-11 21:25:51 -0700300$(obj)/%.o: $(src)/%.c
Jakub Kicinski768759e2018-05-14 22:35:06 -0700301 @echo " CLANG-bpf " $@
Ivan Khoronzhuk2a560df2019-10-11 03:27:57 +0300302 $(Q)$(CLANG) $(NOSTDINC_FLAGS) $(LINUXINCLUDE) $(BPF_EXTRA_CFLAGS) \
303 -I$(obj) -I$(srctree)/tools/testing/selftests/bpf/ \
304 -I$(srctree)/tools/lib/bpf/ \
Alexei Starovoitovb1ae32d2018-05-13 12:32:22 -0700305 -D__KERNEL__ -D__BPF_TRACING__ -Wno-unused-value -Wno-pointer-sign \
Ilya Leoshkevich81f522f2019-07-15 11:11:03 +0200306 -D__TARGET_ARCH_$(SRCARCH) -Wno-compare-distinct-pointer-types \
Alexei Starovoitov69a9d092016-12-01 18:31:12 -0800307 -Wno-gnu-variable-sized-type-not-at-end \
308 -Wno-address-of-packed-member -Wno-tautological-compare \
Abhijit Ayarekar9db95832017-10-13 12:24:06 -0700309 -Wno-unknown-warning-option $(CLANG_ARCH_ARGS) \
Yonghong Song6bf3bbe2019-01-12 15:04:30 -0800310 -I$(srctree)/samples/bpf/ -include asm_goto_workaround.h \
Taeung Song9778cfd2018-07-26 19:13:44 +0900311 -O2 -emit-llvm -c $< -o -| $(LLC) -march=bpf $(LLC_FLAGS) -filetype=obj -o $@
312ifeq ($(DWARF2BTF),y)
313 $(BTF_PAHOLE) -J $@
314endif