From patchwork Thu Dec 16 16:38:38 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jean-Philippe Brucker X-Patchwork-Id: 12682133 X-Patchwork-Delegate: bpf@iogearbox.net Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 3C35CC4332F for ; Thu, 16 Dec 2021 16:50:52 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230459AbhLPQuu (ORCPT ); Thu, 16 Dec 2021 11:50:50 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50360 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235271AbhLPQut (ORCPT ); Thu, 16 Dec 2021 11:50:49 -0500 Received: from mail-wr1-x436.google.com (mail-wr1-x436.google.com [IPv6:2a00:1450:4864:20::436]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D5B02C061401 for ; Thu, 16 Dec 2021 08:50:48 -0800 (PST) Received: by mail-wr1-x436.google.com with SMTP id s1so11187487wrg.1 for ; Thu, 16 Dec 2021 08:50:48 -0800 (PST) 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 :mime-version:content-transfer-encoding; bh=PSj7odpkITXsYB6KPKrMVfI/4wK2fmXegdumHZrochE=; b=dFx0Hwhzmk2igT16BZ1rlhq6dmsS0U34aPp3se+PKa/ZzjcDBS4H2B6kjCKxkKkUnm o6bbpnrimMR8LF6ECf0WtkhDh2EwsMnPD6NRoVWZ3Tp4DtDLktxL0iVIpTPJq2V9Qwv6 EDxc97Zgs3TzNCmdnVAg6l87mbVeDbDElCjbimhMjpYcC+UqtEaWuZuyaDlBvmrhV5H0 LRsmVCx6Se20pdD0St80++FeXjiaE5H5VQbQWFA1Q/Letg6FRFrHEiDgCnA3MCGh4ySD 9Lz7jsukzN4m0l8WSFRE3c+xHkqiPX22/GW9xWqMudL/aDViMXN4MXRY7GYpluZ56GZy ZNWA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=PSj7odpkITXsYB6KPKrMVfI/4wK2fmXegdumHZrochE=; b=4qKep4KP6Hvcfxd2wKrgD3VxiyoUwYkRzlUvSjkHA1Z6cdcrOmG6FcvMSaVH4rCmgf zRejJODKPaoeGCRgr5lv8DJpnqRiV3KvHvqihLOsEokkEwsBZ1+5i2efrf7LY403yxfg WgyVkLt4ATxSkimKTJ0Ffzz2xYaF5PbJZvb0iiEA5+FyuNbcicLeIXEc5UWaZKt86uyv 2nmsgX7D2wtvbK9mD4pHmpsrHGA+oKWCeyIUD30EVoua38jAbXgszJ1E9F2HBkcOK6Dp CVYPuN33AekrbSVawY8YbuaQwXiJHROUDzdhhjJGH+QOWNZSez50I38Bttjs/gdsw8bC pBMQ== X-Gm-Message-State: AOAM530CQdA0a9HOg6dz48wN2+vKXIMO2EKzAFmOVDfkBpWRuNOCxFTu 8vGvYtByymlM6MbzgYBqYRo0cA== X-Google-Smtp-Source: ABdhPJx+P9oqyIfuP9A1UsCS0C6AIk2H9RaJ+5KI1+5kFgW3KWUsbTT45+vSVithjhZ/h43RdNIdIQ== X-Received: by 2002:a5d:4b0a:: with SMTP id v10mr2043375wrq.294.1639673447321; Thu, 16 Dec 2021 08:50:47 -0800 (PST) Received: from localhost.localdomain (cpc92880-cmbg19-2-0-cust679.5-4.cable.virginm.net. [82.27.106.168]) by smtp.gmail.com with ESMTPSA id y15sm7438906wry.72.2021.12.16.08.50.46 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 16 Dec 2021 08:50:47 -0800 (PST) From: Jean-Philippe Brucker To: ast@kernel.org, daniel@iogearbox.net, andrii@kernel.org, shuah@kernel.org, nathan@kernel.org, ndesaulniers@google.com Cc: kafai@fb.com, songliubraving@fb.com, yhs@fb.com, john.fastabend@gmail.com, kpsingh@kernel.org, quentin@isovalent.com, bpf@vger.kernel.org, linux-kselftest@vger.kernel.org, llvm@lists.linux.dev, Jean-Philippe Brucker Subject: [PATCH bpf-next v2 1/6] tools: Help cross-building with clang Date: Thu, 16 Dec 2021 16:38:38 +0000 Message-Id: <20211216163842.829836-2-jean-philippe@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20211216163842.829836-1-jean-philippe@linaro.org> References: <20211216163842.829836-1-jean-philippe@linaro.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: bpf@vger.kernel.org X-Patchwork-Delegate: bpf@iogearbox.net Cross-compilation with clang uses the -target parameter rather than a toolchain prefix. Just like the kernel Makefile, add that parameter to CFLAGS when CROSS_COMPILE is set. Unlike the kernel Makefile, we use the --sysroot and --gcc-toolchain options because unlike the kernel, tools require standard libraries. Commit c91d4e47e10e ("Makefile: Remove '--gcc-toolchain' flag") provides some background about --gcc-toolchain. Normally clang finds on its own the additional utilities and libraries that it needs (for example GNU ld or glibc). On some systems however, this autodetection doesn't work. There, our only recourse is asking GCC directly, and pass the result to --sysroot and --gcc-toolchain. Of course that only works when a cross GCC is available. Autodetection worked fine on Debian, but to use the aarch64-linux-gnu toolchain from Archlinux I needed both --sysroot (for crt1.o) and --gcc-toolchain (for crtbegin.o, -lgcc). The --prefix parameter wasn't needed there, but it might be useful on other distributions. Use the CLANG_CROSS_FLAGS variable instead of CLANG_FLAGS because it allows tools such as bpftool, that need to build both host and target binaries, to easily filter out the cross-build flags from CFLAGS. Acked-by: Quentin Monnet Signed-off-by: Jean-Philippe Brucker Acked-by: Nick Desaulniers --- Most tools I looked at needed additional changes to support cross-build with clang. I've only done the work for bpf tools. --- tools/scripts/Makefile.include | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/tools/scripts/Makefile.include b/tools/scripts/Makefile.include index 071312f5eb92..b0be5f40a3f1 100644 --- a/tools/scripts/Makefile.include +++ b/tools/scripts/Makefile.include @@ -87,7 +87,18 @@ LLVM_STRIP ?= llvm-strip ifeq ($(CC_NO_CLANG), 1) EXTRA_WARNINGS += -Wstrict-aliasing=3 -endif + +else ifneq ($(CROSS_COMPILE),) +CLANG_CROSS_FLAGS := --target=$(notdir $(CROSS_COMPILE:%-=%)) +GCC_TOOLCHAIN_DIR := $(dir $(shell which $(CROSS_COMPILE)gcc)) +ifneq ($(GCC_TOOLCHAIN_DIR),) +CLANG_CROSS_FLAGS += --prefix=$(GCC_TOOLCHAIN_DIR)$(notdir $(CROSS_COMPILE)) +CLANG_CROSS_FLAGS += --sysroot=$(shell $(CROSS_COMPILE)gcc -print-sysroot) +CLANG_CROSS_FLAGS += --gcc-toolchain=$(realpath $(GCC_TOOLCHAIN_DIR)/..) +endif # GCC_TOOLCHAIN_DIR +CFLAGS += $(CLANG_CROSS_FLAGS) +AFLAGS += $(CLANG_CROSS_FLAGS) +endif # CROSS_COMPILE # Hack to avoid type-punned warnings on old systems such as RHEL5: # We should be changing CFLAGS and checking gcc version, but this From patchwork Thu Dec 16 16:38:39 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jean-Philippe Brucker X-Patchwork-Id: 12682135 X-Patchwork-Delegate: bpf@iogearbox.net Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 6DED1C433F5 for ; Thu, 16 Dec 2021 16:50:53 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235271AbhLPQuv (ORCPT ); Thu, 16 Dec 2021 11:50:51 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50364 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S239727AbhLPQuu (ORCPT ); Thu, 16 Dec 2021 11:50:50 -0500 Received: from mail-wr1-x432.google.com (mail-wr1-x432.google.com [IPv6:2a00:1450:4864:20::432]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B2F6BC061747 for ; Thu, 16 Dec 2021 08:50:49 -0800 (PST) Received: by mail-wr1-x432.google.com with SMTP id j9so13196062wrc.0 for ; Thu, 16 Dec 2021 08:50:49 -0800 (PST) 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 :mime-version:content-transfer-encoding; bh=pJRqVurWv/xPXVPfg9RJJPd9MELUol7kDVQDIoB29M4=; b=j11Nk8Sqnke5x2cKuVDNGRjjHdUv65mw61hzMSDPnxhKxKjz9QpmvRbTOAP7PT0Qj4 lRXxMRjip+9dtbSJwULLTlpd8uQFObXQRsWQK8/SkwknGd8VnKGckm/sWIgoysHaC/Z8 HdC4fr9IHtl+IEBfF+F9+H/3xJPYuVVbF95I7BezfRE6DXptsOftO9AhzQ6zL24dejmq jSJY9DN376cNEDYkyJoBYBC9NY7VYUdMQyBdZH/81RjvIU84Yl1ebNqL7SVO3KFoofjN 8moq9RwIwng4+LkWkIyMunWctj6e/4mQi717khuAB1ziYwlG6OJGS4YONFdZQtSx0VUB j5OA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=pJRqVurWv/xPXVPfg9RJJPd9MELUol7kDVQDIoB29M4=; b=4WmlszaWVPcw60Jgur6ewe6n2LkXXvexUFo2qTf0D1CRQbUAnuN1pygcsEPXkDqVyF M/d+EfGbM1x+j4HAZiOy1DEOXqsusmoPrgKOZfR75OdiePVAEZJ3k7TgphDtI/x/3jyb ozIjmpvETnceP6USvPu6qPmMqXHgIXuMSrDbnz3UOBZjlOZOSb9CqGrM0QU+Hsw/Nus0 +e9cQybmui3DXC8IKXzyqOE8diAStGyJfJx1djggOhlthbmUXHz2AcNTJpAKvVy4q8B3 CIswPEpzLn7oyeuMHcknitGRMltWq91wfzsw7eILVFwMKt/H/y7ZngWm0lqT1QjS6f9R pXzg== X-Gm-Message-State: AOAM530IIop3dVvhEJ7nbrYHjCjEp0zUtIinNItlbVyTTNQF3YNuJixr sSDsl1VKT04iqVIFiE2GhPzhdg== X-Google-Smtp-Source: ABdhPJxzwdAAnWi1SsHBCOcf33UW6I563gS8lB7I43K9co91J+vPwBcD4O7ZqVJpBGGrEwajiLNvbw== X-Received: by 2002:adf:f708:: with SMTP id r8mr10213612wrp.198.1639673448266; Thu, 16 Dec 2021 08:50:48 -0800 (PST) Received: from localhost.localdomain (cpc92880-cmbg19-2-0-cust679.5-4.cable.virginm.net. [82.27.106.168]) by smtp.gmail.com with ESMTPSA id y15sm7438906wry.72.2021.12.16.08.50.47 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 16 Dec 2021 08:50:47 -0800 (PST) From: Jean-Philippe Brucker To: ast@kernel.org, daniel@iogearbox.net, andrii@kernel.org, shuah@kernel.org, nathan@kernel.org, ndesaulniers@google.com Cc: kafai@fb.com, songliubraving@fb.com, yhs@fb.com, john.fastabend@gmail.com, kpsingh@kernel.org, quentin@isovalent.com, bpf@vger.kernel.org, linux-kselftest@vger.kernel.org, llvm@lists.linux.dev, Jean-Philippe Brucker Subject: [PATCH bpf-next v2 2/6] tools/resolve_btfids: Support cross-building the kernel with clang Date: Thu, 16 Dec 2021 16:38:39 +0000 Message-Id: <20211216163842.829836-3-jean-philippe@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20211216163842.829836-1-jean-philippe@linaro.org> References: <20211216163842.829836-1-jean-philippe@linaro.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: bpf@vger.kernel.org X-Patchwork-Delegate: bpf@iogearbox.net The CROSS_COMPILE variable may be present during resolve_btfids build if the kernel is being cross-built. Since resolve_btfids is always executed on the host, we set CC to HOSTCC in order to use the host toolchain when cross-building with GCC. But instead of a toolchain prefix, cross-build with clang uses a "-target" parameter, which Makefile.include deduces from the CROSS_COMPILE variable. In order to avoid cross-building libbpf, clear CROSS_COMPILE before building resolve_btfids. Acked-by: Quentin Monnet Signed-off-by: Jean-Philippe Brucker --- tools/bpf/resolve_btfids/Makefile | 1 + 1 file changed, 1 insertion(+) diff --git a/tools/bpf/resolve_btfids/Makefile b/tools/bpf/resolve_btfids/Makefile index 751643f860b2..9ddeca947635 100644 --- a/tools/bpf/resolve_btfids/Makefile +++ b/tools/bpf/resolve_btfids/Makefile @@ -19,6 +19,7 @@ CC = $(HOSTCC) LD = $(HOSTLD) ARCH = $(HOSTARCH) RM ?= rm +CROSS_COMPILE = OUTPUT ?= $(srctree)/tools/bpf/resolve_btfids/ From patchwork Thu Dec 16 16:38:40 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jean-Philippe Brucker X-Patchwork-Id: 12682137 X-Patchwork-Delegate: bpf@iogearbox.net Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 67B29C4321E for ; Thu, 16 Dec 2021 16:50:54 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S239757AbhLPQux (ORCPT ); Thu, 16 Dec 2021 11:50:53 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50370 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235286AbhLPQuv (ORCPT ); Thu, 16 Dec 2021 11:50:51 -0500 Received: from mail-wm1-x332.google.com (mail-wm1-x332.google.com [IPv6:2a00:1450:4864:20::332]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B5128C06173E for ; Thu, 16 Dec 2021 08:50:50 -0800 (PST) Received: by mail-wm1-x332.google.com with SMTP id bg19-20020a05600c3c9300b0034565e837b6so1712219wmb.1 for ; Thu, 16 Dec 2021 08:50:50 -0800 (PST) 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 :mime-version:content-transfer-encoding; bh=tJ57tzLvzYQgO/9a3Xp1difD235xOW6tp16fePO+Nvw=; b=FssgxFJeWNvA52S2sKL8qB9q1T0ylP/fCugzW2B7O25Ifxn5IiNuY3dG8Bzo6PA9Rk kwV+nNqZ9QZ/SRGM0ntcjAk3PpHDXtW8jGqDo9qv26D9ZXRjsiTPE1u3kX4VdjZi3mw9 T4yiRmy2ZNZOorhXbNxf3mtNLHNMKUPY7Q0GDycbsLZmO0Z1q38k9xLg2fOyYl5ZUcXM jYeDM2xivey529HnCxoeEYc+ilywrnRXW+QAzGS7iLw6UFoAcZ38r/SOBJoR6ATWvl0M F6zNnMzjkhW847CpHIaTyz3JMrC1f64//fNhIl1GGt/tZ2WKShrkm1VhRmkJ9PQpZc08 0Xdw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=tJ57tzLvzYQgO/9a3Xp1difD235xOW6tp16fePO+Nvw=; b=z9hu4SyuMdK2TNKrFDzJggJBT8EWVHSxj3GlPKLT7ht3O8z9f085btKH2gFdxCEkBZ wUxZIaO4xks2yWV5JBFulzGaG8vYracKJYzLhwoRHMhQ6GfdUT8ZU06LrUqN05vmq+Th /mt5awn6lbA0AVLzKHS+/0tsoao3Rpv2JaSXRZBH1C2QifG7KeBJ1KAtCtE82w7UDdYR a9Qn4utIKlJIJXoluD2Zwizkz1tvMD6E+o4xKI9qauJMeDDnsyVgP/+C8JP5gFWqan9R nMfcivbBP+5XXFpzcxKdTI7A/5nxfG+nTSOdq73IaIWAQE82YT/LIjWdBjfuFG+KHNDo 6bcg== X-Gm-Message-State: AOAM531qtgFAGztDDbZRLbfWOrnCyqRSVQR/musdvRDAPifgafd0PJty sa667ao9jfPIwuozXt7ZqOT3DQ== X-Google-Smtp-Source: ABdhPJzkUQ91OzbhQT8Zh1Yv5cFer+EkjDQhAjtPzPWe+NBWXRNdGWaP8Jrjn9dbEUm9AuAgAFar0A== X-Received: by 2002:a1c:1f88:: with SMTP id f130mr5863988wmf.91.1639673449319; Thu, 16 Dec 2021 08:50:49 -0800 (PST) Received: from localhost.localdomain (cpc92880-cmbg19-2-0-cust679.5-4.cable.virginm.net. [82.27.106.168]) by smtp.gmail.com with ESMTPSA id y15sm7438906wry.72.2021.12.16.08.50.48 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 16 Dec 2021 08:50:49 -0800 (PST) From: Jean-Philippe Brucker To: ast@kernel.org, daniel@iogearbox.net, andrii@kernel.org, shuah@kernel.org, nathan@kernel.org, ndesaulniers@google.com Cc: kafai@fb.com, songliubraving@fb.com, yhs@fb.com, john.fastabend@gmail.com, kpsingh@kernel.org, quentin@isovalent.com, bpf@vger.kernel.org, linux-kselftest@vger.kernel.org, llvm@lists.linux.dev, Jean-Philippe Brucker Subject: [PATCH bpf-next v2 3/6] tools/libbpf: Enable cross-building with clang Date: Thu, 16 Dec 2021 16:38:40 +0000 Message-Id: <20211216163842.829836-4-jean-philippe@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20211216163842.829836-1-jean-philippe@linaro.org> References: <20211216163842.829836-1-jean-philippe@linaro.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: bpf@vger.kernel.org X-Patchwork-Delegate: bpf@iogearbox.net Cross-building using clang requires passing the "-target" flag rather than using the CROSS_COMPILE prefix. Makefile.include transforms CROSS_COMPILE into CLANG_CROSS_FLAGS. Add them to the CFLAGS. Acked-by: Quentin Monnet Signed-off-by: Jean-Philippe Brucker --- tools/lib/bpf/Makefile | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/tools/lib/bpf/Makefile b/tools/lib/bpf/Makefile index 5f7086fae31c..f947b61b2107 100644 --- a/tools/lib/bpf/Makefile +++ b/tools/lib/bpf/Makefile @@ -90,6 +90,7 @@ override CFLAGS += -Werror -Wall override CFLAGS += $(INCLUDES) override CFLAGS += -fvisibility=hidden override CFLAGS += -D_LARGEFILE64_SOURCE -D_FILE_OFFSET_BITS=64 +override CFLAGS += $(CLANG_CROSS_FLAGS) # flags specific for shared library SHLIB_FLAGS := -DSHARED -fPIC @@ -162,7 +163,7 @@ $(BPF_HELPER_DEFS): $(srctree)/tools/include/uapi/linux/bpf.h $(OUTPUT)libbpf.so: $(OUTPUT)libbpf.so.$(LIBBPF_VERSION) $(OUTPUT)libbpf.so.$(LIBBPF_VERSION): $(BPF_IN_SHARED) $(VERSION_SCRIPT) - $(QUIET_LINK)$(CC) $(LDFLAGS) \ + $(QUIET_LINK)$(CC) $(CFLAGS) $(LDFLAGS) \ --shared -Wl,-soname,libbpf.so.$(LIBBPF_MAJOR_VERSION) \ -Wl,--version-script=$(VERSION_SCRIPT) $< -lelf -lz -o $@ @ln -sf $(@F) $(OUTPUT)libbpf.so From patchwork Thu Dec 16 16:38:41 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jean-Philippe Brucker X-Patchwork-Id: 12682139 X-Patchwork-Delegate: bpf@iogearbox.net Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id D59A8C433FE for ; Thu, 16 Dec 2021 16:50:54 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S239758AbhLPQux (ORCPT ); Thu, 16 Dec 2021 11:50:53 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50378 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S239755AbhLPQuw (ORCPT ); Thu, 16 Dec 2021 11:50:52 -0500 Received: from mail-wr1-x42d.google.com (mail-wr1-x42d.google.com [IPv6:2a00:1450:4864:20::42d]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id AFEF4C061401 for ; Thu, 16 Dec 2021 08:50:51 -0800 (PST) Received: by mail-wr1-x42d.google.com with SMTP id i22so15514699wrb.13 for ; Thu, 16 Dec 2021 08:50:51 -0800 (PST) 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 :mime-version:content-transfer-encoding; bh=XpxpkXYQscEfsWsFoTOiPTSmY6NepL3QKAAqEPptpwY=; b=uEb42ddIqlf5GTi3ZfvCLziEA2Eilam4mdrPDskEFILbqlZDTt866z35BAaU3OXZHX KeNHt5fs1ZtAzz7alex5nB2Q/jUC47m90SdVHPHB9cCqRsXQJRdDKQupAPYPNwOjBAZd +7JQ9b/5pv7PgWy8PUTjaj1lzzfOh6qR3Ky59lP6hPZ72rQe5JZjiZfN65ktvwmCiQii GAajOxxX0z3DRjzwwkO21PJE4xsaG1gTKIEBw/eaDF1EmrFziAbdPKi8lN2E4rsPmjQk 14/g2kUw1Gm7e8QICYTBHM3xBRi1fd2rPZckm8k/lXuq3QAp+a5sY5gLWLpGTL7vR1+p Wqug== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=XpxpkXYQscEfsWsFoTOiPTSmY6NepL3QKAAqEPptpwY=; b=RILhHcnPKKOou7MDykJjzxG4u2X2XK+UcUQC2N6UcSx056IpNi1u0peBbl2RTeTTZh QYgQqFoErFQ+9gbG15dD3MReqAsoSfcwUtEayBZjH03GEbEqXgfk2RJD/XyHchegt/7U 7ld/jNY6Gb7zMtvyTtKjWk/kZ3wgMkCFZn0Xo/YJbPT7NZjoztuc1h6HJeAEDpGvin62 dreblLW+e8zmVvbILCSnLZPSOaJ1/57/H9ZPY3oJfe/5iunkCjR9sWoGNn33RbzmrlYf YfQtiSNIRa+55RAE4HRYiM/RYDXuSx2Oyj/oZDrAZKxEMaGH4pnsdxElBTlr2D6SWDmd Lpow== X-Gm-Message-State: AOAM5331DB/c0l9XOiwIJyWTvPqiMe6aBtXMvwyvdcwPfunnd7jbl4Sc O37tpspxwsn2XjE8lVdQRVYjxQ== X-Google-Smtp-Source: ABdhPJyh5IEh8DFsqYWeu4iMwCkRIQ4DYRdYJrE9x2CeUc8WZt+jk1IHdBFqcFelUpBlrrnjehm+nQ== X-Received: by 2002:a05:6000:188d:: with SMTP id a13mr9601163wri.461.1639673450279; Thu, 16 Dec 2021 08:50:50 -0800 (PST) Received: from localhost.localdomain (cpc92880-cmbg19-2-0-cust679.5-4.cable.virginm.net. [82.27.106.168]) by smtp.gmail.com with ESMTPSA id y15sm7438906wry.72.2021.12.16.08.50.49 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 16 Dec 2021 08:50:49 -0800 (PST) From: Jean-Philippe Brucker To: ast@kernel.org, daniel@iogearbox.net, andrii@kernel.org, shuah@kernel.org, nathan@kernel.org, ndesaulniers@google.com Cc: kafai@fb.com, songliubraving@fb.com, yhs@fb.com, john.fastabend@gmail.com, kpsingh@kernel.org, quentin@isovalent.com, bpf@vger.kernel.org, linux-kselftest@vger.kernel.org, llvm@lists.linux.dev, Jean-Philippe Brucker Subject: [PATCH bpf-next v2 4/6] bpftool: Enable cross-building with clang Date: Thu, 16 Dec 2021 16:38:41 +0000 Message-Id: <20211216163842.829836-5-jean-philippe@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20211216163842.829836-1-jean-philippe@linaro.org> References: <20211216163842.829836-1-jean-philippe@linaro.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: bpf@vger.kernel.org X-Patchwork-Delegate: bpf@iogearbox.net Cross-building using clang requires passing the "-target" flag rather than using the CROSS_COMPILE prefix. Makefile.include transforms CROSS_COMPILE into CLANG_CROSS_FLAGS, and adds that to CFLAGS. Remove the cross flags for the bootstrap bpftool, and erase the CROSS_COMPILE flag for the bootstrap libbpf. Acked-by: Quentin Monnet Signed-off-by: Jean-Philippe Brucker --- tools/bpf/bpftool/Makefile | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/tools/bpf/bpftool/Makefile b/tools/bpf/bpftool/Makefile index 42eb8eee3d89..83369f55df61 100644 --- a/tools/bpf/bpftool/Makefile +++ b/tools/bpf/bpftool/Makefile @@ -57,7 +57,7 @@ $(LIBBPF_INTERNAL_HDRS): $(LIBBPF_HDRS_DIR)/%.h: $(BPF_DIR)/%.h | $(LIBBPF_HDRS_ $(LIBBPF_BOOTSTRAP): $(wildcard $(BPF_DIR)/*.[ch] $(BPF_DIR)/Makefile) | $(LIBBPF_BOOTSTRAP_OUTPUT) $(Q)$(MAKE) -C $(BPF_DIR) OUTPUT=$(LIBBPF_BOOTSTRAP_OUTPUT) \ DESTDIR=$(LIBBPF_BOOTSTRAP_DESTDIR) prefix= \ - ARCH= CC=$(HOSTCC) LD=$(HOSTLD) $@ install_headers + ARCH= CROSS_COMPILE= CC=$(HOSTCC) LD=$(HOSTLD) $@ install_headers $(LIBBPF_BOOTSTRAP_INTERNAL_HDRS): $(LIBBPF_BOOTSTRAP_HDRS_DIR)/%.h: $(BPF_DIR)/%.h | $(LIBBPF_BOOTSTRAP_HDRS_DIR) $(call QUIET_INSTALL, $@) @@ -152,6 +152,9 @@ CFLAGS += -DHAVE_LIBBFD_SUPPORT SRCS += $(BFD_SRCS) endif +HOST_CFLAGS = $(subst -I$(LIBBPF_INCLUDE),-I$(LIBBPF_BOOTSTRAP_INCLUDE),\ + $(subst $(CLANG_CROSS_FLAGS),,$(CFLAGS))) + BPFTOOL_BOOTSTRAP := $(BOOTSTRAP_OUTPUT)bpftool BOOTSTRAP_OBJS = $(addprefix $(BOOTSTRAP_OUTPUT),main.o common.o json_writer.o gen.o btf.o xlated_dumper.o btf_dumper.o disasm.o) @@ -202,7 +205,7 @@ endif CFLAGS += $(if $(BUILD_BPF_SKELS),,-DBPFTOOL_WITHOUT_SKELETONS) $(BOOTSTRAP_OUTPUT)disasm.o: $(srctree)/kernel/bpf/disasm.c - $(QUIET_CC)$(HOSTCC) $(CFLAGS) -c -MMD $< -o $@ + $(QUIET_CC)$(HOSTCC) $(HOST_CFLAGS) -c -MMD $< -o $@ $(OUTPUT)disasm.o: $(srctree)/kernel/bpf/disasm.c $(QUIET_CC)$(CC) $(CFLAGS) -c -MMD $< -o $@ @@ -213,15 +216,13 @@ ifneq ($(feature-zlib), 1) endif $(BPFTOOL_BOOTSTRAP): $(BOOTSTRAP_OBJS) $(LIBBPF_BOOTSTRAP) - $(QUIET_LINK)$(HOSTCC) $(CFLAGS) $(LDFLAGS) $(BOOTSTRAP_OBJS) $(LIBS_BOOTSTRAP) -o $@ + $(QUIET_LINK)$(HOSTCC) $(HOST_CFLAGS) $(LDFLAGS) $(BOOTSTRAP_OBJS) $(LIBS_BOOTSTRAP) -o $@ $(OUTPUT)bpftool: $(OBJS) $(LIBBPF) $(QUIET_LINK)$(CC) $(CFLAGS) $(LDFLAGS) $(OBJS) $(LIBS) -o $@ $(BOOTSTRAP_OUTPUT)%.o: %.c $(LIBBPF_BOOTSTRAP_INTERNAL_HDRS) | $(BOOTSTRAP_OUTPUT) - $(QUIET_CC)$(HOSTCC) \ - $(subst -I$(LIBBPF_INCLUDE),-I$(LIBBPF_BOOTSTRAP_INCLUDE),$(CFLAGS)) \ - -c -MMD $< -o $@ + $(QUIET_CC)$(HOSTCC) $(HOST_CFLAGS) -c -MMD $< -o $@ $(OUTPUT)%.o: %.c $(QUIET_CC)$(CC) $(CFLAGS) -c -MMD $< -o $@ From patchwork Thu Dec 16 16:38:42 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jean-Philippe Brucker X-Patchwork-Id: 12682141 X-Patchwork-Delegate: bpf@iogearbox.net Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 29A84C4167E for ; Thu, 16 Dec 2021 16:50:55 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S239755AbhLPQuy (ORCPT ); Thu, 16 Dec 2021 11:50:54 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50384 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S239727AbhLPQuw (ORCPT ); Thu, 16 Dec 2021 11:50:52 -0500 Received: from mail-wr1-x435.google.com (mail-wr1-x435.google.com [IPv6:2a00:1450:4864:20::435]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9129FC061574 for ; Thu, 16 Dec 2021 08:50:52 -0800 (PST) Received: by mail-wr1-x435.google.com with SMTP id c4so45300094wrd.9 for ; Thu, 16 Dec 2021 08:50:52 -0800 (PST) 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 :mime-version:content-transfer-encoding; bh=ose2WJEou4zoTrngtFvFAaRJtRUsXBV7SYBsD7VOC3Q=; b=PrYuPW3/nxu/boJFGaWpIEi1ilibRe/YYZ7+rh62rX2+dZCbPf8sdfU+Bu4M5rY0aB uDP1fxuOoooPb1Fa0D+K6DbeOmbGcdTW79/pKn/pzzEIzNfQnCZqaMIYL9bIbYr+d8vH vJwcROrTVSEuEKQYb4Vn4aZciE8uB1m31vo+Qu1wK1dtVkZfva99IJFc/+J1KpTzbqSt QqVicK8o9t5DQt8qp6E0ivpq4IQxPEeNQb0WyUDmk2qJutJestY7li9c6lz9S6/36wsS aXuR9mw7RMOhqPzLQ0OSE/koefC42e0CjY7fjHiutc1kwfVYj2RAhx1qf8GrrO7pPvUf pDOg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=ose2WJEou4zoTrngtFvFAaRJtRUsXBV7SYBsD7VOC3Q=; b=5Wic7Kve4e7M2ehkCsaxFsuwJmjrRcONg2NBPlBH0KEeaG6crNSk9B/dvBEB/u7Rfo K2G+cpuuP3wrj0C9ie0mcliH9L0in1MHOq9JaLTPE/c6e37VUH1WbrjspBGgPKaSE9Ob It4Miadle8jRslWozDujfK1ZTA7Ecja+JXB0HWTcMvIOp2xyMo64iXl4Sg8oXEemU7rW Px190oPzfvVufQ33LkqabQljM0Iyx5NMRvn5zWh2n5CrKhFQpx895Y6LPsDo10qNQZkX 9ZwcNhXgQ71zGQR3sg7t5eS4hL7Ok8jMNheU7bXhlr7ycoarbvWsnk+3dGjv8SiARZDx x6Mw== X-Gm-Message-State: AOAM532uBHBYsA7YHLJIJUQ9L6VeSA4oeBKiXTvT/ma1gjplKWPpMA87 FZ2U932SmuGXsdpNJGEcFJtQtw== X-Google-Smtp-Source: ABdhPJyannlEeJJtlT2DKs7SaWIfuTLxMylJjw2g926P8ul5QDUX/huYSyoDKKPvn0fHrzlInVhSvQ== X-Received: by 2002:a05:6000:2cd:: with SMTP id o13mr4733226wry.718.1639673451211; Thu, 16 Dec 2021 08:50:51 -0800 (PST) Received: from localhost.localdomain (cpc92880-cmbg19-2-0-cust679.5-4.cable.virginm.net. [82.27.106.168]) by smtp.gmail.com with ESMTPSA id y15sm7438906wry.72.2021.12.16.08.50.50 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 16 Dec 2021 08:50:50 -0800 (PST) From: Jean-Philippe Brucker To: ast@kernel.org, daniel@iogearbox.net, andrii@kernel.org, shuah@kernel.org, nathan@kernel.org, ndesaulniers@google.com Cc: kafai@fb.com, songliubraving@fb.com, yhs@fb.com, john.fastabend@gmail.com, kpsingh@kernel.org, quentin@isovalent.com, bpf@vger.kernel.org, linux-kselftest@vger.kernel.org, llvm@lists.linux.dev, Jean-Philippe Brucker Subject: [PATCH bpf-next v2 5/6] tools/runqslower: Enable cross-building with clang Date: Thu, 16 Dec 2021 16:38:42 +0000 Message-Id: <20211216163842.829836-6-jean-philippe@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20211216163842.829836-1-jean-philippe@linaro.org> References: <20211216163842.829836-1-jean-philippe@linaro.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: bpf@vger.kernel.org X-Patchwork-Delegate: bpf@iogearbox.net Cross-building using clang requires passing the "-target" flag rather than using the CROSS_COMPILE prefix. Makefile.include transforms CROSS_COMPILE into CLANG_CROSS_FLAGS. Add them to CFLAGS, and erase CROSS_COMPILE for the bpftool build, since it needs to be executed on the host. Acked-by: Quentin Monnet Signed-off-by: Jean-Philippe Brucker --- tools/bpf/runqslower/Makefile | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tools/bpf/runqslower/Makefile b/tools/bpf/runqslower/Makefile index 8791d0e2762b..da6de16a3dfb 100644 --- a/tools/bpf/runqslower/Makefile +++ b/tools/bpf/runqslower/Makefile @@ -12,7 +12,7 @@ BPFOBJ := $(BPFOBJ_OUTPUT)libbpf.a BPF_DESTDIR := $(BPFOBJ_OUTPUT) BPF_INCLUDE := $(BPF_DESTDIR)/include INCLUDES := -I$(OUTPUT) -I$(BPF_INCLUDE) -I$(abspath ../../include/uapi) -CFLAGS := -g -Wall +CFLAGS := -g -Wall $(CLANG_CROSS_FLAGS) # Try to detect best kernel BTF source KERNEL_REL := $(shell uname -r) @@ -88,4 +88,4 @@ $(BPFOBJ): $(wildcard $(LIBBPF_SRC)/*.[ch] $(LIBBPF_SRC)/Makefile) | $(BPFOBJ_OU $(DEFAULT_BPFTOOL): $(BPFOBJ) | $(BPFTOOL_OUTPUT) $(Q)$(MAKE) $(submake_extras) -C ../bpftool OUTPUT=$(BPFTOOL_OUTPUT) \ - CC=$(HOSTCC) LD=$(HOSTLD) + ARCH= CROSS_COMPILE= CC=$(HOSTCC) LD=$(HOSTLD) From patchwork Thu Dec 16 16:38:43 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jean-Philippe Brucker X-Patchwork-Id: 12682143 X-Patchwork-Delegate: bpf@iogearbox.net Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 7BA31C43217 for ; Thu, 16 Dec 2021 16:50:56 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S239688AbhLPQuz (ORCPT ); Thu, 16 Dec 2021 11:50:55 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50392 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S239753AbhLPQuy (ORCPT ); Thu, 16 Dec 2021 11:50:54 -0500 Received: from mail-wm1-x32d.google.com (mail-wm1-x32d.google.com [IPv6:2a00:1450:4864:20::32d]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8D3CEC061574 for ; Thu, 16 Dec 2021 08:50:53 -0800 (PST) Received: by mail-wm1-x32d.google.com with SMTP id z206so5087265wmc.1 for ; Thu, 16 Dec 2021 08:50:53 -0800 (PST) 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 :mime-version:content-transfer-encoding; bh=sT7c6xsY79+p4VjCJ0GuWfCfN2sZ5xBnIoxrf7S6ddA=; b=zXJ8r9ZL0HMuqNYJiTcdyKwaAcd2Hm/hnU26Go6jzk3Hiqo6X0i9NLN9p6AspDCY0V DnjMCTaUmWGj8gTU4jp+mH45CQeZtiarFsCe+yc/f0nDOdAnPxjQC70VaJKYtLnLRShG PfSJ2EX7Nbd5fP3chAm3iaKeLZkRETpU0Ch5pbTy9u16mVSub4HJUIj7TwAybF5baBVB aXLVkPwjApwqDmEmqo9gMgPyBsB+4+3BjQeNQZ7QmKQ6kHmoEpzrgXUATJf+2OTny8zg HYP2jb9qpyT3+5zqx7mRL6VNvRtyMVnbb4ZHIkWgaGVJckVXv43kTDFrMfYDkPpU0rUj fK+A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=sT7c6xsY79+p4VjCJ0GuWfCfN2sZ5xBnIoxrf7S6ddA=; b=MJOmMVq/3mrlXTM0EplYjx4sEGn/wUujx6UmrogiSeOCcmZDD43HiDI914xvM66j70 wGuM4LEBuKGbU2mIdX/N9qm2tHjfaoMNGy79resFqPdHxvt22Oa77ycRsBRxVtrebwUX X9/bhwASaSjbUjc0csObOpLOUQ29LASB8ZP0q9qvfb1MJGBoex38LMYocTILKoQie21p za3B0w71WX5fYAPMyA4IvnHmszxcmidr9VUzuJ/Wr44YWe1hiVANVLF2ByZ7lzDemS6W VLYLWHMlKtWPkZbQMrwcCWFdJujMsHCz4cATfwtoBsJzP2CvNqG8FFiHyB6GekU2SrKc mMww== X-Gm-Message-State: AOAM532bgZyXNbitxjxL50d+ClviPtw9bY0u+yOiw1V20iRWQg2RUR6j ZdS1xTOuE8dJa5mdE3iDb/rjFw== X-Google-Smtp-Source: ABdhPJyYw/JR5XWgtcqwAnuLqgpwIaezx+JHl1pGQ/V7SoktSGt0KL2b9TPIMm6Wy/etnCFJyiPINw== X-Received: by 2002:a05:600c:6d2:: with SMTP id b18mr5873052wmn.98.1639673452137; Thu, 16 Dec 2021 08:50:52 -0800 (PST) Received: from localhost.localdomain (cpc92880-cmbg19-2-0-cust679.5-4.cable.virginm.net. [82.27.106.168]) by smtp.gmail.com with ESMTPSA id y15sm7438906wry.72.2021.12.16.08.50.51 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 16 Dec 2021 08:50:51 -0800 (PST) From: Jean-Philippe Brucker To: ast@kernel.org, daniel@iogearbox.net, andrii@kernel.org, shuah@kernel.org, nathan@kernel.org, ndesaulniers@google.com Cc: kafai@fb.com, songliubraving@fb.com, yhs@fb.com, john.fastabend@gmail.com, kpsingh@kernel.org, quentin@isovalent.com, bpf@vger.kernel.org, linux-kselftest@vger.kernel.org, llvm@lists.linux.dev, Jean-Philippe Brucker Subject: [PATCH bpf-next v2 6/6] selftests/bpf: Enable cross-building with clang Date: Thu, 16 Dec 2021 16:38:43 +0000 Message-Id: <20211216163842.829836-7-jean-philippe@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20211216163842.829836-1-jean-philippe@linaro.org> References: <20211216163842.829836-1-jean-philippe@linaro.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: bpf@vger.kernel.org X-Patchwork-Delegate: bpf@iogearbox.net Cross building using clang requires passing the "-target" flag rather than using the CROSS_COMPILE prefix. Makefile.include transforms CROSS_COMPILE into CLANG_CROSS_FLAGS. Clear CROSS_COMPILE for bpftool and the host libbpf, and use the clang flags for urandom_read and bench. Acked-by: Quentin Monnet Signed-off-by: Jean-Philippe Brucker --- tools/testing/selftests/bpf/Makefile | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/tools/testing/selftests/bpf/Makefile b/tools/testing/selftests/bpf/Makefile index 43f6f3159431..42ffc24e9e71 100644 --- a/tools/testing/selftests/bpf/Makefile +++ b/tools/testing/selftests/bpf/Makefile @@ -170,7 +170,7 @@ $(OUTPUT)/%:%.c $(OUTPUT)/urandom_read: urandom_read.c $(call msg,BINARY,,$@) - $(Q)$(CC) $(LDFLAGS) $< $(LDLIBS) -Wl,--build-id=sha1 -o $@ + $(Q)$(CC) $(CFLAGS) $(LDFLAGS) $< $(LDLIBS) -Wl,--build-id=sha1 -o $@ $(OUTPUT)/bpf_testmod.ko: $(VMLINUX_BTF) $(wildcard bpf_testmod/Makefile bpf_testmod/*.[ch]) $(call msg,MOD,,$@) @@ -217,7 +217,7 @@ BPFTOOL ?= $(DEFAULT_BPFTOOL) $(DEFAULT_BPFTOOL): $(wildcard $(BPFTOOLDIR)/*.[ch] $(BPFTOOLDIR)/Makefile) \ $(HOST_BPFOBJ) | $(HOST_BUILD_DIR)/bpftool $(Q)$(MAKE) $(submake_extras) -C $(BPFTOOLDIR) \ - CC=$(HOSTCC) LD=$(HOSTLD) \ + ARCH= CROSS_COMPILE= CC=$(HOSTCC) LD=$(HOSTLD) \ EXTRA_CFLAGS='-g -O0' \ OUTPUT=$(HOST_BUILD_DIR)/bpftool/ \ LIBBPF_OUTPUT=$(HOST_BUILD_DIR)/libbpf/ \ @@ -248,7 +248,7 @@ $(HOST_BPFOBJ): $(wildcard $(BPFDIR)/*.[ch] $(BPFDIR)/Makefile) \ $(APIDIR)/linux/bpf.h \ | $(HOST_BUILD_DIR)/libbpf $(Q)$(MAKE) $(submake_extras) -C $(BPFDIR) \ - EXTRA_CFLAGS='-g -O0' \ + EXTRA_CFLAGS='-g -O0' ARCH= CROSS_COMPILE= \ OUTPUT=$(HOST_BUILD_DIR)/libbpf/ CC=$(HOSTCC) LD=$(HOSTLD) \ DESTDIR=$(HOST_SCRATCH_DIR)/ prefix= all install_headers endif @@ -551,7 +551,7 @@ $(OUTPUT)/bench: $(OUTPUT)/bench.o \ $(OUTPUT)/bench_bpf_loop.o \ $(OUTPUT)/bench_strncmp.o $(call msg,BINARY,,$@) - $(Q)$(CC) $(LDFLAGS) $(filter %.a %.o,$^) $(LDLIBS) -o $@ + $(Q)$(CC) $(CFLAGS) $(LDFLAGS) $(filter %.a %.o,$^) $(LDLIBS) -o $@ EXTRA_CLEAN := $(TEST_CUSTOM_PROGS) $(SCRATCH_DIR) $(HOST_SCRATCH_DIR) \ prog_tests/tests.h map_tests/tests.h verifier/tests.h \