Received: by 2002:a05:6902:102b:0:0:0:0 with SMTP id x11csp890249ybt; Wed, 1 Jul 2020 12:35:53 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwTTgYXVzaocZEVxwVtbjss0x77JrfduWA/HjvTvCnubMBJ1ZhWwEbT5ZZDbf6qWZ/IWox4 X-Received: by 2002:a50:d78f:: with SMTP id w15mr32167152edi.245.1593632153236; Wed, 01 Jul 2020 12:35:53 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1593632153; cv=none; d=google.com; s=arc-20160816; b=tu7za598USMupjLBiVUtvwxtnhU3/qIGR+zHHucun/AZPHrH5rDaepooaTjSpDWNQy 6ukiot4qRkryvGRujHxaDGZ3iD7NMd48xbMA7uAf8sjsl11A5xSf2rC9uBKCgzhQqA9Q ok1tNSIeJqhb8NUruNWKSxsz2PcIWnzRfDZF9w0NGEnu2I+x58YQ/8FOz9c5mgzKSKsX FpNfraBOzjSd+mnB4Oj5FL6vx/eG2vdlzCV8wXdPn/dk2TtfEPewU4+s7dEQETmP8Wey kdrLnvQDycJ5c64lWMe/7rliql0EFQ+ggbYS3Xs313TJm6gfqgXMDaPWA2CHd0mQd5FB ncVQ== 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:dkim-filter; bh=M049TJy/cPQkzAutDxghwHrAKGcacxHbM+3c0nlXY9g=; b=eAfv+hRV+VYJsCiWEfhOnWmto8MRFNROibOpcZM3ZK/ZelKKehwNlmbqOjRSEmYde4 Ui5LJmT/Do1PigHi14CQtvUEIFOflmunicM0TqrxCH1kc81fLQioMgjd27I/YMo6qeXv 5OiFR+ByRSx6ODR+uyc32MikKhMauWrk/WsNGryeDLHe1SY21YwcVDm2PuyVstUuyL+m TFAqTCNXnFOKT4PvyRLhhfrskvAVer4j3B+sYPxOXaiQTHC8Lf574g2Msm+r2BkvWReB +pJ7mKnUo24T+aFB/+2CO6JZ9pho0573OPBE7PkGOFuYvdvAzLz4jGhIlXxROaO05/Db rxOw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@nifty.com header.s=dec2015msa header.b=jiuTH+JR; 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 be27si4653205edb.50.2020.07.01.12.35.29; Wed, 01 Jul 2020 12:35:53 -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=@nifty.com header.s=dec2015msa header.b=jiuTH+JR; 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 S1727112AbgGATeP (ORCPT + 99 others); Wed, 1 Jul 2020 15:34:15 -0400 Received: from conssluserg-06.nifty.com ([210.131.2.91]:51375 "EHLO conssluserg-06.nifty.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726768AbgGATeP (ORCPT ); Wed, 1 Jul 2020 15:34:15 -0400 Received: from mail-vk1-f182.google.com (mail-vk1-f182.google.com [209.85.221.182]) (authenticated) by conssluserg-06.nifty.com with ESMTP id 061JXpBw011590; Thu, 2 Jul 2020 04:33:52 +0900 DKIM-Filter: OpenDKIM Filter v2.10.3 conssluserg-06.nifty.com 061JXpBw011590 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nifty.com; s=dec2015msa; t=1593632032; bh=M049TJy/cPQkzAutDxghwHrAKGcacxHbM+3c0nlXY9g=; h=References:In-Reply-To:From:Date:Subject:To:Cc:From; b=jiuTH+JRg2ggt7gNIVFpd5HuVofd95Y7704W4gfQvZhirp8bGt/ioZGOA21r4PAlO Dfd2Ka+rA9pdGmS0c4Q9gnlq2atiaJXwjfZqJRIKCUzie5rNHst1ZV3AIvN3LZDU5t DWKik634foelBvem1d7gIh4zpMD5qcg0BVZsrxyTBEoWzg/KhfgeccvwvGbIoibfpQ J/fngoiS78BXu5ndmk6SkKHc1Rmv6hCM4lr3XBYNosy/7le+brkZ3OpD5FkXe2jCaH ugFPoUxd743ZvPw1DWRilgmpR7whemNS5z1BxvURjAZt2oBsKBmnaGDsAhG2RxjtVA V0vTR90tsOrWw== X-Nifty-SrcIP: [209.85.221.182] Received: by mail-vk1-f182.google.com with SMTP id v26so2738535vkn.2; Wed, 01 Jul 2020 12:33:52 -0700 (PDT) X-Gm-Message-State: AOAM532+ypXqIlGy1QqzFqaKROvhakv4S+JfOJ47+KG2R7uOTXbknI46 yfqfNL/pNF1BBWuxp5GDpDOVfljtxh8CVbl1XZE= X-Received: by 2002:ac5:ccaf:: with SMTP id p15mr13601008vkm.12.1593632030968; Wed, 01 Jul 2020 12:33:50 -0700 (PDT) MIME-Version: 1.0 References: <20200626185913.92890-1-masahiroy@kernel.org> In-Reply-To: From: Masahiro Yamada Date: Thu, 2 Jul 2020 04:33:14 +0900 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: [PATCH 1/2] kbuild: remove cc-option test of -fno-stack-protector To: Nick Desaulniers Cc: Linux Kbuild mailing list , clang-built-linux , "maintainer:X86 ARCHITECTURE (32-BIT AND 64-BIT)" , linux-efi , Kees Cook , 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 Tue, Jun 30, 2020 at 7:39 AM Nick Desaulniers wrote: > > On Mon, Jun 29, 2020 at 11:26 AM Nick Desaulniers > wrote: > > > > On Sat, Jun 27, 2020 at 4:59 AM Masahiro Yamada wrote: > > > > > > On Sat, Jun 27, 2020 at 5:13 AM Nick Desaulniers > > > wrote: > > > > > > > > On Fri, Jun 26, 2020 at 12:00 PM Masahiro Yamada wrote: > > > > > > > > > > diff --git a/arch/x86/kernel/cpu/Makefile b/arch/x86/kernel/cpu/Makefile > > > > > index dba6a83bc349..93792b457b81 100644 > > > > > --- a/arch/x86/kernel/cpu/Makefile > > > > > +++ b/arch/x86/kernel/cpu/Makefile > > > > > @@ -17,8 +17,7 @@ KCOV_INSTRUMENT_perf_event.o := n > > > > > KCSAN_SANITIZE_common.o := n > > > > > > > > > > # Make sure load_percpu_segment has no stackprotector > > > > > -nostackp := $(call cc-option, -fno-stack-protector) > > > > > -CFLAGS_common.o := $(nostackp) > > > > > +CFLAGS_common.o := -fno-stack-protector > > > > > > > > Any time I see `:=` assignment to a CFLAGS variable, it's a red flag > > > > for overwriting existing CFLAGS, which is a common source of bugs. I > > > > recognize the kernel is current a mix and match for: > > > > > > > > CFLAGS_.o > > > > > > > > rules to either use `+=` or `:=`, but I wish we were consistent, and > > > > consistent in our use of `+=`. For those rules, is there a difference > > > > between the use of `+=` and `:=` like there is for the more general > > > > case of appending to KBUILD_CFLAGS? If not, it's ok to match the > > > > existing style, but it's curious to me in this patch to see a mixed > > > > use of `+=` and `:=`. > > > > > > > > > I think Kees mostly answered your question. > > > > > > Let me add some comments. > > > > > > > > > '+=' is the most used in kernel Makefiles, but > > > ':=' and '=' are also used. > > > > > > So, you are right, we are inconsistent. > > > This applies to not only CFLAGS_.o, but also obj-y, etc. > > > > > > For example, > > > https://github.com/torvalds/linux/blob/v5.7/arch/arm64/kernel/Makefile#L15 > > > 'obj-y :=' works since it is the first assignment to obj-y in that file. > > > 'obj-y +=' also works, of course. > > > > > > We can consistently use '+=' everywhere, but I do not send > > > patches for churn. > > > > > > > > > You can use any assignment operator to CFLAGS_.o > > > if it is the first assignment in the Makefile. > > > Using '+=' is robust for future code insertion/removal, though. > > > > > > > > > If the right-hand side contains variable references, > > > there is important difference in the behavior. > > > > > > You may know two flavors in variables > > > (https://www.gnu.org/software/make/manual/make.html#Flavors) > > > > Cool, thanks for all the info. With that, I'm happy with this patch. > > > > Reviewed-by: Nick Desaulniers > > > > > > > CFLAGS_foo.o := $(call cc-option,-fno-stack-protector) > > > The cc-option is expanded immediately when this line is parsed. > > > (So, the compiler is invoked for 'make clean' too) > > > > > > > > > CFLAGS_foo.o += $(call cc-option,-fno-stack-protector) > > > If this is the first assignment in the file, > > > '+=' act as '=', so the evaluation of cc-option > > > is delayed until $(CFLAGS_foo.o) is expanded. > > > (So, the compiler is NOT invoked for 'make clean') > > > > Ah, I think that may explain: I've been seeing the occasional warning > > from $(NM) when running `make clean` for ARCH=arm, I'll bet that's > > where this is coming from then. Next time I reproduce it, I'll try to > > find maybe where we're using `:=` or `=` with `$(NM)`. > > > > Maybe arch/arm/boot/compressed/Makefile, KBSS_SZ is evaluated for > > `make clean`? (If you start an arm build, but kill it before vmlinux > > is created, then `make clean` I suspect that KBSS_SZ is evaluated?) > > $ ARCH=arm CROSS_COMPILE=arm-linux-gnueabihf- make LLVM=1 -j71 > $ rm vmlinux > $ ARCH=arm CROSS_COMPILE=arm-linux-gnueabihf- make LLVM=1 -j71 clean > llvm-nm: error: arch/arm/boot/compressed/../../../../vmlinux: No such > file or directory. > > I suspect I see this from doing an ARCH=arm build, then building a > different ARCH and killing the build before vmlinux is produced or > `make clean` for a different ARCH, then run a `make clean` for > ARCH=arm. > > Is the above (regarding lazy evaluation) not true for LDFLAGS_vmlinux? > I would have thought this would work: > I described why this error message is displayed: https://patchwork.kernel.org/patch/11637129/ -- Best Regards Masahiro Yamada