Received: by 2002:a25:c593:0:0:0:0:0 with SMTP id v141csp5556723ybe; Tue, 10 Sep 2019 05:43:04 -0700 (PDT) X-Google-Smtp-Source: APXvYqz6qFGEwcrns2pkYochqWjci0ziDwl8Rg4aWA7G9vnVmNIhrkIqPei7TTxXylPNU0+UQPTZ X-Received: by 2002:a17:906:4cc3:: with SMTP id q3mr24818380ejt.127.1568119384754; Tue, 10 Sep 2019 05:43:04 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1568119384; cv=none; d=google.com; s=arc-20160816; b=uGhXFa4iMn/AB8wLNmerrH50HtObE19RbGSvWXhZvsCXHcgvNHcZaUXZLAk81EYfbU bUzcv6aoBkhGpfX+dG0XSzKuaz+qLHMfhgqWQLziv9ugDWg8noOSF81SmhE/JJhgkY0k /H+7TQ/vW0sP7mDAyHNlmVjSsf3OJMKXLLSkBk+55tYZjOzLXO87oeYCGWdBMHgFqJ17 M73rB+epM8RYQhkUBwAYZfXUSLWPwJCQclVWMftw8AS5rY7BpqnQ13RRva2yfMB5RsRw ZdsSg+j/wyaiBM7oaWAxI6XISMIT+yTjZeDhGsvCcwG59WvKEMj/V90bajvkGSOWp52+ xtPQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:dkim-signature; bh=IcR+D/TfWuQwurL66TOSsrqC7LoAB4pm/OhhtcjezUY=; b=cg0rilFylNWM3t1/rIPfdEWFqFq9iOC4gwycmkrMxugQeIw1pG2Rs5WebMi7/01M8X oiFdsZhavbnsUjx8Bcsa+WxMFiMnOiqRBaDsPegEZuhbeUcZb1NvAbRLe0cctNdltau5 ZJMhG3uZPOOhb6GhsGWZCHiPobb93bRhzeQPELzRoAINRYXdZUFyFwFT7On/zl+QUU43 wSPaLlgVq0NjFXS0BvRlTagSsVrfEnvGGErQzqXr/wHzcMx3n6xVqroCGGTgWa5jc3vl njpRmm1Rxv9eN/EsJlF0xSy5K8Qzx80/pAhZAH33GswNsKAujFsG9xWkgo8PRCOa+L0J 9pxQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=esLNerhV; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id e12si10335317edb.262.2019.09.10.05.42.40; Tue, 10 Sep 2019 05:43:04 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=esLNerhV; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2406240AbfIJKiw (ORCPT + 99 others); Tue, 10 Sep 2019 06:38:52 -0400 Received: from mail-lf1-f66.google.com ([209.85.167.66]:40628 "EHLO mail-lf1-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2436560AbfIJKiu (ORCPT ); Tue, 10 Sep 2019 06:38:50 -0400 Received: by mail-lf1-f66.google.com with SMTP id w18so1118498lfk.7 for ; Tue, 10 Sep 2019 03:38:48 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=IcR+D/TfWuQwurL66TOSsrqC7LoAB4pm/OhhtcjezUY=; b=esLNerhVdr5vtjvVHS8bWaix+dE3PWsOm6T6wTywoSK/3we/bCYyAzUb4Jdi1v49ZD oUlaahWQN+7ncBEoaAaphHNKdA58/hqNebCWaFXZpq8TWyMnL1WfYOE3TpHj4c5s7HLn kkrOAYp80qsQ9yv2YpiJrGvsMCHf9rwR2YMTOe3lyZCc1uAGo1OuR9Ye98T0xImsneWj ALWFkBiTKIColYZ/O4dw/ZLaPx2lQ0UD1KzrlP4p3HBZiRI3d/fTp3VD1ksM07RnqciR mSTaSkwGbOLGl/BkvE92ZHjqXpjhBgn7iBpEx1twTjneUgPJIQqhxczZmU8l8UtuL3cO /ccw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=IcR+D/TfWuQwurL66TOSsrqC7LoAB4pm/OhhtcjezUY=; b=ddViB86fM6tr8OLkJK4ZJIQ1GGb+pNegW/uauafiLlHTDoJqh493EB7mXtLA+myNho 9LXt3Fmowi9h6IWmqUlvg8ikRY8zovbPMMGPE/u9T58+UJM9Mmc/XjH1MFDeR19S/r+h ZWQ/sePNzS5uwI29BotcpRrUHKU9Ih2YU17Ue/t3x9Zv1oVQwIvVV8FadEJWtvCu/N3F Gffeg165WHSCVOaPUcLipTyfTfTxlgNv5L3yl4f8gR9wapp++X8Ph++2E8S9Ah5DSsxN vcroxPClcCGZQrVyzs1VsGjjifXYunxsqwxNsVZ6C4pWQzjG3KJ/6NIgVD8Rg8sdyiNb Qfmw== X-Gm-Message-State: APjAAAUI1eh3KDqZnNlA81jKm6FwgPdncdosz+krfofl8tMVsP7/oqys 8c0a8o2No17Cfb5Jhof4CtjDQA== X-Received: by 2002:a19:5f55:: with SMTP id a21mr20651781lfj.56.1568111927326; Tue, 10 Sep 2019 03:38:47 -0700 (PDT) Received: from localhost.localdomain (168-200-94-178.pool.ukrtel.net. [178.94.200.168]) by smtp.gmail.com with ESMTPSA id g5sm4005563lfh.2.2019.09.10.03.38.46 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 10 Sep 2019 03:38:46 -0700 (PDT) From: Ivan Khoronzhuk To: ast@kernel.org, daniel@iogearbox.net, yhs@fb.com, davem@davemloft.net, jakub.kicinski@netronome.com, hawk@kernel.org, john.fastabend@gmail.com Cc: linux-kernel@vger.kernel.org, netdev@vger.kernel.org, bpf@vger.kernel.org, clang-built-linux@googlegroups.com, Ivan Khoronzhuk Subject: [PATCH bpf-next 08/11] samples: bpf: makefile: base progs build on makefile.progs Date: Tue, 10 Sep 2019 13:38:27 +0300 Message-Id: <20190910103830.20794-9-ivan.khoronzhuk@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190910103830.20794-1-ivan.khoronzhuk@linaro.org> References: <20190910103830.20794-1-ivan.khoronzhuk@linaro.org> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org The main reason for that - HOSTCC and CC have different aims. It was tested for arm cross compilation, based on linaro toolchain, but should work for others. In order to split cross compilation (CC) with host build (HOSTCC), lets base bpf samples on Makefile.progs. It allows to cross-compile samples/bpf progs with CC while auxialry tools running on host built with HOSTCC. Signed-off-by: Ivan Khoronzhuk --- samples/bpf/Makefile | 138 +++++++++++++++++++++++-------------------- 1 file changed, 73 insertions(+), 65 deletions(-) diff --git a/samples/bpf/Makefile b/samples/bpf/Makefile index f5dbf3d0c5f3..625a71f2e9d2 100644 --- a/samples/bpf/Makefile +++ b/samples/bpf/Makefile @@ -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 +progs-y := test_lru_dist +progs-y += sock_example +progs-y += fds_example +progs-y += sockex1 +progs-y += sockex2 +progs-y += sockex3 +progs-y += tracex1 +progs-y += tracex2 +progs-y += tracex3 +progs-y += tracex4 +progs-y += tracex5 +progs-y += tracex6 +progs-y += tracex7 +progs-y += test_probe_write_user +progs-y += trace_output +progs-y += lathist +progs-y += offwaketime +progs-y += spintest +progs-y += map_perf_test +progs-y += test_overhead +progs-y += test_cgrp2_array_pin +progs-y += test_cgrp2_attach +progs-y += test_cgrp2_sock +progs-y += test_cgrp2_sock2 +progs-y += xdp1 +progs-y += xdp2 +progs-y += xdp_router_ipv4 +progs-y += test_current_task_under_cgroup +progs-y += trace_event +progs-y += sampleip +progs-y += tc_l2_redirect +progs-y += lwt_len_hist +progs-y += xdp_tx_iptunnel +progs-y += test_map_in_map +progs-y += xdp_redirect_map +progs-y += xdp_redirect_cpu +progs-y += xdp_monitor +progs-y += xdp_rxq_info +progs-y += syscall_tp +progs-y += cpustat +progs-y += xdp_adjust_tail +progs-y += xdpsock +progs-y += xdp_fwd +progs-y += task_fd_query +progs-y += xdp_sample_pkts +progs-y += ibumad +progs-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 := $(progs-y) always += sockex1_kern.o always += sockex2_kern.o always += sockex3_kern.o @@ -170,21 +168,6 @@ 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 - -HOSTCFLAGS_bpf_load.o += -Wno-unused-variable - -KBUILD_HOSTLDLIBS += $(LIBBPF) -lelf -HOSTLDLIBS_tracex4 += -lrt -HOSTLDLIBS_trace_output += -lrt -HOSTLDLIBS_map_perf_test += -lrt -HOSTLDLIBS_test_overhead += -lrt -HOSTLDLIBS_xdpsock += -pthread - # Strip all expet -D options needed to handle linux headers # for arm it's __LINUX_ARM_ARCH__ and potentially others fork vars D_OPTIONS = $(shell echo "$(KBUILD_CFLAGS) " | sed 's/[[:blank:]]/\n/g' | \ @@ -194,6 +177,29 @@ ifeq ($(ARCH), arm) CLANG_EXTRA_CFLAGS := $(D_OPTIONS) endif +ccflags-y += -I$(objtree)/usr/include +ccflags-y += -I$(srctree)/tools/lib/bpf/ +ccflags-y += -I$(srctree)/tools/testing/selftests/bpf/ +ccflags-y += -I$(srctree)/tools/lib/ +ccflags-y += -I$(srctree)/tools/include +ccflags-y += -I$(srctree)/tools/perf +ccflags-y += $(D_OPTIONS) +ccflags-y += -Wall +ccflags-y += -fomit-frame-pointer +ccflags-y += -Wmissing-prototypes +ccflags-y += -Wstrict-prototypes + +PROGS_CFLAGS := $(ccflags-y) + +PROGCFLAGS_bpf_load.o += -Wno-unused-variable + +PROGS_LDLIBS := $(LIBBPF) -lelf +PROGLDLIBS_tracex4 += -lrt +PROGLDLIBS_trace_output += -lrt +PROGLDLIBS_map_perf_test += -lrt +PROGLDLIBS_test_overhead += -lrt +PROGLDLIBS_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 LLC ?= llc @@ -284,6 +290,8 @@ $(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.prog + # 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. -- 2.17.1