Received: by 10.192.165.156 with SMTP id m28csp2670709imm; Sun, 15 Apr 2018 06:31:06 -0700 (PDT) X-Google-Smtp-Source: AIpwx4/ZwxhqxyPUYLOIBNm4mX94r8O6SsOwMNh9oE3H7rUKolZ5TbxV/7/c3rG2LtuL4XNkmmZK X-Received: by 2002:a17:902:bd95:: with SMTP id q21-v6mr3948401pls.150.1523799066847; Sun, 15 Apr 2018 06:31:06 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1523799066; cv=none; d=google.com; s=arc-20160816; b=ZOpUnnAb6NKqRV+nAhSz4T/pMyzrtVPrneOAkOxrSu1RjJYdsCDnLUrFEMbqiAmKSd beOl53v6lo6U95FGjv27wNkxIeG+Zk0Fr9URfqIZmVvl9pjG5r1wj/XDnHVSJcgh88Mo C13OtjcJukq5ks9rpyNmnGrGwgLN/4W9+xeE9hWDWy6Q+zG91BI6lGZxhIECIcFnNhQY 92s4jp1M9Ris/aIbSk/+T+Q8frV4bavy9mv6Y97JpBNIW4QhmOxBZdOb39z4/IkFfnR9 oeViMT1M+t4D998hvRESkpuQVxrcCOlhFz70kKK/UwI4hOHZDDfuvRmYda1NzFu1Zi57 Tt2A== 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 :references:in-reply-to:mime-version:dkim-signature:dkim-filter :arc-authentication-results; bh=xQ1bJ+DyU2Gbt8kM5lFPU8AHEkz/3Dgma0aoqg6lJ0A=; b=rgZ8X6292uWO2YUUpGyFlvPNhsuxd461iCO63teAy9YHCeIGBkdgfE0POwyg1dhgfY BgQSXw9wLo8rtioC7JjbSWy8nKB+IxbKRa6a8FsWb0/8KT2LMNWo2EwdBL/RzqLEfd0E leO9hKLWz4FC+d1AUgV53gjFtTkE2frrgDQ6yGnmygBW+Qlvmi6mfIL3JpbxkiOVRiIS Qgl6dW2qp6bRKp6DC81Tw2T3SvUnpMvFg8PSmS8LDcA27Ohq7V3M3Rs7eX/vv/iaEOyI 2lHT4G9T7RhSZObFHszN2dzYw6bHfVIR/oXldizk+W+fdhI1/mU23HUUfRY99PrKIyZZ DRTQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@nifty.com header.s=dec2015msa header.b=ZJpNypDE; 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 l4si4315694pgc.374.2018.04.15.06.30.53; Sun, 15 Apr 2018 06:31:06 -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; dkim=pass header.i=@nifty.com header.s=dec2015msa header.b=ZJpNypDE; 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 S1752488AbeDON3W (ORCPT + 99 others); Sun, 15 Apr 2018 09:29:22 -0400 Received: from conssluserg-05.nifty.com ([210.131.2.90]:30872 "EHLO conssluserg-05.nifty.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752403AbeDON3U (ORCPT ); Sun, 15 Apr 2018 09:29:20 -0400 Received: from mail-ua0-f174.google.com (mail-ua0-f174.google.com [209.85.217.174]) (authenticated) by conssluserg-05.nifty.com with ESMTP id w3FDT3Pp025443; Sun, 15 Apr 2018 22:29:04 +0900 DKIM-Filter: OpenDKIM Filter v2.10.3 conssluserg-05.nifty.com w3FDT3Pp025443 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nifty.com; s=dec2015msa; t=1523798944; bh=xQ1bJ+DyU2Gbt8kM5lFPU8AHEkz/3Dgma0aoqg6lJ0A=; h=In-Reply-To:References:From:Date:Subject:To:Cc:From; b=ZJpNypDEkdB8+gHeSalvuP39ipiDRUGOhvdGPbS+12GkiGmV2ofZlbZNbtPmvcdjY Ug0WlpHrnNwXZa+gE5F7LgUmJj4yGQ0sUFfW7X+RcXJB61sheQkG358zeWcP07VPG7 h0OXTfjP5YHcLCyL4K+vJJR/S4rY1TZIDoCS7N8/nsfQ4uafCbOafIM/52XMrfnGEG dsC57UTatrAW3YCUD5jrcaOdSIw2Ee4HjsLevDOhAfveWz0N/hd30uOsJRDgwNzfZx KsfKWXhedn+YK+9YTotLgiKAywa25SuuQefwoyWPDS6MPPA6BzQ/g5bFypH8yT5xPZ ho1zgn+IqaeIQ== X-Nifty-SrcIP: [209.85.217.174] Received: by mail-ua0-f174.google.com with SMTP id d3so8158276uae.4; Sun, 15 Apr 2018 06:29:04 -0700 (PDT) X-Gm-Message-State: ALQs6tBNyWXsbvPRXqMAZ9aSv5XrqPWqhvHzs56u+/jCKObx4iSUTnoA nP3VfFvJPDagANaDwvS7ktwGZmvez4OgBtOjd44= X-Received: by 10.176.22.3 with SMTP id k3mr4866181uae.52.1523798942863; Sun, 15 Apr 2018 06:29:02 -0700 (PDT) MIME-Version: 1.0 Received: by 10.176.85.216 with HTTP; Sun, 15 Apr 2018 06:28:22 -0700 (PDT) In-Reply-To: References: <1523595999-27433-1-git-send-email-yamada.masahiro@socionext.com> <1523595999-27433-22-git-send-email-yamada.masahiro@socionext.com> From: Masahiro Yamada Date: Sun, 15 Apr 2018 22:28:22 +0900 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: [PATCH 21/30] stack-protector: test compiler capability in Kconfig and drop AUTO mode To: Linus Torvalds Cc: Kees Cook , linux-kbuild , Sam Ravnborg , Ulf Magnusson , Nicholas Piggin , Emese Revfy , X86 ML , LKML 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 2018-04-14 3:11 GMT+09:00 Linus Torvalds : > On Fri, Apr 13, 2018 at 9:41 AM, Kees Cook wrote: >> >> How about something like this instead: > > I'd rather avoid the ifdef's in the Makefile if at all possible. > > I'd rather expose this as a Kconfig rule, and in the Kconfig just have > an entry something like this > > config STACKPROTECTOR_FLAGS > string > default "-fstack-protector-strong" if CC_STACKPROTECTOR_STRONG > default "-fstack-protector" if CC_STACKPROTECTOR > default "-fno-stack-protector" if CC_HAS_STACKPROTECTOR_NONE > default "" > > which is really simple and straightforward. In the presense of > multiple defaults, the first is picked, so this _automatically_ does > that whole priority ordering. > > And then the Makefile can just have > > KBUILD_CFLAGS += $(CONFIG_STACKPROTECTOR_FLAGS) > > which seems much simpler. This has a minor problem. A string type symbol encloses a value with "..." like CONFIG_STACKPROTECTOR_FLAGS="-fstack-protector-strong" I think the least ugliest notation to rip off "..." is to do like follows: KBUILD_CFLAGS += $(CONFIG_STACKPROTECTOR_FLAGS:"%"=%) > It also makes more complex conditionals easier (ie different compilers > with different flags, since clang sometimes does the same thing with > another flag name), so I'd rather see this pattern in general. > > I'd also *much* rather do as much as possible at Kconfig time compared > to build time. Maybe it's just shifting the costs around, but the less > "clever" things we ask "make" to do, the better. > > I find our Makefiles an odd combination of really clean and simply > (the ones that just have "obj-$(CONFIG_X) += xyz.o" are just lovely) > and completely incomprehensible (all of our infrastructure support for > the simple stuff). > > I'd rather have more of the simple stuff in Makefiles, less of the > complex conditionals. > > Linus You showed a preference of the following, CONFIG_XYZ bool "Enable xyz" depends on $(cc-option -fxyz) CONFIG_XYZ_FLAGS string "-fxyz" if XYZ Then, in Makefile KBUILD_CFLAGS += $(CONFIG_XYZ_FLAGS:"%"=%) Users usually say y/n to a question "do you want to use xyz?" So, if you make this a general pattern, it would require one additional symbol to convert a bool symbol to a string. I think the following was your original idea. CONFIG_XYZ bool "xyz" depends on $(cc-option -fxyz) Then, in Makefile KBUILD_CFLAGS-$(CONFIG_XYZ) += -fxyz Both notations have pros/cons, but I slightly prefer the latter at the moment of time. There are some complicated cases such as stack protector flags. Your idea, config STACKPROTECTOR_FLAGS string default "-fstack-protector-strong" if CC_STACKPROTECTOR_STRONG default "-fstack-protector" if CC_STACKPROTECTOR default "-fno-stack-protector" if CC_HAS_STACKPROTECTOR_NONE default "" works fine since the first visible default is picked. In my Makefile ... stackp-flags-$(CONFIG_CC_HAS_STACKPROTECTOR_NONE) := -fno-stack-protector stackp-flags-$(CONFIG_CC_STACKPROTECTOR) := -fstack-protector stackp-flags-$(CONFIG_CC_STACKPROTECTOR_STRONG) := -fstack-protector-strong KBUILD_CFLAGS += $(stackp-flags-y) the last one is picked. IMHO, they are tied in terms of "cleanness". Perhaps I may miss something, but we will have more time to consider which approach is better. -- Best Regards Masahiro Yamada