From patchwork Wed Sep 4 21:22:07 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ivan Khoronzhuk X-Patchwork-Id: 173079 Delivered-To: patch@linaro.org Received: by 2002:a05:6e02:ce:0:0:0:0 with SMTP id r14csp455167ilq; Wed, 4 Sep 2019 14:23:33 -0700 (PDT) X-Google-Smtp-Source: APXvYqwzCDz7qqRDBxCv0V6GLKpusHx13mzcoqv3LiJaaNDFMcZtXHD6LvbgkraPTCYuXOACGJbn X-Received: by 2002:a63:4522:: with SMTP id s34mr168987pga.362.1567632213252; Wed, 04 Sep 2019 14:23:33 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1567632213; cv=none; d=google.com; s=arc-20160816; b=hyn0IPsHV/cDeJc7WerUGCsZJPLY5M5s6RnnxNfLxQbkfPcteUo6sOOzfY2G8dIgO7 6GTZmwJuvgqeE4/EtTeB8R1T7wQWDPDuFd4fmZ9EXOjLO0Vcg8y6h/RNN86btvuDNIZn +SHt3di5P70+4hcRYYcFZGda8xHcV3hsQd6v7NQeUKSnRoD0eZYEkDe8NOlD/tZ1bxRi qdMIOsD3F+8Lg+Cu9fTjU8iPC4cE0jz272ZVJbH/q8d29+PGFS8+Bxv2vX6gI21pV36W KjR1AgPwo1TWc6WF3byeLKWeHgfBX2pKbYouYk3Nku/w3tO65cmde2ntzmn323Zsr49I zcLg== 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=yAjuHlaJV4iM+XkUvTeUDNJ1TAXGjdj3xJMvNO0S43o=; b=Ap5JqDaVdlJF7qJrOayUs5n0z/YEoYiKRaP8gHrX10vCy+07CAmYkE0CF0otGHSVEC ZnGzYpgkivF2HfpxW5ZKzO7xa7pR64Gov4JJ4MRejQn+h89rrN4gC91WdJrWBp3Km1FD duy8Zft6xI/mS51sR1Sn6r22n+Q0mZUImS7F7+b70vH84KJ9eDiUAn0sTWZugYvNS5ND 1wtrTC2JCu+sLeZA7k0nc2cBSlyv8wnueboSGr3eETx6TB8gQTrxfUflsJMiPtTJUhki MJc5fH1FESIkSbBSGAagNmitPzybIsm7G8My38g8m7cvfJ1W0s5sWnuWpECar3kq+/05 Oixg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=Cyv0J+ys; 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 g4si17759609pgf.383.2019.09.04.14.23.33; Wed, 04 Sep 2019 14:23:33 -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=Cyv0J+ys; 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 S1730842AbfIDVXc (ORCPT + 28 others); Wed, 4 Sep 2019 17:23:32 -0400 Received: from mail-lj1-f194.google.com ([209.85.208.194]:38389 "EHLO mail-lj1-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730273AbfIDVXH (ORCPT ); Wed, 4 Sep 2019 17:23:07 -0400 Received: by mail-lj1-f194.google.com with SMTP id h3so194422ljb.5 for ; Wed, 04 Sep 2019 14:23:05 -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=yAjuHlaJV4iM+XkUvTeUDNJ1TAXGjdj3xJMvNO0S43o=; b=Cyv0J+ysGE8GlcBy84R0TU6rZdMLzrvRQiwpquEiozDeaAQQQbYdykncSxj9SDvUie 8cgkYnKiR0ReAyi40NULGieV75yTwmLbqtUC8erbl75yzlcUtht7eSCMcD96oSjQ6M48 na1DMKbDpuTpTnG6pBKnr8wpjHOb3yRIBcWZofhCezWk3TBniFS5nn7vx0YuyOh6Lmdh HWKQEzLvfpoT2NyKmWajaXus8qX7m3kiia7NxEwBexwDarrjZLHJ3aFVDEsLsVgZRvb9 Ba6Q8Da00IG4GVsd36zqBgKddkHbNRYPDGnrTw0kpAnEYfpgEDkKlGd7hMCJzVM7iMuK Jj8w== 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=yAjuHlaJV4iM+XkUvTeUDNJ1TAXGjdj3xJMvNO0S43o=; b=oZejzdDjS/AgENo20cvd4SscjZV8en2PfpeRno9nLB6cwo+8I/+TmaCKkcmXfz46r0 cF/QCeNU9DEEd5C3yxeu9htV5xGoLb0e3qLPABO9zHJ3OawAfoP197+NcJiOpJuPaq2y +GrfRqtGDTnXD3UWiSfBD2Zn9J8eJ/VMS103AhZmb1BUF82PeRcr3YKRVRUdx9sONtml 4fe5asG+Gg5IpR+pxd8HRvyXGaN/bDDh3WP027fJpUe/HtiZ2FzXfzy5U+hwhUxbOA5w IDk6pVmSeloFmcLGKmFgamLfJM8urd06vUAISn48GTCqosoxtmWQWi0Fqb3C4Qlfqqqs LAYg== X-Gm-Message-State: APjAAAVNqnsBec1qCsjCBZaCg7tcqr3MEVlEexFevBUBGAumQkzAj5dT D78Xn75xvSbapUlG916VK6AKGw== X-Received: by 2002:a05:651c:1ba:: with SMTP id c26mr4261123ljn.154.1567632184814; Wed, 04 Sep 2019 14:23:04 -0700 (PDT) Received: from localhost.localdomain (168-200-94-178.pool.ukrtel.net. [178.94.200.168]) by smtp.gmail.com with ESMTPSA id s8sm3540836ljd.94.2019.09.04.14.23.03 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 04 Sep 2019 14:23:04 -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 3/8] libbpf: Makefile: add C/CXX/LDFLAGS to libbpf.so and test_libpf targets Date: Thu, 5 Sep 2019 00:22:07 +0300 Message-Id: <20190904212212.13052-4-ivan.khoronzhuk@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190904212212.13052-1-ivan.khoronzhuk@linaro.org> References: <20190904212212.13052-1-ivan.khoronzhuk@linaro.org> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org In case of LDFLAGS and EXTRA_CC flags there is no way to pass them correctly to build command, for instance when --sysroot is used or external libraries are used, like -lelf. In follow up patches this is used for samples/bpf cross-compiling getting elf lib from sysroot. Signed-off-by: Ivan Khoronzhuk --- tools/lib/bpf/Makefile | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) -- 2.17.1 diff --git a/tools/lib/bpf/Makefile b/tools/lib/bpf/Makefile index c6f94cffe06e..bccfa556ef4e 100644 --- a/tools/lib/bpf/Makefile +++ b/tools/lib/bpf/Makefile @@ -94,6 +94,10 @@ else CFLAGS := -g -Wall endif +ifdef EXTRA_CXXFLAGS + CXXFLAGS := $(EXTRA_CXXFLAGS) +endif + ifeq ($(feature-libelf-mmap), 1) override CFLAGS += -DHAVE_LIBELF_MMAP_SUPPORT endif @@ -176,8 +180,9 @@ $(BPF_IN): force elfdep bpfdep $(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) \ - -Wl,--version-script=$(VERSION_SCRIPT) $^ -lelf -o $@ + $(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) @@ -185,7 +190,7 @@ $(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 $@ + $(QUIET_LINK)$(CXX) $(CXXFLAGS) $(LDFLAGS) $(INCLUDES) $^ -lelf -o $@ $(OUTPUT)libbpf.pc: $(QUIET_GEN)sed -e "s|@PREFIX@|$(prefix)|" \ From patchwork Wed Sep 4 21:22:08 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ivan Khoronzhuk X-Patchwork-Id: 173074 Delivered-To: patch@linaro.org Received: by 2002:a05:6e02:ce:0:0:0:0 with SMTP id r14csp454796ilq; Wed, 4 Sep 2019 14:23:10 -0700 (PDT) X-Google-Smtp-Source: APXvYqxf1GQY0jU6MW+n6Rqi9e3MvuDJ8FTgh1heHOtOc/0kyLmvM3wNlE/998F2LnWdJPz0JfgX X-Received: by 2002:a63:205f:: with SMTP id r31mr158227pgm.159.1567632190300; Wed, 04 Sep 2019 14:23:10 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1567632190; cv=none; d=google.com; s=arc-20160816; b=RhSDRoec6vFZle5iC4kd5jvJ15TzJmTxO/v+Ih/dpJLPKsRFxcnbUBQk1Ni16hUFgJ w62LSZrPlSKkVMgXQ9Wd5Cvy6PQxZu9gk/JncgFKuTSwwh0tWqlvb0kdsKVlnEj719iY bofMqI9n6C0Qsci79bkNwgJFGxy0Ye7mQRMUwI2p/ZBIES0cjsoIBzyaK3cifUBUR8Za veyM9yLxPDXmp3HpuLOSd3dWhthh+gfovJm71jrktZP7zy26IbxxE8EoIFGdm8B8jo8p 0ZoaKpw0Fn5595ZRjYhw7qFszkFRuAFRL0NMWG67EACyW1FwG+M0NqtTgMd0cbjDY/9K Qzcw== 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=Jcr7utRE+skJcsLIDmCcqhAtcA7yd+FAfx8VSIjlEN0=; b=IMoH5uD0cgCDgTrCwMvMIDX+uc4cgm6aPeAn8Pm3L1uSlirPKVn/MnvESB8k+PNoC1 kD2lTtn1xXRQ608GDPs/YyMLqD7BNJDejMUATFvKzwh0JB9+/uiTsekk1Vv10UiluoFa A/QpEB26e8OBRM04ISbCFPMoNHr1pidUCpez10jpvnXGtpWVak9ZNHRLQE9YX8EcelDh DC3+x6QPlqsMFp18KBCrmQ1T3IncpHinyD9RI69/t50R3DJ9gWp7PbUTh2/2uL31PdLm V5MKpDq9Tcedgjc9+vGWC3+Euf+OvvTIxGS7nZNZmcZVE2Um8xh+THEJvSk8qv+AxsNF tzZw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=ABJbZSLC; 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 u8si206860pjy.20.2019.09.04.14.23.10; Wed, 04 Sep 2019 14:23:10 -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=ABJbZSLC; 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 S1730541AbfIDVXJ (ORCPT + 28 others); Wed, 4 Sep 2019 17:23:09 -0400 Received: from mail-lj1-f194.google.com ([209.85.208.194]:40330 "EHLO mail-lj1-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730404AbfIDVXI (ORCPT ); Wed, 4 Sep 2019 17:23:08 -0400 Received: by mail-lj1-f194.google.com with SMTP id 7so181731ljw.7 for ; Wed, 04 Sep 2019 14:23:06 -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=Jcr7utRE+skJcsLIDmCcqhAtcA7yd+FAfx8VSIjlEN0=; b=ABJbZSLCV3FsQTMEMvdQFXH1D6yKF8jjS3/RsTHVZzVIkAvo/W1a9b9X01mzy8erDf IvqzyVfDgOZy32aa2l5oCtncvHQ6pMbPDxg7JN2j46uWoAF42oXFeCw9S7iXZ3TCsDU7 bXlTQlfFkgg8VgBDXwIJy5jEQ0IpJoX1rT+fT8L3uKAjbYVAbZx8BJhUff53hbdBvUil 4ImdVopvHM5krnUPckUJAQOEh8YvcljPij/nQuBCc39DZ9KGfce2McYBf7MWkJe1ieJm DCHDm8Q5yTXSRrFzvxF7e4WBVf0/ob1Bhcsx52IZEldzSy51EfyGwBs/8oSuQ/oTYIPU 9AlQ== 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=Jcr7utRE+skJcsLIDmCcqhAtcA7yd+FAfx8VSIjlEN0=; b=j1+nycbZbZ73nVJFe9wulsRg8mi89JMgZ41VlqalCTMARVZG+FmwCPLGTXzTXK1LzJ g94IMsEqxHPESadxK7bT7s2vcKXhZ50W+4ruOUHcKyXuevDQylQXAtgJFDzEb0EvlYJJ 6rzA5Wqbog/uVabGr77gaEGufwg2uI7bG2BwQ42UpXqMVpZN2lAUf1MQTWG0Lp6qG03K I0PCZmVQxrKcxT8wUTZlJr+Znf6yC4bde/n8RHOu/n39fFDfIXVwcKY7fizz91QB2kLA YczICHhAypPvj1chvEa1LGWy1rDw9wNbznJdD9e1fwzMPOntjh/oVr6JCV4Uk1ica6an sJWA== X-Gm-Message-State: APjAAAVEon6GMaKnQAPmFtOCpy3oArw2whM5qGTBLZ3VoH860fGvSXcD iVC45BiHBmvjsjm3dsoXu62A2g== X-Received: by 2002:a2e:8103:: with SMTP id d3mr3392965ljg.105.1567632185972; Wed, 04 Sep 2019 14:23:05 -0700 (PDT) Received: from localhost.localdomain (168-200-94-178.pool.ukrtel.net. [178.94.200.168]) by smtp.gmail.com with ESMTPSA id s8sm3540836ljd.94.2019.09.04.14.23.04 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 04 Sep 2019 14:23:05 -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 4/8] samples: bpf: use own EXTRA_CFLAGS for clang commands Date: Thu, 5 Sep 2019 00:22:08 +0300 Message-Id: <20190904212212.13052-5-ivan.khoronzhuk@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190904212212.13052-1-ivan.khoronzhuk@linaro.org> References: <20190904212212.13052-1-ivan.khoronzhuk@linaro.org> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org It can overlap with CFLAGS used for libraries built with gcc if not now then in next patches. Correct it here for simplicity. Signed-off-by: Ivan Khoronzhuk --- samples/bpf/Makefile | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) -- 2.17.1 diff --git a/samples/bpf/Makefile b/samples/bpf/Makefile index a2953357927e..cdd742c05200 100644 --- a/samples/bpf/Makefile +++ b/samples/bpf/Makefile @@ -219,10 +219,10 @@ BTF_LLVM_PROBE := $(shell echo "int main() { return 0; }" | \ /bin/rm -f ./llvm_btf_verify.o) ifneq ($(BTF_LLVM_PROBE),) - EXTRA_CFLAGS += -g + CLANG_EXTRA_CFLAGS += -g else ifneq ($(and $(BTF_LLC_PROBE),$(BTF_PAHOLE_PROBE),$(BTF_OBJCOPY_PROBE)),) - EXTRA_CFLAGS += -g + CLANG_EXTRA_CFLAGS += -g LLC_FLAGS += -mattr=dwarfris DWARF2BTF = y endif @@ -281,8 +281,8 @@ $(obj)/hbm_edt_kern.o: $(src)/hbm.h $(src)/hbm_kern.h # 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/ \ + $(Q)$(CLANG) $(NOSTDINC_FLAGS) $(LINUXINCLUDE) $(CLANG_EXTRA_CFLAGS) \ + -I$(obj) -I$(srctree)/tools/testing/selftests/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 \ From patchwork Wed Sep 4 21:22:10 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ivan Khoronzhuk X-Patchwork-Id: 173076 Delivered-To: patch@linaro.org Received: by 2002:a05:6e02:ce:0:0:0:0 with SMTP id r14csp454842ilq; Wed, 4 Sep 2019 14:23:13 -0700 (PDT) X-Google-Smtp-Source: APXvYqx1rDh4ZXU6yt+sYtaySY80d2RpW15ZJZ3Dndg8ye2zGeTKkVZqQkEg74OoSBYJDDAU88UR X-Received: by 2002:a63:3148:: with SMTP id x69mr159825pgx.300.1567632192992; Wed, 04 Sep 2019 14:23:12 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1567632192; cv=none; d=google.com; s=arc-20160816; b=jjLOwauWWnNfa+aij4ig5tfy0xt7P/rGxqqwK/x4/fQRuv82skXYFDp+emDvDBw7n8 d4klzPFIEzrm54q3GPE5Zxl1B9Of+iUXv6e7c2AYajHOQc6teTE8uiwlwHCTXCvsPCjG vL+K3LRnB49CdAV9ulyCTMlQOkXyISrTX/9SXyowGCDG8FGe5/PG5AiPRTqXTJmeuNxe 4iqJ0wgiDgujabyZEz/88ymBGU0xgebiWq7Vq9Wyigs2+dRSBn1lhW0f4zNu7rowcWit zyFEPtGn4EbZVPOmzOn1p3MtDpPnQE6jPH5K7cAkE4fckqmWT4RiFTLwu0631VbM997z bFPA== 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=iQdFKRCdsWomZgjBMZ1BG8YTrJG1Rf0I+zDwJUFyFFw=; b=waNXW3WfifQrURNHVL0Gfh1bUGA2AwMiX8NYYKjew4Zbhfrc7NJ20pg7M9G/n8fS+y g9Kjs4CEQzE22DNz/zVpzxXTq/xcR176kz2L6XQIFrryMh5JCQC3bZaP5juo6009tAp6 wbSppzjFxQseLMwT+Z5W7Dr75Zzk3T7kpUzLpdF9zHoTNnlupE+MyTcZ3Yr2w6lvR77Z bHacFvCKinCiyVb+eEUV/hueZdABQLnaUpCoTivtou/GB0ScFXl+k9fg5l3bYckGovpH c39zD6T/yXVDZ6WNXP4XvFFdbIqt9wuNfXmNwevu2gttul0/egxbt4idK0Fc/38ShTTn aUZg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=w9EqOn0Y; 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 g18si56749plo.373.2019.09.04.14.23.12; Wed, 04 Sep 2019 14:23:12 -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=w9EqOn0Y; 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 S1730664AbfIDVXM (ORCPT + 28 others); Wed, 4 Sep 2019 17:23:12 -0400 Received: from mail-lj1-f193.google.com ([209.85.208.193]:42652 "EHLO mail-lj1-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730453AbfIDVXK (ORCPT ); Wed, 4 Sep 2019 17:23:10 -0400 Received: by mail-lj1-f193.google.com with SMTP id y23so171460lje.9 for ; Wed, 04 Sep 2019 14:23:08 -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=iQdFKRCdsWomZgjBMZ1BG8YTrJG1Rf0I+zDwJUFyFFw=; b=w9EqOn0YY7I/TacD6X6Vjc8n258l7Gc09N11miWY40kBi9+VSoXN++YMfJIjBwnOgK U3UYsWfJKg5xSFSiqtIdn4vm09vAxP+kColVZvJOAOebO8/IuymQKm31SLCXRQOaTCD2 RQ504SX7sSFVdtdwg/+sjWtzgKM9iIoaVLhnL6YyxtwAEBniaR7JWdJ7xfs5miGI91St mWtVSdMkew7dInOa2/bLuyKOckX3QvgY72z4nrryE/Ox706S8eJcxRziKI+q9XvhULll rTMbm4Ywygv/OTteQSOBuv5RG7t75vFyKH3z9GaYJCB4IXyIJFSFqpi4UiXk/eIRbuga Vn+A== 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=iQdFKRCdsWomZgjBMZ1BG8YTrJG1Rf0I+zDwJUFyFFw=; b=OnB9qnsMn+qNMnyapxC8vZdukEK4zelgvFvtkxbW1Qy/jm/9+hhHa+zIrVk+I3Rxpl W3VUJXtg1BBk3lmDkRrqh5fKV+1tvkIiK3Ola+Vn4dTQdxxtazTbng8CaA/axT327Kjk K+QOwRnAOS7z6mbiJkaUuvy93iUkc+Sr6QFrioJYqDx4E1FuW7iATlRsvEIjqOaGx+xY nOkroiiRls6NRbkn9a1LmNySMO7zt9p5cur/CO/7EUfXYM/hqvGXaOvXebcJPEexqh28 Cbxc+OBMy6qYDgFkerIeGW6qn7g37Jzek4LGI2t0M6xlg3iw1zGjp0iNv6UuIIA2hBbR +Ixg== X-Gm-Message-State: APjAAAUVvFNDv/Lm0hZS3rbtpilc9l2BMzCT5ZygikjrhV8q9DAxSEM3 3eV7j2eDGyDKzHml70UNIG/LSA== X-Received: by 2002:a2e:5358:: with SMTP id t24mr15379944ljd.209.1567632188285; Wed, 04 Sep 2019 14:23:08 -0700 (PDT) Received: from localhost.localdomain (168-200-94-178.pool.ukrtel.net. [178.94.200.168]) by smtp.gmail.com with ESMTPSA id s8sm3540836ljd.94.2019.09.04.14.23.07 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 04 Sep 2019 14:23:07 -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 6/8] samples: bpf: makefile: fix HDR_PROBE "echo" Date: Thu, 5 Sep 2019 00:22:10 +0300 Message-Id: <20190904212212.13052-7-ivan.khoronzhuk@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190904212212.13052-1-ivan.khoronzhuk@linaro.org> References: <20190904212212.13052-1-ivan.khoronzhuk@linaro.org> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org echo should be replaced on echo -e to handle \n correctly, but instead, replace it on printf as some systems can't handle echo -e. Signed-off-by: Ivan Khoronzhuk --- samples/bpf/Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) -- 2.17.1 diff --git a/samples/bpf/Makefile b/samples/bpf/Makefile index 9232efa2b1b3..043f9cc14cdd 100644 --- a/samples/bpf/Makefile +++ b/samples/bpf/Makefile @@ -208,7 +208,7 @@ endif # Don't evaluate probes and warnings if we need to run make recursively ifneq ($(src),) -HDR_PROBE := $(shell echo "\#include \n struct list_head { int a; }; int main() { return 0; }" | \ +HDR_PROBE := $(shell printf "\#include \n struct list_head { int a; }; int main() { return 0; }" | \ $(HOSTCC) $(KBUILD_HOSTCFLAGS) -x c - -o /dev/null 2>/dev/null && \ echo okay) From patchwork Wed Sep 4 21:22:12 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ivan Khoronzhuk X-Patchwork-Id: 173078 Delivered-To: patch@linaro.org Received: by 2002:a05:6e02:ce:0:0:0:0 with SMTP id r14csp454879ilq; Wed, 4 Sep 2019 14:23:16 -0700 (PDT) X-Google-Smtp-Source: APXvYqzGmpfs2qG6T0WdlC3x1wvdbR42/o5a2SrbDVg0GBZ0V1NILfTK8cjS6DKsK/6avWuVYWij X-Received: by 2002:a63:d90f:: with SMTP id r15mr150130pgg.259.1567632195871; Wed, 04 Sep 2019 14:23:15 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1567632195; cv=none; d=google.com; s=arc-20160816; b=eWF9o8qt5pBb+yeQIg54T04g3vA5p6fLHyKh1ypnjg8Uyrrxt4sPyAcNVX2VE1Ugi8 6fNIJBdtn/rrdbu3R8Gvpove5eeM/wtXFsAmznp6N7tZJMRbUKx/cKu67h3KNiZYteop RSbNhl7DvQcOCe/WvvF8EKJPbbOAT7aG013kmZ70vGfbVBY4ywKsxrPKrAHF3wWEFgdO b04/JuWzDKi9xkSSsgkx5VMIbBCtzo61EryxGi/1TEA4t/FspwE2ClPe5Yn2ATUqEDFW PYskJCrbuu3hNhOAMS25Anho4CxYx/e4Qej9qxQ4rRzhWpM/E+aUNtSinGb2gw3eWOFk sT6Q== 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=LT/VbQvHwKdykK+LZeZdbR4ubTJg9E+tpSt48zuAEBQ=; b=HLXougENVjlVxkzG1Z07D+oJ7nLoa9p1/1OJQlvBpWtEA2EiMQhgYy2SGVR/S0NPEO MX7JKeZ3jt0UVJN/keGoX8pcgoZOzgF+8c0qRmqPM7BawMcsciiQXRR1biZM6MGWr3ip TE0r8XM/gTbMe0QaTgBcaZrT1hynHyYJG+tbnIkAaO2ESXjo5E+gGOih2pj0mnJ/YMse QrVLhYIMqJH8wJGVxlQ9E+onDD+NVgCbpFyvoyT2ryEyJ1nvdujh7mVwovZj/lK7iWty Y+/3eng2D+8Cyq/VdAxiI7da8XcfHzczBfCZivTrbVHcHh8HXrDoCK9JS+xjGhxXYVCE pL+w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=c+pDBYNm; 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 y186si17766399pgd.440.2019.09.04.14.23.15; Wed, 04 Sep 2019 14:23:15 -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=c+pDBYNm; 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 S1730778AbfIDVXO (ORCPT + 28 others); Wed, 4 Sep 2019 17:23:14 -0400 Received: from mail-lj1-f193.google.com ([209.85.208.193]:47013 "EHLO mail-lj1-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730599AbfIDVXN (ORCPT ); Wed, 4 Sep 2019 17:23:13 -0400 Received: by mail-lj1-f193.google.com with SMTP id e17so147813ljf.13 for ; Wed, 04 Sep 2019 14:23:11 -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=LT/VbQvHwKdykK+LZeZdbR4ubTJg9E+tpSt48zuAEBQ=; b=c+pDBYNmGKQOLh8g4Xd+cJoZUuLqBQFVNtkw6u+Eu6w3Ib4JBhGO5EUPHYjHm15ia6 PwYR+OpAOG2O2VFgoSPtAlYIT4D2b1bIO0WD2nzAAgGgUlnQ5BF1Y4b2kxjCcLbkRYEO PlB13F4S5OCPe6G7haHW0Rs5+FZujk3N1dVxybykSrBtr17I830Mhwt6A9pFQBBeE5xb tgANQJXzB0nyYGPSOmpnsI6qqL2iGljn3JFIgaEj1IycW3W+yxGyUR5I3Q3gCtF/pyeA Q6vPERylcsqOXEgoq0yteAsDc2GX/aSKXHMlRW/QxOAO93BemfJmAX3NxRfrkvBHwJhj EGOw== 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=LT/VbQvHwKdykK+LZeZdbR4ubTJg9E+tpSt48zuAEBQ=; b=Pa2Gkj0wIFntyrdi7kXamXqdDAmvzPvgsxgnOwYVOo6uYIdJZeT3QXJtVtN9s1a6ZE CMnNma/0QQNhJ5rZ0n+Wm+OOdCZTVKMEnE82EIqI6NQvg5M9TWvhtEu0QHuaiPMAjNGx AlH23wodiVjRsOP2ul7O9aDLcVAbwyFvkIaW2VibCpq91r2x+PyNzAzvyPLTxi9t7NgR Q9U7jl+TvWdKvHf0fsvvHuV48abi9jD5UrA7YFd7Hl0Kod2B+lR6q/msfukO0DQVCof2 2wQ6BZ7DnnBo88/jkzJoEnhtGulP6OGbZ47HZVZJoDHGQTqCuvXt+lxlx98pO0LVOI/9 WN3A== X-Gm-Message-State: APjAAAVmcAThtJhxfcgWOpf++CZ8BRW4CGq9cUOVK8g94/bCySwPtQ5I nRlnlBRioCTk9D+32uT1NoPG/w== X-Received: by 2002:a2e:8510:: with SMTP id j16mr24485327lji.174.1567632190563; Wed, 04 Sep 2019 14:23:10 -0700 (PDT) Received: from localhost.localdomain (168-200-94-178.pool.ukrtel.net. [178.94.200.168]) by smtp.gmail.com with ESMTPSA id s8sm3540836ljd.94.2019.09.04.14.23.09 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 04 Sep 2019 14:23:10 -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 8/8] samples: bpf: Makefile: base progs build on Makefile.progs Date: Thu, 5 Sep 2019 00:22:12 +0300 Message-Id: <20190904212212.13052-9-ivan.khoronzhuk@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190904212212.13052-1-ivan.khoronzhuk@linaro.org> References: <20190904212212.13052-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 with host build, base bpf samples on Makefile.progs. It's also convenient when NFC is used: export ARCH=arm export CROSS_COMPILE=arm-linux-gnueabihf- make samples/bpf/ SYSROOT="path/to/sysroot" Sysroot contains correct headers installed ofc. Signed-off-by: Ivan Khoronzhuk --- samples/bpf/Makefile | 164 ++++++++++++++++++++++++----------------- samples/bpf/README.rst | 7 ++ 2 files changed, 102 insertions(+), 69 deletions(-) -- 2.17.1 diff --git a/samples/bpf/Makefile b/samples/bpf/Makefile index 043f9cc14cdd..ed7131851172 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 @@ -171,26 +169,51 @@ 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 += -I$(objtree)/usr/include -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' | \ sed '/^-D/!d' | tr '\n' ' ') +ifdef SYSROOT +ccflags-y += --sysroot=${SYSROOT} +ccflags-y += -I${SYSROOT}/usr/include +CLANG_EXTRA_CFLAGS := $(ccflags-y) +PROGS_LDFLAGS := -L${SYSROOT}/usr/lib +endif + +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/perf + +ccflags-y += $(D_OPTIONS) +ccflags-y += -Wall +ccflags-y += -Wmissing-prototypes +ccflags-y += -Wstrict-prototypes +ccflags-y += -fomit-frame-pointer + +PROGS_CFLAGS := $(ccflags-y) + +ccflags-y += -I$(objtree)/usr/include +ccflags-y += -I$(srctree)/tools/include + +PROGCFLAGS_bpf_load.o += -I$(objtree)/usr/include -I$(srctree)/tools/include \ + -Wno-unused-variable +PROGCFLAGS_sampleip_user.o += -I$(srctree)/tools/include +PROGCFLAGS_task_fd_query_user.o += -I$(srctree)/tools/include +PROGCFLAGS_trace_event_user.o += -I$(srctree)/tools/include +PROGCFLAGS_trace_output_user.o += -I$(srctree)/tools/include +PROGCFLAGS_tracex6_user.o += -I$(srctree)/tools/include +PROGCFLAGS_xdp_sample_pkts_user.o += -I$(srctree)/tools/include +PROGCFLAGS_xdpsock_user.o += -I$(srctree)/tools/include + +PROGS_LDLIBS := $(LIBBPF) -lelf +PROGLDLIBS_tracex4 += -lrt +PROGLDLIBS_trace_output += -lrt +PROGLDLIBS_map_perf_test += -lrt +PROGLDLIBS_test_overhead += -lrt +PROGLDLIBS_xdpsock += -pthread + CLANG_EXTRA_CFLAGS += $(D_OPTIONS) # Allows pointing LLC/CLANG to a LLVM backend with bpf support, redefine on cmdline: @@ -202,15 +225,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=$(notdir $(CROSS_COMPILE:%-=%)) endif # Don't evaluate probes and warnings if we need to run make recursively ifneq ($(src),) HDR_PROBE := $(shell printf "\#include \n struct list_head { int a; }; int main() { return 0; }" | \ - $(HOSTCC) $(KBUILD_HOSTCFLAGS) -x c - -o /dev/null 2>/dev/null && \ - echo okay) + $(CC) $(PROGS_CFLAGS) $(PROGS_LDFLAGS) -x c - -o /dev/null \ + 2>/dev/null && echo okay) ifeq ($(HDR_PROBE),) $(warning WARNING: Detected possible issues with include path.) @@ -246,7 +268,9 @@ 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="$(ccflags-y)" \ + EXTRA_CXXFLAGS="$(ccflags-y)" LDFLAGS=$(PROGS_LDFLAGS) \ + srctree=$(BPF_SAMPLES_PATH)/../../ O= $(obj)/syscall_nrs.h: $(obj)/syscall_nrs.s FORCE $(call filechk,offsets,__SYSCALL_NRS_H__) @@ -283,6 +307,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. diff --git a/samples/bpf/README.rst b/samples/bpf/README.rst index 5f27e4faca50..6b5e4eace977 100644 --- a/samples/bpf/README.rst +++ b/samples/bpf/README.rst @@ -74,3 +74,10 @@ 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 + +If need to use environment of target board, the SYSROOT also can be set, +pointing on FS of target board: + +make samples/bpf/ LLC=~/git/llvm/build/bin/llc \ + CLANG=~/git/llvm/build/bin/clang \ + SYSROOT=~/some_sdk/linux-devkit/sysroots/aarch64-linux-gnu