Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp870379imu; Mon, 5 Nov 2018 10:00:13 -0800 (PST) X-Google-Smtp-Source: AJdET5c8uGciEJxnWgcPBDsJZV2nzOMi+D6B6bZ8Al8AJA+7ugAC7zGqmuzk+4nsSzM+INm4wtA2 X-Received: by 2002:a62:56dd:: with SMTP id h90-v6mr13095889pfj.225.1541440813766; Mon, 05 Nov 2018 10:00:13 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1541440813; cv=none; d=google.com; s=arc-20160816; b=aRokXKmPC8toNnPt+GmK4kMxLRKV4f+SibRLJDFCxwODSeD5Ke9R99+SguKM+xpLke WrhCbn088SjFGhHECbw9Ti6Dx+D15koJqusC81XquN5zvmtutrKwToD6yKGy+eAC+4U6 COmxSlONd39hkkN4uHbf85qlY57oaUA8l7oh9Rt3c+ApcIKpn6y70Q+UoH0GzONaYlK2 mBRWLGqJVPdpVSc1g0VFKDv3E9QDCYTR8q46rRTVEL0VXamN9Qwe0FEsfcOyC/GsIUCg oq9/vDbr9j93lNX5txA+UPnLv3UP3aJ9O6svvCEvP4TodNlsSypw1yi4l07MBr5SzZ/x EGoA== 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:dkim-signature; bh=XJirzculLSk5q3m7YlBP8o38DUdPeBuNIG5Fi2euPRE=; b=psthStF0KYst8A12lXFAe971cJ5EpXMkTCCYUZPjpAcUodmOpnRiNY7Xjm4+ByMLO5 74M5DsAmAgULpfpiuCAMBT5oyJZ2JrlM5c8Yzd6LuM1AoivU7MD+2tO4hZaoPPnG7dRH ZgDlCcZev1JL3wGRetVNlZgtG8H2mkQIeo1pRU7qONTtIFSvEic+nSY9vLV4otmtMW7p /+VLYlka7RCcgpvPZIx78FJRj2fbcRHeE9DNj1/Cr7YoySA4VwdObSsGgiZq1qJqC78S wGBs/TyEfYJ57Psp8rbs7ZkXbpKVfjQh7HOmBbuNC9E/gCrFfj2Ow600GJWu9U4Vlu7X 0HUw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=AMyvzpDV; 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; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id a144-v6si31447229pfd.138.2018.11.05.09.59.57; Mon, 05 Nov 2018 10:00:13 -0800 (PST) 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=@google.com header.s=20161025 header.b=AMyvzpDV; 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; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2387773AbeKFDUJ (ORCPT + 99 others); Mon, 5 Nov 2018 22:20:09 -0500 Received: from mail-pf1-f196.google.com ([209.85.210.196]:36032 "EHLO mail-pf1-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2387651AbeKFDUJ (ORCPT ); Mon, 5 Nov 2018 22:20:09 -0500 Received: by mail-pf1-f196.google.com with SMTP id j22-v6so4803060pfh.3 for ; Mon, 05 Nov 2018 09:59:21 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=XJirzculLSk5q3m7YlBP8o38DUdPeBuNIG5Fi2euPRE=; b=AMyvzpDVsy805XeIvLCqf/7hRBoNGNo2B+u+ZuxzBjYhG7DvkKkz3tsLVF0xwS8ZKB zacRiKG5mc3l6zjB86B8kb5c2XDNTea/RkDrVqP0xfOPLD54oUGULEIA229iAl2XcoT3 5s0noaU1q1SLuunvoPpe8iFlCPhe0WWIKrEa5cSApLijdzP76hBcYcUZwbL0CdlkmZhY FHjoL1tVR2xZEuT5wZ3ZqeXEr4Vr2JM3DfITOXb1kxMbf6Ge1Fu17suQapFEQRprf7Wg fqcDstiSxkyziEoRyrwpjwtsIavhq+K8vcD/xtmY3oDaG6xxC6jl2k+kbpYrxiihfGRK QfsQ== 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=XJirzculLSk5q3m7YlBP8o38DUdPeBuNIG5Fi2euPRE=; b=tYHTtrxDqPv/4d6pGQxZ/P8RXsAL8qmekzJAVP0UhWeZtuaMiM4Atw/ejjttUlARKh +pWmk+IUwg8HCiy7aj1sUghagRIKndWTJVBme5D3IbV9rKXykSg8+LHrfYS6G0puw3Zh eaKofxp9itgtT9IJfKsN4LkF3e7XWP6aIAQqnNVz6y+074ttMoGz3uzpdZUe+erxhpsE I3qhLvMKznc7Jcx61P0KQYDYPhohS3JDJz1REhuMNVTyH8jKf5pOA8NR/MuhJdu2Ku2p ENeHq/ANwwY0GIZsOQAMh1tO/uAL17hUyT8cn2isfDbMPH/R6hANuqzqRVxcxJfo2e7A jbwA== X-Gm-Message-State: AGRZ1gLgBniAAUCkwTN3BkC7S8jseZ/FItm7Kt/+7c5qZyxQRHcgLICG CFy52Ma+BnAjAv10BfxSQkva1TE8/dJSKZlQK6V2BA== X-Received: by 2002:a63:bf0b:: with SMTP id v11mr4550048pgf.302.1541440760891; Mon, 05 Nov 2018 09:59:20 -0800 (PST) MIME-Version: 1.0 References: <1541386099-13118-1-git-send-email-yamada.masahiro@socionext.com> In-Reply-To: From: Nick Desaulniers Date: Mon, 5 Nov 2018 09:59:09 -0800 Message-ID: Subject: Re: [PATCH] kbuild: consolidate Clang compiler flags To: Masahiro Yamada Cc: Stefan Agner , Linux Kbuild mailing list , Kees Cook , Matthias Kaehlcke , Chris Fries , joel@jms.id.au, dja@axtens.net, Michal Marek , 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 On Mon, Nov 5, 2018 at 1:19 AM Masahiro Yamada wrote: > > On Mon, Nov 5, 2018 at 6:10 PM Stefan Agner wrote: > > > > On 05.11.2018 03:48, Masahiro Yamada wrote: > > > Add basic options for Clang such as --target, --prefix, --gcc-toolchain, > > > -no-integrated-as to a single variable CLANG_FLAGS. > > > > > > Signed-off-by: Masahiro Yamada > > > --- > > > > > > Makefile | 13 ++++++------- > > > 1 file changed, 6 insertions(+), 7 deletions(-) > > > > > > diff --git a/Makefile b/Makefile > > > index 93315eb..58c838a 100644 > > > --- a/Makefile > > > +++ b/Makefile > > > @@ -487,18 +487,17 @@ endif > > > > > > ifneq ($(shell $(CC) --version 2>&1 | head -n 1 | grep clang),) > > > ifneq ($(CROSS_COMPILE),) > > > -CLANG_TARGET := --target=$(notdir $(CROSS_COMPILE:%-=%)) > > > +CLANG_FLAGS = --target=$(notdir $(CROSS_COMPILE:%-=%)) > > > GCC_TOOLCHAIN_DIR := $(dir $(shell which $(LD))) > > > -CLANG_PREFIX := --prefix=$(GCC_TOOLCHAIN_DIR) > > > +CLANG_FLAGS += --prefix=$(GCC_TOOLCHAIN_DIR) > > > > So this will expand later now, is this ok? > > > > -- > > Stefan > > > > > GCC_TOOLCHAIN := $(realpath $(GCC_TOOLCHAIN_DIR)/..) > > > endif > > > ifneq ($(GCC_TOOLCHAIN),) > > > -CLANG_GCC_TC := --gcc-toolchain=$(GCC_TOOLCHAIN) > > > +CLANG_FLAGS += --gcc-toolchain=$(GCC_TOOLCHAIN) > > > endif > > > -KBUILD_CFLAGS += $(CLANG_TARGET) $(CLANG_GCC_TC) $(CLANG_PREFIX) > > > -KBUILD_AFLAGS += $(CLANG_TARGET) $(CLANG_GCC_TC) $(CLANG_PREFIX) > > > -KBUILD_CFLAGS += $(call cc-option, -no-integrated-as) > > > -KBUILD_AFLAGS += $(call cc-option, -no-integrated-as) > > > +CLANG_FLAGS += $(call cc-option, -no-integrated-as) > > > +KBUILD_CFLAGS += $(CLANG_FLAGS) > > > +KBUILD_AFLAGS += $(CLANG_FLAGS) > > > CLANG_FLAGS is expanded here because KBUILD_CFLAGS and KBUILD_AFLAGS > are defined by using := > > So, it should be OK, but turning CLANG_FLAGS into a simple variable > will be a little more efficient since $(call cc-option, -no-integrated-as) > is evaluated just once. > > (Or, this cc-option may not be necessary any longer.) > > Will send v2. If the ultimate goal is not evaluate cc-option more than once, removing cc-option from both KBUILD_CFLAGS and KBUILD_AFLAGS for clang is the better approach; we always want those for clang unconditionally. And if you by chance have an ancient version of clang that doesn't support those flags, you wont be able to compile a kernel anyways. Eventually we want to get Clang's integrated assembler in shape to be used to assemble the kernel, but I think we're a ways off there still. -- Thanks, ~Nick Desaulniers