From patchwork Fri Oct 11 00:28:01 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ivan Khoronzhuk X-Patchwork-Id: 175896 Delivered-To: patch@linaro.org Received: by 2002:a92:7e96:0:0:0:0:0 with SMTP id q22csp42128ill; Thu, 10 Oct 2019 17:29:22 -0700 (PDT) X-Google-Smtp-Source: APXvYqz3S1lNG3Wn3d9nauNhriSqeNqI2o0PMii7K59BiPuD53Zh/qhqUcUV53d2jMI+vAkG+fNk X-Received: by 2002:a17:906:e89:: with SMTP id p9mr10823688ejf.95.1570753762674; Thu, 10 Oct 2019 17:29:22 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1570753762; cv=none; d=google.com; s=arc-20160816; b=IVy/rpY3R3Nu/hTX5cmdPLYFXS95VlCXRDT8Mxs5/8IeJ4rV9Zw8GP5ak6ORIjwF8V Qw07h5KoimoamvqP4LgzpKR6MXCu7+LgGf+kIubRAut3AXTu5IWt6BiyGR3lpxgD6MWM PrLr6VQhrKDTyLdHGFuIX0/h4VDL27Avtmu2+BJ5T9lshe57q5B2H2/LVW2y99WxpS6s ylRORi8iz9TRyfcWoqIebyzmlHhh3lVn6aQkOnSBGH8mxVQ0+iGoZEDFsb2Wi3+VQ899 YFY4dDYW3xBCFIj6QEwJuTtHlAdKXsoYKkcWCC0OoTOClAsmjhUzEaSka/S5Ma/w+epR 9yRQ== 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=M7M9P1nOh5u0u0U5RBRymVMGVBKZgCwkvUp/NKJyprc=; b=AeI8xjeIAoZ6XQOpgskjS+Nyh5zyxbI5afjugoUp4SNtDaAw9IrWCBB3Bjx8lxU8dh vxl4+xFj3aeU8Fd6lLx1JAYJOwDVvRmlcwTE2WF80bLLLWsH6/TYw0tAJFPVo5kRIjvh bLG+mkYEKTIBUvsD9jQCQYrbR4M3afcJI2sy8iivL0noP3x5LB32hMLHyojcRZz+LFtt GV9Agyb0keRYQlihuFBI2vowEaWVAg7KRVLO70d20vHRCANnMqXpyYGk3mLugeOFrA+/ SlaVFT7oiYJ8Ir0LrJ9fHOBZnXtH7rgEgq9102Vls4OgIRBMnZFmF2m385MYiEppZnZI qHOQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=ibYg0paF; 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 gz11si4336801ejb.341.2019.10.10.17.29.22; Thu, 10 Oct 2019 17:29:22 -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=ibYg0paF; 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 S1727953AbfJKA3V (ORCPT + 22 others); Thu, 10 Oct 2019 20:29:21 -0400 Received: from mail-lj1-f196.google.com ([209.85.208.196]:34295 "EHLO mail-lj1-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727677AbfJKA2f (ORCPT ); Thu, 10 Oct 2019 20:28:35 -0400 Received: by mail-lj1-f196.google.com with SMTP id j19so8070466lja.1 for ; Thu, 10 Oct 2019 17:28:32 -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=M7M9P1nOh5u0u0U5RBRymVMGVBKZgCwkvUp/NKJyprc=; b=ibYg0paFoKo1uWW2ZohFNjD1dit5TC7SSo9UxWFEhTZuMRWCAZYERaHiqsx5GbMMSt JPpuMpWPXyK5ARUbSM2PyJ0BbnRWXAMy+sn/LVb7cfbhfaSTnnFZWnpEzhruB9aUqVMx 84Rg/UsjnI18+4zlOoUlu2wGLESMn2ADGtIHOzPrYSWQjTyhSQ9PzH+2viAhYJEAtnKL l1K9/Bz+aOCQRpd18IecoNgKhpNlsaetrRdfB9E3rcJwxxnW2OS4Kt65Cv+SlBF2s74V xHzn33MZujh9yUTsypo6q2ADqX3EhMX/t1Z8YcC8CiEj1dw9Dw2yvaguJbj6DvVAFeou SJlQ== 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=M7M9P1nOh5u0u0U5RBRymVMGVBKZgCwkvUp/NKJyprc=; b=omvXKDHCe0ecVKmrkHcn6y6gabh4xXTEndfLtzxR+ODFdFuaG0cGus0trvy7jpGBn1 FVVlWNAN306jzwxcyXlpOiqd9MB6Yj+zuhdIVk1835OAgI0eKAm2GHlP+8NM2mdUduMF P0pO/u/DUCxYtPrmjKd8aPA+nxRW8W/0nKAoCoPY6fH3Njr6daIYLFVUpi9M9iOgbv+X 2G6mDU/hO5pVxLzrqN/OZdgqYf0TZ/r4gEThW98zhXUQhysCrr0Wpjc4+QH9jvexYrN2 SyH/JNrt8XMEwPouJ2TSJmnDWV0FDJzs971iHmL5S8O7Vh5aoCu80X/tUN2opAChFUPH Q4qw== X-Gm-Message-State: APjAAAU+BcmiIZe2EsTXmJR0EyRmN7r+8vemXQw0DsfCuUySnHL15HF4 DrdOXcLQTp/+KVOup0rFtIo1Ug== X-Received: by 2002:a2e:a0c9:: with SMTP id f9mr7869876ljm.77.1570753711744; Thu, 10 Oct 2019 17:28:31 -0700 (PDT) Received: from localhost.localdomain (88-201-94-178.pool.ukrtel.net. [178.94.201.88]) by smtp.gmail.com with ESMTPSA id 126sm2367010lfh.45.2019.10.10.17.28.30 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 10 Oct 2019 17:28:31 -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, ilias.apalodimas@linaro.org, sergei.shtylyov@cogentembedded.com, Ivan Khoronzhuk Subject: [PATCH v5 bpf-next 08/15] samples/bpf: base target programs rules on Makefile.target Date: Fri, 11 Oct 2019 03:28:01 +0300 Message-Id: <20191011002808.28206-9-ivan.khoronzhuk@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20191011002808.28206-1-ivan.khoronzhuk@linaro.org> References: <20191011002808.28206-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. HOSTCC is used to build programs running on host, that can cross-comple target programs with CC. It was tested for arm and arm64 cross compilation, based on linaro toolchain, but should work for others. So, in order to split cross compilation (CC) with host build (HOSTCC), lets base samples on Makefile.target. It allows to cross-compile samples/bpf programs with CC while auxialry tools running on host built with HOSTCC. Signed-off-by: Ivan Khoronzhuk --- samples/bpf/Makefile | 135 ++++++++++++++++++++++--------------------- 1 file changed, 69 insertions(+), 66 deletions(-) -- 2.17.1 diff --git a/samples/bpf/Makefile b/samples/bpf/Makefile index bb2d976e824e..91bfb421c278 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 +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 @@ -170,29 +168,32 @@ 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 - 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) -KBUILD_HOSTCFLAGS += $(ARM_ARCH_SELECTOR) +TPROGS_CFLAGS += $(ARM_ARCH_SELECTOR) endif +TPROGS_LDLIBS := $(KBUILD_HOSTLDLIBS) +TPROGS_CFLAGS += $(KBUILD_HOSTCFLAGS) $(HOST_EXTRACFLAGS) +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 + +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 LLC ?= llc @@ -283,6 +284,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.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.