Received: by 2002:ac0:a5a6:0:0:0:0:0 with SMTP id m35-v6csp6943811imm; Tue, 28 Aug 2018 03:57:20 -0700 (PDT) X-Google-Smtp-Source: ANB0Vdb5VWGBy5zj4ZLrqc3DHYQ429Wug7kXMkO+PnUU8vUGkaeohgcTGRt7CBBatR0WNXAymILH X-Received: by 2002:a62:5a01:: with SMTP id o1-v6mr1027513pfb.0.1535453840351; Tue, 28 Aug 2018 03:57:20 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1535453840; cv=none; d=google.com; s=arc-20160816; b=O6SkO8AVt9lbYhmOp0zwtRZqTV5YCtW1J33oDky953e0uSFFbVjnwIkLJ/I8My/Frr 3bo8RR+2jFpVcm6Bok4EU5PtPMlOF6XFfC4+mvo/DbpWo7hHii9kXqXNaNM3o4BMOaKU 0pqvIjiVgI9nECUXiBJXBvN6CTw8jlvFqAdO85VFJw9HI13Q0M0b/YXlX6dvkIJT3ZvN nwdHa2fSOQko+UdVFvmkSBj2lnP7irCUqlgV5Nc19DcVjVd3wVtuicAJ13eCW53ABwqa WMoyzCpS5t8erF5wN4WGUtLDdXDE/tFBy1rLUSyojQsWdqJcTSHka4s83Xk0077CLzF0 ruXw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:arc-authentication-results; bh=6EyVnGzEXtmHDUZNpeAAbtRg/nqDNiWg+/uLUN1sf70=; b=e9U8sKJqvFM/5rrzUd2pNt2mqQFJ+PyefqeIUKndnH/1JZLvoVUtUBdFuip0dmc5qh HhRPUpbd0HSsHD/cHjlEcCXZjbKeSeYLbxk+sBegHmyIHNiY/BZysA5rvcv2SZDgVXDd vH1oVwllGOEAn6ft0vZheqOIagr8Nibt15u2qJ7tm1cU7F17k9B4HDANqcXjB8Is2VnS 2sudqqDUvbMSSR2XlWoX3m+bGHcChhcvlagsE8Z2kNuqF25rAOVa8lK+K8ijYsdNOggt UsizPLoLWDg92y0jf214wBs9Mt1+0fJkT+xf3O+UtMIFLeOHOH1X0gJnqpOO5YzhhMnK kVEQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id h7-v6si758477pgl.441.2018.08.28.03.57.04; Tue, 28 Aug 2018 03:57:20 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727502AbeH1OrE (ORCPT + 99 others); Tue, 28 Aug 2018 10:47:04 -0400 Received: from mail-qk0-f195.google.com ([209.85.220.195]:44323 "EHLO mail-qk0-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727104AbeH1OrE (ORCPT ); Tue, 28 Aug 2018 10:47:04 -0400 Received: by mail-qk0-f195.google.com with SMTP id d131-v6so634434qke.11; Tue, 28 Aug 2018 03:55:59 -0700 (PDT) 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=6EyVnGzEXtmHDUZNpeAAbtRg/nqDNiWg+/uLUN1sf70=; b=OmdgsBrUPcnhOWHwmCDOWp8ob1Vkwh+l+hyXFqpCjl4677Z9o9HhK+uZl9sqdQY75L HG30QNNhaiJSusIb9X2YWSIGZNjUwNGEBgTfHZaH1jIayxcX52UDVyo88V20zoKri+wE GePa2biaqxItfpKULd+38IoxmEbhcU+RvoyDWPpUVlID8BljKWNTdV6e5Xohy7kM1eCA 0S64H4w98I66+tMba6sg1rgi81Nhs5NIfUimitDwtSilpE7OWS99Nzy/G6FTYIIQwix6 odki9ic6LwbvkWrJTkuyzZuz6+EibAEX1L8Y14Peopce/gwSnyVmA7KsFfguEu0VgL7+ ASjQ== X-Gm-Message-State: APzg51DeDZcLbpERc7h0cJA8jBu+aMIPzoG/c7ISwEgWmDLKv+C3u4Jd AykX5vwlqDGLKE6Cr4P53FRSmwkvjg46zRXT7tM= X-Received: by 2002:a37:6b03:: with SMTP id g3-v6mr868366qkc.107.1535453758926; Tue, 28 Aug 2018 03:55:58 -0700 (PDT) MIME-Version: 1.0 References: <1535220989-27645-1-git-send-email-yamada.masahiro@socionext.com> <84cf6ae0-97c8-6b73-ca86-b3d3b3daba5b@pobox.com> <8d5cf8c6-556a-96a1-610d-c92355783a9f@pobox.com> In-Reply-To: <8d5cf8c6-556a-96a1-610d-c92355783a9f@pobox.com> From: Arnd Bergmann Date: Tue, 28 Aug 2018 12:55:42 +0200 Message-ID: Subject: Re: [PATCH v2] compiler.h: give up __compiletime_assert_fallback() To: daniel.santos@pobox.com Cc: Nick Desaulniers , Masahiro Yamada , Linus Torvalds , Kees Cook , Christopher Li , linux-sparse@vger.kernel.org, Linux Kernel Mailing List Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, Aug 27, 2018 at 10:44 PM Daniel Santos wrote: > > On 08/27/2018 03:09 PM, Nick Desaulniers wrote: > >> Now we're back to the question of "what do you mean by 'constant'"? If > >> you mean a C constant expression (as defined in the C standard) than > >> almost none of this code fits that criteria. For these compile-time > >> assertions to work, we are concerned with the data flow analysis and > >> constant propagation performed by the compiler during optimization. You > >> will notice in include/linux/compiler.h that __compiletime_assert is a > >> no-op when __OPTIMIZE__ is not defined. > > Depending on optimizations for static assertions sounds problematic. > > (with my best Palpatine voice) It is unavoidable. > > Actually it's theoretically possible, but the compiler would have to do > something akin to copying it's control flow graph et. al, run -O2-ish > optimizations, perform the static assertions and then throw away the > optimized control flow graph and emit code based upon the original. In the context of the kernel, compiling with anything less than -O2 or -Os is not an issue, we don't do it anyway. -O0 never worked, and AFAICT we only build one file with -O1, but that is something we can do away with as well: from fs/reiserfs/Makefile: # gcc -O2 (the kernel default) is overaggressive on ppc32 when many inline # functions are used. This causes the compiler to advance the stack # pointer out of the available stack space, corrupting kernel space, # and causing a panic. Since this behavior only affects ppc32, this ifeq # will work around it. If any other architecture displays this behavior, # add it here. ccflags-$(CONFIG_PPC32) := $(call cc-ifversion, -lt, 0400, -O1) Arnd