Message ID | 20230412095912.188453-1-andrea.righi@canonical.com |
---|---|
State | New |
Headers |
Return-Path: <linux-kernel-owner@vger.kernel.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:b0ea:0:b0:3b6:4342:cba0 with SMTP id b10csp204856vqo; Wed, 12 Apr 2023 03:06:22 -0700 (PDT) X-Google-Smtp-Source: AKy350Y9+Vm9C8+aYwjXnUZOPJpBXhe0qBrXZSWSAsJ1XQblW8RJ/9qx3jBbdeXKbl/DLJoCLUta X-Received: by 2002:a17:907:215b:b0:94a:959f:8089 with SMTP id rk27-20020a170907215b00b0094a959f8089mr8593847ejb.50.1681293982642; Wed, 12 Apr 2023 03:06:22 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1681293982; cv=none; d=google.com; s=arc-20160816; b=LZGhwxKmTLDISAADATiTApweRTy6F6qK+pE+t/v9ID4mQx37wjGFPiVE6HTl1h3i3D MtyuzS5TtXn0jrbUoK3PSknDNKpWrtnCTFxQKyXaho2+dfwCtUJ0hKOjefy+7hnhE9Z/ BOheWyc1QxVphp1iGDe+oztjOE0f/YUhESh1SKIweosOaotToH5/QET7/z6PZJ0DT6Z9 oHHK8P1/mPZ3Qp1mOjDFK9lM+u5pzjzyBHWIAU6LV4wOO1oZQaimuQPtpbbaPUzdjBEO Ldt7pyFIexUtInNXPKxDiCG42WT993/73nQx+excAB+ubnspc2CafNPEwTnUsFuBn3kq HB4w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from:dkim-signature; bh=lPAnInjEPmYSXmdYizwbO/BNtnsYb9zk0SNDJiS3bTc=; b=dY3DRlInIjqQJ75TlIT3LffZ8eee+3Gvc6vMpAqru6AzVhWT+d8aKemWaLmduHW49o HYiYHL+mXqdwZ/r8lmJmLLPTaRxMDlndHX6yiRi/OXEN/DoPa4Hnbvb0ZAs6u6zE1u2H DtMFC7u6uzha6tTP65JFHb+/P7idkBNIjz/0aU6QB39eXy8lbBVgiAueE0QpPnciUpTP a8lHGDSqGWf8NRCSu1A7ttBUGQD12bgIuNtGGZq96ZNz6aYQGhPj+gZv5PgY3szvZepF K0fSm2t3K4PSPlt1Km30KOwCw6RQGbPo8f4AZqouF/n+5t9Epcr0pj0EMDFAw4mtw0+k aMEw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@canonical.com header.s=20210705 header.b=wLahUtca; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=canonical.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id gn27-20020a1709070d1b00b0093e0b659bc3si992352ejc.493.2023.04.12.03.05.59; Wed, 12 Apr 2023 03:06:22 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@canonical.com header.s=20210705 header.b=wLahUtca; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=canonical.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229917AbjDLJ7e (ORCPT <rfc822;peter110.wang@gmail.com> + 99 others); Wed, 12 Apr 2023 05:59:34 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44994 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229802AbjDLJ73 (ORCPT <rfc822;linux-kernel@vger.kernel.org>); Wed, 12 Apr 2023 05:59:29 -0400 Received: from smtp-relay-internal-0.canonical.com (smtp-relay-internal-0.canonical.com [185.125.188.122]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id EE48C6A57 for <linux-kernel@vger.kernel.org>; Wed, 12 Apr 2023 02:59:27 -0700 (PDT) Received: from mail-oa1-f72.google.com (mail-oa1-f72.google.com [209.85.160.72]) (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 214393F438 for <linux-kernel@vger.kernel.org>; Wed, 12 Apr 2023 09:59:26 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=canonical.com; s=20210705; t=1681293566; bh=lPAnInjEPmYSXmdYizwbO/BNtnsYb9zk0SNDJiS3bTc=; h=From:To:Cc:Subject:Date:Message-Id:MIME-Version; b=wLahUtcaFHFDXoNn8BuQeWUpnpcfXs/Y4F+DvJ42pu6r3kVgm8rzq4We2lpvIQOQm 6PnC11Hdxj5cgkhfkf5DFnuzBdPHvtDypHkoVjA2dcKc/UVVNqeIbxrEHMpAK6qFia Jr8FFAuXhXiaADcTlGBZtBOiXxCNHXYHLkYCqgH1UuaIYqylXknb4KSjyE3MJ58i7M 7V1cQhdSpJZJnRYLZC2sbFeFZhLCTj8VXrCFeKI0di9u5y+otMoEcTITc/Gs4seFeE fTb55hnRdqtnTRRhq+Gnz9YMDvs8xUu9Tr55MaKJKaAyDKMiDpwjm9BzbKN5Rldnd8 0Z/RIM+W7EXeQ== Received: by mail-oa1-f72.google.com with SMTP id 586e51a60fabf-186ec473a81so801719fac.14 for <linux-kernel@vger.kernel.org>; Wed, 12 Apr 2023 02:59:26 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1681293564; x=1683885564; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=lPAnInjEPmYSXmdYizwbO/BNtnsYb9zk0SNDJiS3bTc=; b=PHIg+7inkCFvn8iAUGwC33JIW8SGVP6NsuiCyADQQq+p0zzJCQdqibd5oMUdigzFea CNA9tt4VfgshchyBtvzvM45BjBGGqOCmelnV7L6RdjSMvEQ5gLoWqvM52KBR/NckoJZg Q4I8Hrd4kzjkfM2YNCv3aYAf7SJDH+EOJKt+wfZwLNH94x6P37yVBNLnUGH1whoF1gFx 41yaqj/ZEv2oaPW6Xg8zb3yu3+x3pKiJe/zklyS/rdwdH1cWq379b1mImS+LU1LJLT9s xXwl28fXTpUBqdvjbpWNxwA0vnTOaXy5sdLpi7z5IRj9vOKsI5RV16u0OFCAL9YRIeb2 kXIg== X-Gm-Message-State: AAQBX9ej4aynUtES8WostNAmeQNBpnCkNM/Gy6lPjMUK3jqplCM5JtFz ApeTY5hMps4WeZ4VFAPIrFhtcWILsz+0bV9nYnH1nnFNdwvzSQ1oz0ukdyt+VXJ7HujlgwwXq57 /ZI26FabfKGE8fxs8SDYBf31fYtICyV2IVLbrPDEU+UiOXkoVJnO07lw= X-Received: by 2002:a05:6870:610d:b0:183:be43:c9b6 with SMTP id s13-20020a056870610d00b00183be43c9b6mr1118724oae.4.1681293564788; Wed, 12 Apr 2023 02:59:24 -0700 (PDT) X-Received: by 2002:a05:6870:610d:b0:183:be43:c9b6 with SMTP id s13-20020a056870610d00b00183be43c9b6mr1118714oae.4.1681293564521; Wed, 12 Apr 2023 02:59:24 -0700 (PDT) Received: from localhost.localdomain (uk.sesame.canonical.com. [185.125.190.60]) by smtp.gmail.com with ESMTPSA id zr21-20020a056871ae1500b001765b2f6c53sm6045880oab.9.2023.04.12.02.59.20 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 12 Apr 2023 02:59:23 -0700 (PDT) From: Andrea Righi <andrea.righi@canonical.com> To: Alexei Starovoitov <ast@kernel.org>, Daniel Borkmann <daniel@iogearbox.net>, Andrii Nakryiko <andrii@kernel.org> Cc: Martin KaFai Lau <martin.lau@linux.dev>, Song Liu <song@kernel.org>, Yonghong Song <yhs@fb.com>, John Fastabend <john.fastabend@gmail.com>, KP Singh <kpsingh@kernel.org>, Hao Luo <haoluo@google.com>, Jiri Olsa <jolsa@kernel.org>, Mykola Lysenko <mykolal@fb.com>, Shuah Khan <shuah@kernel.org>, Nathan Chancellor <nathan@kernel.org>, Nick Desaulniers <ndesaulniers@google.com>, Tom Rix <trix@redhat.com>, Paolo Pisati <paolo.pisati@canonical.com>, bpf@vger.kernel.org, linux-kselftest@vger.kernel.org, llvm@lists.linux.dev, linux-kernel@vger.kernel.org Subject: [PATCH] selftests/bpf: ignore pointer types check with clang Date: Wed, 12 Apr 2023 11:59:12 +0200 Message-Id: <20230412095912.188453-1-andrea.righi@canonical.com> X-Mailer: git-send-email 2.39.2 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-4.4 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_MED, SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: <linux-kernel.vger.kernel.org> X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1762964518692880573?= X-GMAIL-MSGID: =?utf-8?q?1762964518692880573?= |
Series |
selftests/bpf: ignore pointer types check with clang
|
|
Commit Message
Andrea Righi
April 12, 2023, 9:59 a.m. UTC
Building bpf selftests with clang can trigger errors like the following:
CLNG-BPF [test_maps] bpf_iter_netlink.bpf.o
progs/bpf_iter_netlink.c:32:4: error: incompatible pointer types assigning to 'struct sock *' from 'struct sock___17 *' [-Werror,-Wincompatible-pointer-types]
s = &nlk->sk;
^ ~~~~~~~~
1 error generated.
This is due to the fact that bpftool emits duplicate data types with
different names in vmlinux.h (i.e., `struct sock` in this case) and
these types, despite having a different name, represent in fact the same
object.
Add -Wno-incompatible-pointer-types to CLANG_CLAGS to prevent these
errors.
Signed-off-by: Andrea Righi <andrea.righi@canonical.com>
---
tools/testing/selftests/bpf/Makefile | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
Comments
On Wed, Apr 12, 2023 at 2:59 AM Andrea Righi <andrea.righi@canonical.com> wrote: > > Building bpf selftests with clang can trigger errors like the following: > > CLNG-BPF [test_maps] bpf_iter_netlink.bpf.o > progs/bpf_iter_netlink.c:32:4: error: incompatible pointer types assigning to 'struct sock *' from 'struct sock___17 *' [-Werror,-Wincompatible-pointer-types] > s = &nlk->sk; > ^ ~~~~~~~~ > 1 error generated. I cannot reproduce this and BPF CI doesn't complain about it either. What kind of clang do you use? Some special version and build flags?
On Thu, Apr 13, 2023 at 09:56:00PM -0700, Alexei Starovoitov wrote: > On Wed, Apr 12, 2023 at 2:59 AM Andrea Righi <andrea.righi@canonical.com> wrote: > > > > Building bpf selftests with clang can trigger errors like the following: > > > > CLNG-BPF [test_maps] bpf_iter_netlink.bpf.o > > progs/bpf_iter_netlink.c:32:4: error: incompatible pointer types assigning to 'struct sock *' from 'struct sock___17 *' [-Werror,-Wincompatible-pointer-types] > > s = &nlk->sk; > > ^ ~~~~~~~~ > > 1 error generated. > > I cannot reproduce this and BPF CI doesn't complain about it either. > What kind of clang do you use? > Some special version and build flags? I'm using Ubuntu clang version 15.0.7 (Ubuntu 23.04), no special build flag (unless Ubuntu enables some different default flags, but it shouldn't be the case... I'll double check). -Andrea
On Fri, Apr 14, 2023 at 08:15:03AM +0200, Andrea Righi wrote: > On Thu, Apr 13, 2023 at 09:56:00PM -0700, Alexei Starovoitov wrote: > > On Wed, Apr 12, 2023 at 2:59 AM Andrea Righi <andrea.righi@canonical.com> wrote: > > > > > > Building bpf selftests with clang can trigger errors like the following: > > > > > > CLNG-BPF [test_maps] bpf_iter_netlink.bpf.o > > > progs/bpf_iter_netlink.c:32:4: error: incompatible pointer types assigning to 'struct sock *' from 'struct sock___17 *' [-Werror,-Wincompatible-pointer-types] > > > s = &nlk->sk; > > > ^ ~~~~~~~~ > > > 1 error generated. > > > > I cannot reproduce this and BPF CI doesn't complain about it either. > > What kind of clang do you use? > > Some special version and build flags? > > I'm using Ubuntu clang version 15.0.7 (Ubuntu 23.04), no special build > flag (unless Ubuntu enables some different default flags, but it > shouldn't be the case... I'll double check). > > -Andrea Hi, FWIW, I see similar errors when I don't use recent pahole. Best regards, Ilya
On Fri, Apr 14, 2023 at 06:15:38PM +0200, Ilya Leoshkevich wrote: > On Fri, Apr 14, 2023 at 08:15:03AM +0200, Andrea Righi wrote: > > On Thu, Apr 13, 2023 at 09:56:00PM -0700, Alexei Starovoitov wrote: > > > On Wed, Apr 12, 2023 at 2:59 AM Andrea Righi <andrea.righi@canonical.com> wrote: > > > > > > > > Building bpf selftests with clang can trigger errors like the following: > > > > > > > > CLNG-BPF [test_maps] bpf_iter_netlink.bpf.o > > > > progs/bpf_iter_netlink.c:32:4: error: incompatible pointer types assigning to 'struct sock *' from 'struct sock___17 *' [-Werror,-Wincompatible-pointer-types] > > > > s = &nlk->sk; > > > > ^ ~~~~~~~~ > > > > 1 error generated. > > > > > > I cannot reproduce this and BPF CI doesn't complain about it either. > > > What kind of clang do you use? > > > Some special version and build flags? > > > > I'm using Ubuntu clang version 15.0.7 (Ubuntu 23.04), no special build > > flag (unless Ubuntu enables some different default flags, but it > > shouldn't be the case... I'll double check). > > > > -Andrea > > Hi, > > FWIW, I see similar errors when I don't use recent pahole. I'm using pahole v1.24. -Andrea
On Fri, Apr 14, 2023 at 9:28 AM Andrea Righi <andrea.righi@canonical.com> wrote: > > On Fri, Apr 14, 2023 at 06:15:38PM +0200, Ilya Leoshkevich wrote: > > On Fri, Apr 14, 2023 at 08:15:03AM +0200, Andrea Righi wrote: > > > On Thu, Apr 13, 2023 at 09:56:00PM -0700, Alexei Starovoitov wrote: > > > > On Wed, Apr 12, 2023 at 2:59 AM Andrea Righi <andrea.righi@canonical.com> wrote: > > > > > > > > > > Building bpf selftests with clang can trigger errors like the following: > > > > > > > > > > CLNG-BPF [test_maps] bpf_iter_netlink.bpf.o > > > > > progs/bpf_iter_netlink.c:32:4: error: incompatible pointer types assigning to 'struct sock *' from 'struct sock___17 *' [-Werror,-Wincompatible-pointer-types] > > > > > s = &nlk->sk; > > > > > ^ ~~~~~~~~ > > > > > 1 error generated. > > > > > > > > I cannot reproduce this and BPF CI doesn't complain about it either. > > > > What kind of clang do you use? > > > > Some special version and build flags? > > > > > > I'm using Ubuntu clang version 15.0.7 (Ubuntu 23.04), no special build > > > flag (unless Ubuntu enables some different default flags, but it > > > shouldn't be the case... I'll double check). > > > > > > -Andrea > > > > Hi, > > > > FWIW, I see similar errors when I don't use recent pahole. > > I'm using pahole v1.24. I believe Ilya is correct. struct sock___17 is likely coming from vmlinux.h Which means that there were errors due vmlinux build which caused multiple structs to be present in BTF and therefore bpftool generated such broken vmlinux.h The BTF section in such vmlinux is likely much larger than normal. Let's get to the bottom of it instead of masking build error. Please try pahole 1.25.
On Fri, Apr 14, 2023 at 06:15:41PM -0700, Alexei Starovoitov wrote: > On Fri, Apr 14, 2023 at 9:28 AM Andrea Righi <andrea.righi@canonical.com> wrote: > > > > On Fri, Apr 14, 2023 at 06:15:38PM +0200, Ilya Leoshkevich wrote: > > > On Fri, Apr 14, 2023 at 08:15:03AM +0200, Andrea Righi wrote: > > > > On Thu, Apr 13, 2023 at 09:56:00PM -0700, Alexei Starovoitov wrote: > > > > > On Wed, Apr 12, 2023 at 2:59 AM Andrea Righi <andrea.righi@canonical.com> wrote: > > > > > > > > > > > > Building bpf selftests with clang can trigger errors like the following: > > > > > > > > > > > > CLNG-BPF [test_maps] bpf_iter_netlink.bpf.o > > > > > > progs/bpf_iter_netlink.c:32:4: error: incompatible pointer types assigning to 'struct sock *' from 'struct sock___17 *' [-Werror,-Wincompatible-pointer-types] > > > > > > s = &nlk->sk; > > > > > > ^ ~~~~~~~~ > > > > > > 1 error generated. > > > > > > > > > > I cannot reproduce this and BPF CI doesn't complain about it either. > > > > > What kind of clang do you use? > > > > > Some special version and build flags? > > > > > > > > I'm using Ubuntu clang version 15.0.7 (Ubuntu 23.04), no special build > > > > flag (unless Ubuntu enables some different default flags, but it > > > > shouldn't be the case... I'll double check). > > > > > > > > -Andrea > > > > > > Hi, > > > > > > FWIW, I see similar errors when I don't use recent pahole. > > > > I'm using pahole v1.24. > > I believe Ilya is correct. > > struct sock___17 is likely coming from vmlinux.h > Which means that there were errors due vmlinux build which > caused multiple structs to be present in BTF > and therefore bpftool generated such broken vmlinux.h > > The BTF section in such vmlinux is likely much larger than normal. > Let's get to the bottom of it instead of masking build error. > > Please try pahole 1.25. Yay! Success. Everything is working fine with pahole 1.25. Please ignore my patch, the fix is to simply upgrade pahole. Thanks! -Andrea
diff --git a/tools/testing/selftests/bpf/Makefile b/tools/testing/selftests/bpf/Makefile index b677dcd0b77a..0d9ef819a065 100644 --- a/tools/testing/selftests/bpf/Makefile +++ b/tools/testing/selftests/bpf/Makefile @@ -356,7 +356,8 @@ BPF_CFLAGS = -g -Werror -D__TARGET_ARCH_$(SRCARCH) $(MENDIAN) \ -I$(abspath $(OUTPUT)/../usr/include) CLANG_CFLAGS = $(CLANG_SYS_INCLUDES) \ - -Wno-compare-distinct-pointer-types + -Wno-compare-distinct-pointer-types \ + -Wno-incompatible-pointer-types $(OUTPUT)/test_l4lb_noinline.o: BPF_CFLAGS += -fno-inline $(OUTPUT)/test_xdp_noinline.o: BPF_CFLAGS += -fno-inline