Received: by 2002:a05:6358:9144:b0:117:f937:c515 with SMTP id r4csp250114rwr; Wed, 19 Apr 2023 06:10:32 -0700 (PDT) X-Google-Smtp-Source: AKy350bfgStCsU2zhbnAcsXvM6HH4HZ1sUTbiq+lF6DqIlKW5pDf/Y7rZzETDQMzyecZHAwXIzPJ X-Received: by 2002:a17:902:cec9:b0:19f:1f0a:97f1 with SMTP id d9-20020a170902cec900b0019f1f0a97f1mr6478738plg.30.1681909831957; Wed, 19 Apr 2023 06:10:31 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1681909831; cv=none; d=google.com; s=arc-20160816; b=AKZZoRRlfdrdRcs9s2ZZ/k00ycsPRISmXxoIwM177vbfAzxKOy4rXK5DCtb8wdBpeg HNy076l1mxzUxr5xSd7Gxa17ipO6E1SM8M9yHAJfqL2bnk63Nr/j+icLrAEt0ozZqbj5 Ab+3czdzHtI788YguHXSfiYNmO6rCfQRPExdIgNWD4d7nxM7rz3pmTsIg7a4/vR3MICQ eYGT0J9ATm0r/lLN0DFWQRUEMQosTBwc5EDcu7sBYUPpjRRuaUqG2M0p7IUwVvzMhMTM m8IF+lqxHDDxkOREKxhWPaUW9zzk5CBMX40/JFko0QjDrHP1yj7SLVBFDMBUzduJEtOH vE4w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:cc:to:subject :message-id:date:from:in-reply-to:references:mime-version :dkim-signature; bh=xwi6q3cu45MnE4kyT4HYhg8YlJb8XVnKZHENVBx9cJw=; b=PE/Ph5qnsvpihZe2GLE/SSsKTG9Ew3uCOcOJd3XUPHMNfK0KTH3Man/ALkXNWbMUwL TNEP4m8s9ZlY08xtvbyW9di2jExSPDWcp5Kh5rOx6YF7jTM7nRbu62CculaEbz6BChNL u756I/Rfv2c4K9Zw5l6sGHZbDribRPA1vHY0GKjd/79if83iWS4c2wKZxkd0gbuJYks5 iTA2BQ/05nqOri9RSgxZtvNmKe87WHPTupqaFALSzcZev6DzSUY+q9wUzKcghkgzkFXr Sg12L4dqwij9F3AbD2vk0JptFYNXFX9q2YxEftCmMmKniYHPLDIxWc3YFNzltBmb99CE pR8Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20221208 header.b=q9bUXYfN; 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=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id je5-20020a170903264500b001a1b5dc97f0si16079108plb.270.2023.04.19.06.10.07; Wed, 19 Apr 2023 06:10:31 -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=@google.com header.s=20221208 header.b=q9bUXYfN; 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=REJECT sp=REJECT dis=NONE) header.from=google.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232135AbjDSNAq (ORCPT + 99 others); Wed, 19 Apr 2023 09:00:46 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42694 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232678AbjDSNAo (ORCPT ); Wed, 19 Apr 2023 09:00:44 -0400 Received: from mail-ej1-x62f.google.com (mail-ej1-x62f.google.com [IPv6:2a00:1450:4864:20::62f]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id DB3FBC17B for ; Wed, 19 Apr 2023 06:00:42 -0700 (PDT) Received: by mail-ej1-x62f.google.com with SMTP id dx24so37414153ejb.11 for ; Wed, 19 Apr 2023 06:00:42 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20221208; t=1681909241; x=1684501241; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=xwi6q3cu45MnE4kyT4HYhg8YlJb8XVnKZHENVBx9cJw=; b=q9bUXYfNIZcsLe55ILrvb+lgpf2Vt3HQWODdgf0HwXP7ruIx5aJKLDRpZMAoNyq2xl U2eVXI9moVOcl6M5H7JRZet9WaKzH0hO+Tj42DpFmXmgFhmtz8YBCBdDfJCe54JokDgG wyRSar3MYwUSuh6tViOBxFXCKKVqWNv3dyppoCxVS3jIOPiIV+9yKFUV9ck60YZ3uJcq 3Wu106SGWBD+iAAIAXjJSyPPr8U+xJPEnfvVq78SP8j1CzZg8aRiVfDMtK7rHbhlvJBY lxdowrUZ8QV5WqOIvj+2RG4BlGpm4KrXoIe6Yu06Kc71nPndkK7dteYEDLPeQhAPhS3S KmJw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1681909241; x=1684501241; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=xwi6q3cu45MnE4kyT4HYhg8YlJb8XVnKZHENVBx9cJw=; b=Q/V6yV3dfX+eohVgdLt0Tn9J0pwZCToUxkXwX/BY+B25CujdKINsmVsD/Hsc3/3H+3 qvb0sUTu8Rh/46cHgVMDChPjeqiD+Hxha6FiXZ0u9WzBp/eKXpeRle9xGN6vLJKqDupv nj4ig0pfqBh6IOPEVHOZIK2pPhraUS++kEYFs6M+dJ3Yp9v4tt2PkdSETFuX8YfyVR4q SGkLWIOUETOATjrA3KMpH3iLNv56qA/RYB1sJsGOwiCFRQwyLberO165E3PdgaGf5KgV V1PBAbA00YxcJ0Sl6yt8e+S7Jy0AkXWgFJacoRYGgJ07WBR2aaa768t9UklZ1SQWKJpp 2vBg== X-Gm-Message-State: AAQBX9cafZDfsudZpcLyhGEmyiVEK+HudbVPGvsmRrmDq2IAWeo29svr FJXaarsxxwoeH6LI0YL0YpXbuWEC5ArQila7PXVfog== X-Received: by 2002:a17:907:8a21:b0:94f:3521:396 with SMTP id sc33-20020a1709078a2100b0094f35210396mr13023290ejc.23.1681909241003; Wed, 19 Apr 2023 06:00:41 -0700 (PDT) MIME-Version: 1.0 References: <20230414005309.GA2198310@google.com> In-Reply-To: From: Florent Revest Date: Wed, 19 Apr 2023 15:00:30 +0200 Message-ID: Subject: Re: clangd cannot handle tree_nocb.h To: Nick Desaulniers Cc: Joel Fernandes , rcu@vger.kernel.org, nathan@kernel.org, trix@redhat.com, llvm@lists.linux.dev, linux-kernel@vger.kernel.org, paulmck@kernel.org, "revest@chromium.org" Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Spam-Status: No, score=-17.6 required=5.0 tests=BAYES_00,DKIMWL_WL_MED, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF, ENV_AND_HDR_SPF_MATCH,RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS, T_SCC_BODY_TEXT_LINE,USER_IN_DEF_DKIM_WL,USER_IN_DEF_SPF_WL 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 Tue, Apr 18, 2023 at 6:28=E2=80=AFPM Nick Desaulniers wrote: > > + Florent Hi there! > Joel, Florent is doing some cool stuff with clangd and kernels (check > out the demo at go/linux-kernel-vscode). I'm pushing Florent to Apologies for folks outside Google, this is an internal link to a kernel dev setup I originally created for myself, then for my team and apparently more and more people are starting to use it internally. :) If there's enough appetite for it externally too, I'll try to open-source it someday. Anyway, in the context of this conversation, it's just something that uses clangd. :) > publish some of the cool stuff he's been working on externally because > it is awesome. ;) > > Florent, have you seen any such issues such as what Joel reported below? Yes, I've seen this problem a bunch of times. Afaiu, Clangd operates under the assumption that every source file is a valid compilation unit. My understanding is that it's generally a good practice to keep things that way and I wouldn't be surprised if the userspace Chrome code-base Joel saw enforces this (iirc, it's a rule for Google-internal C++ too, all headers must be interpretable independently). However, from the perspective of the C spec, anything can be included anywhere and a C file can only make sense if it's included after/before certain other things are defined/included. Spontaneously, I would call these ".inc" rather than ".h" or ".c" because I would expect a source file to be always valid and this suffix makes it clearer they depend on their context, but as a matter of fact source files that don't compile when interpreted individually are quite common in the kernel tree. Other examples that have been reported to me include a lot of kernel/sched/*, since many of these files (including .c files) are included from kernel/sched/build_policy.c in a specific order to form one big compilation unit. Unfortunately, I don't know of any solution. :( This feels like a limit of C or compile_commands.json to me. "compile commands" can not be enough to interpret any file, clangd would need a way to express "interpret this file as if it were included in that spot of that compilation unit" and maybe even need a bunch of heuristics to choose one such include spot. I don't know if clangd has any plan to address this and so far I've just lived with these error squiggles.