Received: by 2002:a6b:fb09:0:0:0:0:0 with SMTP id h9csp3375157iog; Mon, 27 Jun 2022 14:53:23 -0700 (PDT) X-Google-Smtp-Source: AGRyM1vEXMuozIYywYzudu3ZeeatFYLsvfUep/XExf4j2aDcBczNkQCoRGKpkRXZL7D7N5lagv7a X-Received: by 2002:a17:907:72d5:b0:722:def3:9160 with SMTP id du21-20020a17090772d500b00722def39160mr14793424ejc.164.1656366803666; Mon, 27 Jun 2022 14:53:23 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1656366803; cv=none; d=google.com; s=arc-20160816; b=dN+q4kLGl/nXiVgJ1CRWIy4vylRwEgJZcoqjb6EXx8gDhPU60XWQNYo9/YL+Lr2Vv/ SmyYAavYkUXH3PkhknmUrjjtX0Oe9tDCBKcMNraoSEticwgg5qFt1YtWN5e7mrwyaA5i 0go1TFHIOBwGnvQmXA5JlfjlsLs6H4iwKPheenpJOwp6CZL8R8JO4N2R7pQ4EY2lyom0 z284BgVeVJQOc0C6S87FSz2uj9PRVdnpCur32UZTtcDwMJvSXmIwsQ2kX/WN2/qbYqts vJvga6YvlsH5+R4uJG/37QsZjXrE1L1LJFF6bBva+R5yhXbIUZBjBlIAmF8CN3uE0Ua1 oxyA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:subject:message-id:date:from:in-reply-to :references:mime-version:dkim-signature; bh=HjkSjk+quHsIJAc8+Pm/a2ht8JUXLV90rAzj2FC4Qwk=; b=Uf8XLJ+YnzW+1H+XRJ1oMT9i9j2q2Jc5gvipiOdg2hdRj3dzdcFAZBFt4KhwRTQkWH pYeEd6VXqp9NGtywCGL1+qmalH1udBQADsgMVb4PB+FqSJ8D1Rbo1B0WNyvmxlJyBVOA PovjlwVbtjmQmXIRMeiDK1ZRZfyeiQKhlJp2+bfKWICpn+qLjSYefFRqDG8c868oxHxq dT1esNStetCjAJlZJENn2SvtKC2ixQmEEl33ElM6enJL3dJ5qdFIJX0jzZpxRJmUppAx MKOYHYSnDfzIFgftomEDksslVJEh/lUpWEzIv/L+mxhshur7XwPTsh0q/1W0fL2Ek3me JkBQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=dwFFoA1D; 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=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id z25-20020a170906715900b00715771cd3c1si11965314ejj.622.2022.06.27.14.52.58; Mon, 27 Jun 2022 14:53:23 -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=@gmail.com header.s=20210112 header.b=dwFFoA1D; 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=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S239221AbiF0VvK (ORCPT + 99 others); Mon, 27 Jun 2022 17:51:10 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55332 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S239028AbiF0VvI (ORCPT ); Mon, 27 Jun 2022 17:51:08 -0400 Received: from mail-ej1-x62d.google.com (mail-ej1-x62d.google.com [IPv6:2a00:1450:4864:20::62d]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D169E199; Mon, 27 Jun 2022 14:51:07 -0700 (PDT) Received: by mail-ej1-x62d.google.com with SMTP id g26so21869034ejb.5; Mon, 27 Jun 2022 14:51:07 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=HjkSjk+quHsIJAc8+Pm/a2ht8JUXLV90rAzj2FC4Qwk=; b=dwFFoA1Dpr93AYox32+CQZDIUYUaa1GZ/NhrtMx8JXXqHiQgRmLxcSAmH5NrDGB3HC knnRepvFI52d6RkjCrW/SYxKV2H6jzhdDh+mTTl/FFB/tGRjI/B97ORFehvQLk9sCjVr rsLaf7/8DmA9bR3Ta06989ddwwr+J4WiRbvgeh1qhHrdV+rJWTvIYWld4rYselxwmMoO 0tPntf6p3ntyjXm4eMgO6syiR8G0Sla8flN2GBr+s+Dw/AnzVjzAijGQgW7M2BpwrgG3 rjLeZDg9R/Ip2CBzCkSB2zNUlKRTVJVvliJufVEuQrcoaw3Gsd3HrhlKyCXXnlD2FSww Q2bg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=HjkSjk+quHsIJAc8+Pm/a2ht8JUXLV90rAzj2FC4Qwk=; b=BKQv6hS6+SR/zLa6KdwhF1ae8uvLrVgpeqKNsD2WSGQ6i5rfLj59zWIlPVrwUCgyX5 oN5zlPTtMkNahnUDBz47td8n3SIowL00tq0kRjmDsGjNR+b9xMFyfE4ZpNYH7pMPDj/a eMwfXmNJmuMQDb0qJTy0UvhAwOgkj+2DZxgo2B9BGyKkh0Lxn5bAbCUBjnZ+9g38pTIU oXW2eDu2QsVcaSZwW0elly0as3fXhad1bYgVI0D8ygPLcji6oyRn2Kd15kFxuz3oaeb/ 9A6+06ESzhwmZ8LplKz5OnQF2vAvOX55Ur+RBirBHGZNTZFFdh31d9o9Zj1t19QDwP9N LxWg== X-Gm-Message-State: AJIora8CLRGj5xXehqoDRkXKITyAyvcBkKKqHO7vM2ol0+Lx4G1f5krb SeTMS6u9eWyF0kBidIXEYSxxw6Lm/k4bPtSZmdY= X-Received: by 2002:a17:906:a3ca:b0:726:2bd2:87bc with SMTP id ca10-20020a170906a3ca00b007262bd287bcmr14828902ejb.226.1656366665820; Mon, 27 Jun 2022 14:51:05 -0700 (PDT) MIME-Version: 1.0 References: <20220609062829.293217-1-james.hilliard1@gmail.com> In-Reply-To: From: Andrii Nakryiko Date: Mon, 27 Jun 2022 14:50:53 -0700 Message-ID: Subject: Re: [PATCH 1/1] libbpf: replace typeof with __typeof__ for -std=c17 compatibility To: James Hilliard Cc: bpf , Alexei Starovoitov , Daniel Borkmann , Andrii Nakryiko , Martin KaFai Lau , Song Liu , Yonghong Song , John Fastabend , KP Singh , =?UTF-8?B?QmrDtnJuIFTDtnBlbA==?= , Magnus Karlsson , Maciej Fijalkowski , Jonathan Lemon , "open list:BPF (Safe dynamic programs and tools)" , open list Content-Type: text/plain; charset="UTF-8" X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM, RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham 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: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, Jun 9, 2022 at 4:46 PM James Hilliard wrote: > > On Thu, Jun 9, 2022 at 12:11 PM Andrii Nakryiko > wrote: > > > > On Wed, Jun 8, 2022 at 11:28 PM James Hilliard > > wrote: > > > > > > Fixes errors like: > > > error: expected specifier-qualifier-list before 'typeof' > > > 14 | #define __type(name, val) typeof(val) *name > > > | ^~~~~~ > > > ../src/core/bpf/socket_bind/socket-bind.bpf.c:25:9: note: in expansion of macro '__type' > > > 25 | __type(key, __u32); > > > | ^~~~~~ > > > > > > Signed-off-by: James Hilliard > > > --- > > > > If you follow DPDK link you gave me ([0]), you'll see that they ended up doing > > > > #ifndef typeof > > #define typeof __typeof__ > > #endif > > > > It's way more localized. Let's do that. > > Won't that potentially leak the redefinition into external code including the > header file? all this is in BPF-side helpers and we add a bunch of other "common" definitions like barrier(), offsetof(), etc. So I think this is acceptable, at least for now (and users will be able to override this due to #ifndef check, right?) > > I don't see a redefinition of typeof like that used elsewhere in the kernel. kernel is just happily using much cleaner looking typeof() almost universally, though $ rg -w typeof ~/linux/include | wc -l 401 $ rg -w __typeof__ ~/linux/include | wc -l 28 > > However I do see __typeof__ used in many headers already so that approach > seems to follow normal conventions and seems less risky. > > FYI using -std=gnu17 instead of -std=c17 works around this issue with bpf-gcc > at least so this issue isn't really a blocker like the SEC macro > issue, I had just > accidentally mixed the two issues up due to accidentally not clearing out some > header files when testing, they seem to be entirely separate. > > > > > But also I tried to build libbpf-bootstrap with -std=c17 and > > immediately ran into issue with asm, so we need to do the same with > > asm -> __asm__. Can you please update your patch and fix both issues? > > Are you hitting that with clang/llvm or bpf-gcc? It doesn't appear that the > libbpf-bootstrap build system is set up to build with bpf-gcc yet. > I didn't realize you were using bpf-gcc, sorry. I was testing with clang. > > > > [0] https://patches.dpdk.org/project/dpdk/patch/2601191342CEEE43887BDE71AB977258213F3012@irsmsx105.ger.corp.intel.com/ > > [1] https://github.com/libbpf/libbpf-bootstrap > > > > > > > tools/lib/bpf/bpf_core_read.h | 16 ++++++++-------- > > > tools/lib/bpf/bpf_helpers.h | 4 ++-- > > > tools/lib/bpf/bpf_tracing.h | 24 ++++++++++++------------ > > > tools/lib/bpf/btf.h | 4 ++-- > > > tools/lib/bpf/libbpf_internal.h | 6 +++--- > > > tools/lib/bpf/usdt.bpf.h | 6 +++--- > > > tools/lib/bpf/xsk.h | 12 ++++++------ > > > 7 files changed, 36 insertions(+), 36 deletions(-) > > > > > > > [...]