Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp745579pxj; Thu, 13 May 2021 16:14:11 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwJxxoVpmCfGg1bTl2DOTeOeUQxuP7wPWuLhTP+GCat7Yl2LoZtrvitA57uagPAbBk5oYxR X-Received: by 2002:a17:906:bcd6:: with SMTP id lw22mr1223341ejb.250.1620947651005; Thu, 13 May 2021 16:14:11 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1620947650; cv=none; d=google.com; s=arc-20160816; b=QH5N+jcfdtKoCdjd6ALJZUcms42eoZ9IOvTt2NeBy4npryH71Mqk46aKNMqre7Oc4y MSNFfE2E1HCT037JU/+/2L8vfGIBSE6bDw1yuYIKCJaozHTOPXmWH38hBwove8lAKMKV LLTmr8SgEpfXSyMCUFUdYFlqxQWUICoE4YE15XbNUU69uJG1+Bs/3mgZNNm7OcjhS/J0 pXEtLQSGXOibtQtzOr04pPUOFqMMG17lNPmE4397NGGLJqzMC2MMmyw9yREK8Qznt+s0 CkRO85iOYm2L1N9buQYEYgTeStOzY86cIJdyZYT0hqIK4mc5xs5OJnusLeA2JZOqC7oq NhKw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:content-language :in-reply-to:mime-version:user-agent:date:message-id:from:references :cc:to:subject:dkim-signature; bh=z5gace/o+tdlAl+9tHx+rNdCBiX9JxlEA+gJY/6/jpI=; b=KcG9NvHSS8341aTDg/9GZg3Fs3tVDAlbylCpdoy0TptWhnkEwsp4l0Lyyq1IKdjCiR lcudo0vu24814uKQulrjj6NP12+Ki147hjuKdldfmYgIOptQQMbx/pRl+tgtdaSYNPXc Y1UJl2VRngE8oVr2FKH07aQzWg08xOivHujLxLH6ZLq3cVQG4b+j3zfr+wG61L7jVE5i 0zFQOb4WKQ8A/vrRnr7WfP3olqrHusluv7GHg2s7ijo9qlFWs3Z4FMQsREMXWEh4j7V4 VSKc/EOI/mkH236p7y8EKfvyzr4EEZQtrw0kS7g+OCIoIm8+tnkxa+T/B2GHSTg5qOlg KCjA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=jbm4kRsm; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id k1si4319202ejp.353.2021.05.13.16.13.45; Thu, 13 May 2021 16:14:10 -0700 (PDT) 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=@kernel.org header.s=k20201202 header.b=jbm4kRsm; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231926AbhEMTA1 (ORCPT + 99 others); Thu, 13 May 2021 15:00:27 -0400 Received: from mail.kernel.org ([198.145.29.99]:46444 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230352AbhEMTA0 (ORCPT ); Thu, 13 May 2021 15:00:26 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 9ED4061264; Thu, 13 May 2021 18:59:15 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1620932356; bh=CNlWPuDlH4KO4XDrkInCB6C/vySWY4yRCKjQVEyQquI=; h=Subject:To:Cc:References:From:Date:In-Reply-To:From; b=jbm4kRsmye3VePuEY0uiOXpxuAR45Yth9vGMIuLZA/281w7viNipT9Pkj3hSuhNTn MROnDhqdIMGP1KxFI7cRE15VJR7+3Eyn9jV6EythV+BQZDuC8abju9f7vBEEmCxQOe e2ZWWrYSP7vodJweDjUZtwu5NYx0o6skn/u4qy1SdvhyIJzjMNdEVcybKv6cQ/Ckyo QkZXXiGDcBrmK9nDJ1i3SFQdmBOgaWtfMzZUWJU0NTL2e3QSfuGTucKEPA1bhpNx+7 eyWaWJq8HO+8+iHN3d1RoVR66e8oTcxfKqlB3E94hEyffhJ89wsxwaj61l4MIQFXu+ mjBK0ZitZL/SA== Subject: Re: [PATCH kernel v3] powerpc/makefile: Do not redefine $(CPP) for preprocessor To: Alexey Kardashevskiy , linuxppc-dev@lists.ozlabs.org Cc: linux-kernel@vger.kernel.org, linux-kbuild@vger.kernel.org, clang-built-linux@googlegroups.com, Nick Desaulniers , Michal Marek , Michael Ellerman , Masahiro Yamada , Segher Boessenkool References: <20210513115904.519912-1-aik@ozlabs.ru> From: Nathan Chancellor Message-ID: Date: Thu, 13 May 2021 11:59:14 -0700 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:78.0) Gecko/20100101 Thunderbird/78.10.1 MIME-Version: 1.0 In-Reply-To: <20210513115904.519912-1-aik@ozlabs.ru> Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 7bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 5/13/2021 4:59 AM, Alexey Kardashevskiy wrote: > The $(CPP) (do only preprocessing) macro is already defined in Makefile. > However POWERPC redefines it and adds $(KBUILD_CFLAGS) which results > in flags duplication. Which is not a big deal by itself except for > the flags which depend on other flags and the compiler checks them > as it parses the command line. > > Specifically, scripts/Makefile.build:304 generates ksyms for .S files. > If clang+llvm+sanitizer are enabled, this results in > > -emit-llvm-bc -fno-lto -flto -fvisibility=hidden \ > -fsanitize=cfi-mfcall -fno-lto ... > > in the clang command line and triggers error: > > clang-13: error: invalid argument '-fsanitize=cfi-mfcall' only allowed with '-flto' > > This removes unnecessary CPP redefinition. Which works fine as in most > place KBUILD_CFLAGS is passed to $CPP except > arch/powerpc/kernel/vdso64/vdso(32|64).lds. To fix vdso, this does: > 1. add -m(big|little)-endian to $CPP > 2. add target to $KBUILD_CPPFLAGS as otherwise clang ignores -m(big|little)-endian if > the building platform does not support big endian (such as x86). > > Signed-off-by: Alexey Kardashevskiy > --- > Changes: > v3: > * moved vdso cleanup in a separate patch > * only add target to KBUILD_CPPFLAGS for CLANG > > v2: > * fix KBUILD_CPPFLAGS > * add CLANG_FLAGS to CPPFLAGS > --- > Makefile | 1 + > arch/powerpc/Makefile | 3 ++- > 2 files changed, 3 insertions(+), 1 deletion(-) > > diff --git a/Makefile b/Makefile > index 15b6476d0f89..5b545bef7653 100644 > --- a/Makefile > +++ b/Makefile > @@ -576,6 +576,7 @@ CC_VERSION_TEXT = $(subst $(pound),,$(shell $(CC) --version 2>/dev/null | head - > ifneq ($(findstring clang,$(CC_VERSION_TEXT)),) > ifneq ($(CROSS_COMPILE),) > CLANG_FLAGS += --target=$(notdir $(CROSS_COMPILE:%-=%)) > +KBUILD_CPPFLAGS += --target=$(notdir $(CROSS_COMPILE:%-=%)) You can avoid the duplication here by just doing: KBUILD_CPPFLAGS += $(CLANG_FLAGS) I am still not super happy about the flag duplication but I am not sure I can think of a better solution. If KBUILD_CPPFLAGS are always included when building .o files, maybe we should just add $(CLANG_FLAGS) to KBUILD_CPPFLAGS instead of KBUILD_CFLAGS? > endif > ifeq ($(LLVM_IAS),1) > CLANG_FLAGS += -integrated-as > diff --git a/arch/powerpc/Makefile b/arch/powerpc/Makefile > index 3212d076ac6a..306bfd2797ad 100644 > --- a/arch/powerpc/Makefile > +++ b/arch/powerpc/Makefile > @@ -76,6 +76,7 @@ endif > > ifdef CONFIG_CPU_LITTLE_ENDIAN > KBUILD_CFLAGS += -mlittle-endian > +KBUILD_CPPFLAGS += -mlittle-endian > KBUILD_LDFLAGS += -EL > LDEMULATION := lppc > GNUTARGET := powerpcle > @@ -83,6 +84,7 @@ MULTIPLEWORD := -mno-multiple > KBUILD_CFLAGS_MODULE += $(call cc-option,-mno-save-toc-indirect) > else > KBUILD_CFLAGS += $(call cc-option,-mbig-endian) > +KBUILD_CPPFLAGS += $(call cc-option,-mbig-endian) > KBUILD_LDFLAGS += -EB > LDEMULATION := ppc > GNUTARGET := powerpc > @@ -208,7 +210,6 @@ KBUILD_CPPFLAGS += -I $(srctree)/arch/$(ARCH) $(asinstr) > KBUILD_AFLAGS += $(AFLAGS-y) > KBUILD_CFLAGS += $(call cc-option,-msoft-float) > KBUILD_CFLAGS += -pipe $(CFLAGS-y) > -CPP = $(CC) -E $(KBUILD_CFLAGS) > > CHECKFLAGS += -m$(BITS) -D__powerpc__ -D__powerpc$(BITS)__ > ifdef CONFIG_CPU_BIG_ENDIAN >