Received: by 2002:a05:6a10:f347:0:0:0:0 with SMTP id d7csp7650489pxu; Fri, 25 Dec 2020 23:56:46 -0800 (PST) X-Google-Smtp-Source: ABdhPJyUELHj38w4BAqo1BrjtwLrANOly0Csbl0tJtf+T4uc+7XAqvV1qaKglx9r65eijJsYdgMZ X-Received: by 2002:a05:6402:229c:: with SMTP id cw28mr34432949edb.285.1608969406541; Fri, 25 Dec 2020 23:56:46 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1608969406; cv=none; d=google.com; s=arc-20160816; b=RKfg+ooqshnUIOOeQYc7uq4S1FOX+HrN7Ig419hvde35TUpDlm5nb2BmBxWV3aodZS fi/Zp79/PYzHGpURQjsU0V16ZKAVR7lmvk+xGRW/NJlX85DjxD83AYmBPhmLK1WlTLev 4EjE/IXW/nlrlAVuYHP8Xl5c39MR1hRVzyRpzPrIX9GykqJuLvePzi5YxzqnmK+63Mc0 aXRPqWg1uRWOmJkmn/gQd0+ZLGtQUIYRnpqsIGl8lz32h+ZpzBn0BFvgZyUZGej+wieZ CK1O0knsFEHNVzSwWizBj4l0vGYV2/WAoVqvbqF0Y7jrQ4Gy1T1w7ILiA+B1BMLgU5tw 3Dfg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-transfer-encoding :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:dkim-signature; bh=NGNEUvGMlB9kamBKy3F0042bww9MOHsmz3qAxswwrG4=; b=sgHBZ+hA1B1pFEgiLuk7Q8i+I6HZYSHghpE0ML/EgVY+0PD4laOHvTpgtIWS2c8eiX LspsMTvdhMn2cJyR8/wCF55dN4dnPMjdPIF5PDYT0qeqxdpk4qsNRC0dQjRJSm12zoH0 4OzSdIBMeF37OYNyQY4cjVx1MFCgQWE/nolwbrgs192RU3Rc77+XSPavTzk+ZBUXy6Nj TVjWYnLQuTau7xUgN2Ibr8USWFz+uD6+UvfMPKDQq39gpGCmoK9mMwyBTy+omrI5r7Er ONhtBAQVzgpA55JwcmASA66HR50/15M0JaRgIikKK56zuS2P/Uu+TwMXeqKr1+WZagwr jIlw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=QMo9OLxc; 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=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id y17si15049054ejb.713.2020.12.25.23.56.23; Fri, 25 Dec 2020 23:56:46 -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=@gmail.com header.s=20161025 header.b=QMo9OLxc; 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=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726045AbgLZHya (ORCPT + 99 others); Sat, 26 Dec 2020 02:54:30 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41552 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725809AbgLZHya (ORCPT ); Sat, 26 Dec 2020 02:54:30 -0500 Received: from mail-io1-xd2f.google.com (mail-io1-xd2f.google.com [IPv6:2607:f8b0:4864:20::d2f]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 59C21C061757 for ; Fri, 25 Dec 2020 23:53:50 -0800 (PST) Received: by mail-io1-xd2f.google.com with SMTP id p187so5255233iod.4 for ; Fri, 25 Dec 2020 23:53:50 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:content-transfer-encoding:in-reply-to; bh=NGNEUvGMlB9kamBKy3F0042bww9MOHsmz3qAxswwrG4=; b=QMo9OLxcp57tzIXTLcYu/cpoXyjzH4RaNogkFGC/nuZcnrz13coab8rlNyOdd6OCY1 kH5ecgFVHeKxhAB6V5p8mct3qmsSWrlFgXDws5Bu3kQqVWWh8+Q9ZylJRehKV8kV8vaB 26KVR9xF27o0kkrd6MQ1lm3WurGbeFYfPheveWUx1CVrnu85EILoraNcJ2H0Gj7ELma9 N5n5k+GItpim1daYRBobVXbGIl0aY6ob6++nuxW4YXYXRWBWmRzX05kw4x5nNgU78pTW rOGrc4QVZitsaTYKdjMTD4A0lHxxUXRpikifrwnYVSx2PbaOk3k511p+Gt5FX3/ku5Jp zN9A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:content-transfer-encoding :in-reply-to; bh=NGNEUvGMlB9kamBKy3F0042bww9MOHsmz3qAxswwrG4=; b=RBcOz8acqUPhCyFmiEGVzVsXVOoStjObrZD586GsESEiUEfn/vbaztrY2JOXj8xFA5 l7ZGwLoJuQRloEvm8iI/I9XmV/zb2kfDMGGzWz+3RT8UJs04QZYfVtRc1q06cbGtGlgV No6YwdAMaP8bTApEGBa4m1tghGnh0/Zof1pDU41c07x8M22dfiYQX3hg6GAt4qN9S0QG Escf6ldgTFMvvIw7zzwCeLgCo9+ENKH1TkUGCf0URaI7QuXW2i+Q4mCBYf/eLbMgoKSN jlSFxN9h1c+igxv0FTanSFWc2T88g+d+Dp6pUqgWcR0iaHvYdZdsp835jy4r50Ugc04L drag== X-Gm-Message-State: AOAM531jAZ9zyQGWSzA2NXTJG4UGzBmGYLbZOah/oUkhnGFEROCWHUZ1 nNL9fv76sa8mFDtHILycG7g= X-Received: by 2002:a02:3f62:: with SMTP id c34mr32162065jaf.16.1608969229712; Fri, 25 Dec 2020 23:53:49 -0800 (PST) Received: from ubuntu-m3-large-x86 ([2604:1380:45f1:1d00::1]) by smtp.gmail.com with ESMTPSA id b12sm23205166ilc.21.2020.12.25.23.53.48 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 25 Dec 2020 23:53:49 -0800 (PST) Date: Sat, 26 Dec 2020 00:53:47 -0700 From: Nathan Chancellor To: hpa@zytor.com Cc: John Millikin , x86@kernel.org, linux-kernel@vger.kernel.org, clang-built-linux@googlegroups.com, Thomas Gleixner , Ingo Molnar , Borislav Petkov , John Millikin Subject: Re: [PATCH] arch/x86: Propagate $(CLANG_FLAGS) to $(REALMODE_FLAGS) Message-ID: <20201226075347.GA1977841@ubuntu-m3-large-x86> References: <37DE7046-5096-4C0C-A96D-FD168A849DFD@zytor.com> MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <37DE7046-5096-4C0C-A96D-FD168A849DFD@zytor.com> Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, Dec 25, 2020 at 11:35:28PM -0800, hpa@zytor.com wrote: > On December 25, 2020 11:29:30 PM PST, John Millikin wrote: > >When compiling with Clang, the `$(CLANG_FLAGS)' variable contains > >additional flags needed to cross-compile C and Assembly sources: I am not sure how or if others agree but it took me a second to realize the purpose of this change was cross compiling even though I read the commit message so I think it should be called out a bit more. I would argue that it is not very common to see x86 cross compiled (I know Stephen Rothwell does) :) x86 is one of the most tested architectures for building with clang and we have see no recent failures in the boot or realmode code. > >* `-no-integrated-as' tells clang to assemble with GNU Assembler > >? instead of its built-in LLVM assembler. This flag is set by default > >? unless `LLVM_IAS=1' is set, because the LLVM assembler can't yet > >? parse certain GNU extensions. > > > >* `--target' sets the target architecture when cross-compiling. This > >? flag must be set for both compilation and assembly (`KBUILD_AFLAGS') > >? to support architecture-specific assembler directives. > > > >Signed-off-by: John Millikin > >--- > >?arch/x86/Makefile | 5 +++++ > >?1 file changed, 5 insertions(+) > > > >diff --git a/arch/x86/Makefile b/arch/x86/Makefile > >index 7116da3980be..725c65532482 100644 > >--- a/arch/x86/Makefile > >+++ b/arch/x86/Makefile > >@@ -33,6 +33,11 @@ REALMODE_CFLAGS += -ffreestanding > >?REALMODE_CFLAGS += -fno-stack-protector > >?REALMODE_CFLAGS += $(call __cc-option, $(CC), $(REALMODE_CFLAGS), > >-Wno-address-of-packed-member) > >?REALMODE_CFLAGS += $(call __cc-option, $(CC), $(REALMODE_CFLAGS), > >$(cc_stack_align4)) > >+ > >+ifdef CONFIG_CC_IS_CLANG > >+REALMODE_CFLAGS += $(CLANG_FLAGS) > >+endif > >+ > >?export REALMODE_CFLAGS > >? > >?# BITS is used as extension for files which are available in a 32 bit > > Why is CLANG_FLAGS non-null when unused? It would be better to centralize that. It isn't. $ rg "CLANG_FLAGS :=" Makefile 507:CLANG_FLAGS := $ rg "CLANG_FLAGS\t" Makefile 564:CLANG_FLAGS += --target=$(notdir $(CROSS_COMPILE:%-=%)) 566:CLANG_FLAGS += --prefix=$(GCC_TOOLCHAIN_DIR)$(notdir $(CROSS_COMPILE)) 570:CLANG_FLAGS += --gcc-toolchain=$(GCC_TOOLCHAIN) 573:CLANG_FLAGS += -no-integrated-as 575:CLANG_FLAGS += -Werror=unknown-warning-option The ifdef can be dropped and unconditonally add CLANG_FLAGS to REALMODE_CFLAGS, as is done in a few arch directories: $ rg "\(CLANG_FLAGS\)" arch | cat arch/s390/purgatory/Makefile:KBUILD_CFLAGS += $(CLANG_FLAGS) arch/s390/Makefile:KBUILD_AFLAGS_DECOMPRESSOR := $(CLANG_FLAGS) -m64 -D__ASSEMBLY__ arch/s390/Makefile:KBUILD_CFLAGS_DECOMPRESSOR := $(CLANG_FLAGS) -m64 -O2 arch/powerpc/boot/Makefile:BOOTCFLAGS += $(CLANG_FLAGS) arch/powerpc/boot/Makefile:BOOTAFLAGS += $(CLANG_FLAGS) Cheers, Nathan