From patchwork Wed Feb 8 18:13:36 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Andrei Gherzan X-Patchwork-Id: 1739606 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.ubuntu.com (client-ip=91.189.94.19; helo=huckleberry.canonical.com; envelope-from=kernel-team-bounces@lists.ubuntu.com; receiver=) Authentication-Results: legolas.ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=canonical.com header.i=@canonical.com header.a=rsa-sha256 header.s=20210705 header.b=iep/XX3f; dkim-atps=neutral Received: from huckleberry.canonical.com (huckleberry.canonical.com [91.189.94.19]) (using TLSv1.2 with cipher ECDHE-ECDSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4PBp6R67xdz23yB for ; Thu, 9 Feb 2023 05:14:06 +1100 (AEDT) Received: from localhost ([127.0.0.1] helo=huckleberry.canonical.com) by huckleberry.canonical.com with esmtp (Exim 4.86_2) (envelope-from ) id 1pPox7-0006Xd-IX; Wed, 08 Feb 2023 18:13:53 +0000 Received: from smtp-relay-internal-0.internal ([10.131.114.225] helo=smtp-relay-internal-0.canonical.com) by huckleberry.canonical.com with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.86_2) (envelope-from ) id 1pPox5-0006XG-Jp for kernel-team@lists.ubuntu.com; Wed, 08 Feb 2023 18:13:51 +0000 Received: from mail-wm1-f71.google.com (mail-wm1-f71.google.com [209.85.128.71]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by smtp-relay-internal-0.canonical.com (Postfix) with ESMTPS id 69EDA3F211 for ; Wed, 8 Feb 2023 18:13:51 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=canonical.com; s=20210705; t=1675880031; bh=Z9FlWrzXJZFZsaoVRHyqbcjBEiYxOTY/b9e1Nea0zyA=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version:Content-Type; b=iep/XX3fof1P4mYIEj6g5szsNJZcK/tD/sdwwyqxI712yPtxJfKnSBcmJL5Qoei1V +7qxGhi/f5Wg1zlZCGR5pJZmHHxmTxAvKO3dyEjnNylmtj50ZB8NhLkbuBVFgZX3TJ lokFxikCerkw08jJOJ3uoPaXZkld6tfnanNmjH3kvUsoobb3q+su8e0MGJyXNjTafW WcSKukjEchadfUvniMnCBi77cOkBv8TLvzQyYdyxaggFy/sdlT5S3x5BCp2QTjKFfg pjiHwaWajFrPQILIdeMYWgSocyptpL3nRliPlDmnrGlXpraSkoNwvlVgDUBPShm9PG bOpSLl2NUEUcQ== Received: by mail-wm1-f71.google.com with SMTP id a20-20020a05600c349400b003dfecb98d38so1560425wmq.0 for ; Wed, 08 Feb 2023 10:13:51 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=Z9FlWrzXJZFZsaoVRHyqbcjBEiYxOTY/b9e1Nea0zyA=; b=RuBW/vtiq0CHfUi3aOKNk4YL8BpSto/+EuvC1GlsL/VAeJQM2J9ntsrsDN5XwwHgI0 2Rgn0lc+zlLEwSmX1Cswzstzg9y3K8p201qhxEOgxiVM/o9CLA3lKWT8ZEsnMqJ9U95X xm5J+pHIw7G14i6URNpLcLorEObzm0jZ48z5eXiTrhpcIF1mIJsFBIAyvJJ1vttOoduc /i7g2M0VY9Aidc4a3HQJMMk0uyqB+cg6AOWlp1bu8u9LQJdmuWjOo5zQoExW+qNFxZM8 zfp1MJRi3wctlhf4x0j1UBhBpOOCZtfmkWLLcpoqY8yVr7QWTXIh3r5oyriMgadIUVhb FFkQ== X-Gm-Message-State: AO0yUKU01Fo8mnQY6Zktp3Ib3wDjYwmT7onUqvxSV5Jy6XMsX3lRjT2e P340lSESh40LQ2/aZgdTHh4hlfWCIFDa0OMn6xsWfNqVsBANiumiBZhSTMorWLjcD43qsVFeEex kACBe/MR1Y5Bz5rmnCEslJqHX1a8Ffj3MKGysdEmywl0/doY= X-Received: by 2002:a5d:5150:0:b0:2c3:f971:ae1 with SMTP id u16-20020a5d5150000000b002c3f9710ae1mr4537894wrt.29.1675880030669; Wed, 08 Feb 2023 10:13:50 -0800 (PST) X-Google-Smtp-Source: AK7set9AZDHfeDcNxIK4ARYaiWRhpmAYqNIVTcjDGGiPFMbw/+0vIwgRkcNhNDV15tztbD8aJytHhg== X-Received: by 2002:a5d:5150:0:b0:2c3:f971:ae1 with SMTP id u16-20020a5d5150000000b002c3f9710ae1mr4537885wrt.29.1675880030506; Wed, 08 Feb 2023 10:13:50 -0800 (PST) Received: from qwirkle.internal ([81.2.157.149]) by smtp.gmail.com with ESMTPSA id g16-20020a05600c4ed000b003dfee43863fsm3058136wmq.26.2023.02.08.10.13.49 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 08 Feb 2023 10:13:49 -0800 (PST) From: Andrei Gherzan To: kernel-team@lists.ubuntu.com Subject: [SRU][Kinetic][PATCH 1/3] selftests: net: Add cross-compilation support for BPF programs Date: Wed, 8 Feb 2023 18:13:36 +0000 Message-Id: <20230208181338.476272-2-andrei.gherzan@canonical.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230208181338.476272-1-andrei.gherzan@canonical.com> References: <20230208181338.476272-1-andrei.gherzan@canonical.com> MIME-Version: 1.0 X-BeenThere: kernel-team@lists.ubuntu.com X-Mailman-Version: 2.1.20 Precedence: list List-Id: Kernel team discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Andrei Gherzan Errors-To: kernel-team-bounces@lists.ubuntu.com Sender: "kernel-team" From: Björn Töpel BugLink: https://bugs.launchpad.net/ubuntu/bugs/1996536 The selftests/net does not have proper cross-compilation support, and does not properly state libbpf as a dependency. Mimic/copy the BPF build from selftests/bpf, which has the nice side-effect that libbpf is built as well. Signed-off-by: Björn Töpel Reviewed-by: Anders Roxell Link: https://lore.kernel.org/r/20221119171841.2014936-1-bjorn@kernel.org Signed-off-by: Paolo Abeni (cherry-picked from 837a3d66d698516ad2330e122eba9752ec3a48ed) Signed-off-by: Andrei Gherzan --- tools/testing/selftests/net/bpf/Makefile | 45 +++++++++++++++++++++--- 1 file changed, 41 insertions(+), 4 deletions(-) diff --git a/tools/testing/selftests/net/bpf/Makefile b/tools/testing/selftests/net/bpf/Makefile index 7d8eddd327b7..1d4a0059fb47 100644 --- a/tools/testing/selftests/net/bpf/Makefile +++ b/tools/testing/selftests/net/bpf/Makefile @@ -1,15 +1,52 @@ # SPDX-License-Identifier: GPL-2.0 CLANG ?= clang +SCRATCH_DIR := $(OUTPUT)/tools +BUILD_DIR := $(SCRATCH_DIR)/build +BPFDIR := $(abspath ../../../lib/bpf) +APIDIR := $(abspath ../../../include/uapi) + CCINCLUDE += -I../../bpf -CCINCLUDE += -I../../../../lib CCINCLUDE += -I../../../../../usr/include/ +CCINCLUDE += -I$(SCRATCH_DIR)/include + +BPFOBJ := $(BUILD_DIR)/libbpf/libbpf.a + +MAKE_DIRS := $(BUILD_DIR)/libbpf +$(MAKE_DIRS): + mkdir -p $@ TEST_CUSTOM_PROGS = \ # $(OUTPUT)/bpf/nat6to4.o # Disabled for Ubuntu selftests build all: $(TEST_CUSTOM_PROGS) -$(OUTPUT)/%.o: %.c - $(CLANG) -O2 -target bpf -c $< $(CCINCLUDE) -o $@ +# Get Clang's default includes on this system, as opposed to those seen by +# '-target bpf'. This fixes "missing" files on some architectures/distros, +# such as asm/byteorder.h, asm/socket.h, asm/sockios.h, sys/cdefs.h etc. +# +# Use '-idirafter': Don't interfere with include mechanics except where the +# build would have failed anyways. +define get_sys_includes +$(shell $(1) $(2) -v -E - &1 \ + | sed -n '/<...> search starts here:/,/End of search list./{ s| \(/.*\)|-idirafter \1|p }') \ +$(shell $(1) $(2) -dM -E -