Received: by 2002:a05:6a10:8c0a:0:0:0:0 with SMTP id go10csp2728105pxb; Sun, 28 Feb 2021 11:04:35 -0800 (PST) X-Google-Smtp-Source: ABdhPJy118lkWsGRrIn1kCnL8dfcgF8G7ZzaE1rW/t5cBKdcuTnnlzk+HKFglkZOV+0zztIl9IVG X-Received: by 2002:a17:906:229b:: with SMTP id p27mr11963184eja.287.1614539075736; Sun, 28 Feb 2021 11:04:35 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1614539075; cv=none; d=google.com; s=arc-20160816; b=VyBSXPWbb8LTGuebNQCN+ANIflGe6/ECHSl2N2G0B0EsU9E+URc0S5B8U4Egx8uQg1 IPXTG0SwzHxiCFe8f3bxroGDH7XQxmb+qT4mHNGL1vQ4E6gHOQbgcdakCstmrg/ehZue TTI2wmN0QotKXJ70xyNJJKiXfRI7rpBvqubTlwRgkXEBsdfQAOOTNK1ElPOlT9YmFcC6 0YPUop5Z603FSWjdo/Jq+QGOb7SLaf7noUaku3QRnxbBvq+h1yIqbxgOZ2O8p/PvRchm RMMzQfwoEVggQp+XF0sMCnmUDhR20Bi9amJ/+zWl6ZK+rXtdd6X3ARJNlSNU1AGm/76z ZpQw== 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=PYbd8W2ERsYmeYVUmOtaj2jhrGyioWCUfE9oukXAhNE=; b=IAVvKHT1aAGWFVDdNdfjAXjHtkvOzl/kenaS3NDyCZoa/amzOELVFBrSHCIRQy910K yTJDukAZpeYW8RrDMCfxWdRRZxqI2piGVWr96SkXLpkpFTHnm7Ex1sWS2FS4L1g174yD 9fVmKy3P01tvbBCC1ntU0QnbueCBCI8y4Wt9WYf6QjParCWCwh2g2yQ7ER5zNLDIr7UN xgqT2JErmHskDG3SshuKiDxjRYZALFzCmIDF5X52b0QwwvArRSUE2VdOLqRHmHrjyYhr npY6gztRKKAJog/GVkFUv1eq1NonpIfO4Qlu/1OmRjlJMoYxUs2LF6ai5UU2ksO4+7K6 cHHA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linux-foundation.org header.s=google header.b=ESt51xZ6; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id r11si1054961eja.563.2021.02.28.11.04.12; Sun, 28 Feb 2021 11:04:35 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@linux-foundation.org header.s=google header.b=ESt51xZ6; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231314AbhB1RrT (ORCPT + 99 others); Sun, 28 Feb 2021 12:47:19 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56486 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231267AbhB1RrR (ORCPT ); Sun, 28 Feb 2021 12:47:17 -0500 Received: from mail-lj1-x22a.google.com (mail-lj1-x22a.google.com [IPv6:2a00:1450:4864:20::22a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 26BDFC061786 for ; Sun, 28 Feb 2021 09:46:37 -0800 (PST) Received: by mail-lj1-x22a.google.com with SMTP id y12so3760232ljj.12 for ; Sun, 28 Feb 2021 09:46:37 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux-foundation.org; s=google; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=PYbd8W2ERsYmeYVUmOtaj2jhrGyioWCUfE9oukXAhNE=; b=ESt51xZ6j8z3R2C13hvhPuz4+dqFbpWeLIYeBC/785+e7TMpGjVvwbZTyBbXYiywNg tUHY8gJUP0ZFuwgthF/ITRSf89SQUxz6/1OZcinYsJAnQktW5vMYNpGD6j8iTXw9vQic +l1XcmZmM6okfi0xWyf/k8Pd9YahI3rTnu4CM= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=PYbd8W2ERsYmeYVUmOtaj2jhrGyioWCUfE9oukXAhNE=; b=ex3q6IJ71ttgW6vLuumF51Ek4xW/5fvkVpbhiUXJIa83XdBiyJRo224VCfXAruYgNj LIENC/GwvjYeObnJceeAMfuhLpsG63gmZ5zLG/Xs38VfghJRG57rpcPD2VZLJjz2Vf+x YIPV2weZo5W7wnk2gXHcU1NoCKem4UZJC53l+aYF5/pPhCX37WS+njoGNLIRi9nRfPdA Heg0JtkwalRl6epNNLYEu4lLD4q0yMBNLDmWJqwt8K39b6sSl38TzHsqm7K9fkR8HyHL bYlDN6eSkcc7HW8Nt25ZOM6/mwBT90p/denP8BUdk0kTsyD0Ha/bVW5xZEFOJG0hjxz8 gh6w== X-Gm-Message-State: AOAM5317Qsdclsu7TtvC35dPKWtu9h2EopkMS6C/9PcSt8hQnSymqHqM IsWV5Pgb+Nf592ndJhL1s8QxZuGWjgHNBg== X-Received: by 2002:a2e:8047:: with SMTP id p7mr1124490ljg.8.1614534395099; Sun, 28 Feb 2021 09:46:35 -0800 (PST) Received: from mail-lj1-f176.google.com (mail-lj1-f176.google.com. [209.85.208.176]) by smtp.gmail.com with ESMTPSA id t142sm1812154lff.255.2021.02.28.09.46.34 for (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Sun, 28 Feb 2021 09:46:34 -0800 (PST) Received: by mail-lj1-f176.google.com with SMTP id p15so7766852ljc.13 for ; Sun, 28 Feb 2021 09:46:34 -0800 (PST) X-Received: by 2002:a05:651c:3c1:: with SMTP id f1mr6158938ljp.507.1614534393744; Sun, 28 Feb 2021 09:46:33 -0800 (PST) MIME-Version: 1.0 References: In-Reply-To: From: Linus Torvalds Date: Sun, 28 Feb 2021 09:46:17 -0800 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: [PATCH 00/11] pragma once: treewide conversion To: Alexey Dobriyan , Luc Van Oostenryck Cc: Linux Kernel Mailing List , Andrew Morton , Sparse Mailing-list Content-Type: text/plain; charset="UTF-8" Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Sun, Feb 28, 2021 at 8:57 AM Alexey Dobriyan wrote: > > This is bulk deletion of preprocessor include guards and conversion > to #pragma once directive. So as mentioned earlier, I'm not 100% convinced about the advantage of #pragma once. But I decided to actually test it, and it turns out that it causes problems for at least sparse. Sparse *does* support pragma once, but it does it purely based on pathname equality. So a simple test-program like this: File 'pragma.h': #pragma once #include "header.h" works fine. But this doesn't work at all: #pragma once #include "./header.h" because it causes the filename to be different every time, and you eventually end up with trying to open "././....../pragma.h" and it causes ENAMETOOLONG. So at least sparse isn't ready for this. I guess sparse could always simplify the name, but that's non-trivial. And honestly, using st_dev/st_ino is problematic too, since (a) they can easily be re-used for generated files (b) you'd have to actually open/fstat the filename to use it, which obviates one of the optimizations Trying the same on gcc, you don't get that endless "add "./" behavior" that sparse did, but a quick test shows that it actually opens the file and reads it three times: once for "pramga.h", once for "./pragma.h" and a third time for "pragma.h". It only seems to _expand_ it once, though. I have no idea what gcc does. Maybe it does some "different name, so let's open and read it, and then does st_dev/st_ino again". But if so, why the _third_ time? Is it some guard against "st_ino might have been re-used, so I'll open the original name and re-verify"? End result: #pragma is fundamentally less reliable than the traditional #ifdef guard. The #ifdef guard works fine even if you re-read the file for whatever reason, while #pragma relies on some kind of magical behavior. I'm adding Luc in case he has any ideas of what the magical behavior might be. Honestly, I think #pragma once is complete garbage. It's really is fundamenetally more complicated than the #ifdef guard, and it has absolutely zero upsides. I'm not taking this pramga series unless somebody can explain why it's a good thing. Because all I see are downsides. Linus