linux-next.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Linus Torvalds <torvalds@linux-foundation.org>
To: Stephen Rothwell <sfr@canb.auug.org.au>
Cc: Linux Kernel Mailing List <linux-kernel@vger.kernel.org>,
	Linux Next Mailing List <linux-next@vger.kernel.org>,
	Michael Ellerman <mpe@ellerman.id.au>,
	PowerPC <linuxppc-dev@lists.ozlabs.org>
Subject: Re: linux-next: build failure after merge of the origin tree
Date: Mon, 13 Sep 2021 18:29:26 -0700	[thread overview]
Message-ID: <CAHk-=whyWUdJDeOBN1hRWYSkQkvzYiQ5RbSW5rJjExgnbSNX9Q@mail.gmail.com> (raw)
In-Reply-To: <20210914105359.5c651d55@canb.auug.org.au>

[-- Attachment #1: Type: text/plain, Size: 2449 bytes --]

On Mon, Sep 13, 2021 at 5:58 PM Stephen Rothwell <sfr@canb.auug.org.au> wrote:
>
> > I have no idea why it then complains about removal of the GCC4 macros.
>
> Me neither :-(

Ooh.

So I'm looking at gcc sources, just to see if "maybe this thing is
somehow conditional".

And bingo.

In cpp_init_special_builtins(), gcc does

      if (b->value == BT_HAS_ATTRIBUTE
          && (CPP_OPTION (pfile, lang) == CLK_ASM
              || pfile->cb.has_attribute == NULL))
        continue;

which basically says that if we're pre-processing an ASM file, the
magical pre-processor symbol for __has_attribute is not defined.

I'm not sure what that 'pfile->cb.has_attribute == NULL' thing means,
but the libcpp/ChangeLog file also mentions this:

        (cpp_init_special_builtins): Don't initialize __has_attribute
        or __has_cpp_attribute if CLK_ASM or pfile->cb.has_attribute is NULL.

So this is a very very special magical thing: if building an *.S file,
__has_attribute magically goes away.

And sure enough, that's exactly what is going on. It's during that
build of arch/powerpc/boot/crt0.S, and the reason this hits on powerpc
is that in arch/powerpc/boot/Makefile we have

         -include $(srctree)/include/linux/compiler_attributes.h

as part of BOOTCFLAGS, and then it does

        BOOTAFLAGS      := -D__ASSEMBLY__ $(BOOTCFLAGS) -nostdinc

to also include that header file when building ASM files.

And our old GCC4 code silently hid this all, and made it work, because
for a *.S file  you'd then (completely illogically) get those fake
gcc-4 attribute macros.

Now, do I know *why* that ppc Makefile it does that? No. Neither do I
know why the gcc people decided to just make ASM preprocessor so
special.

But at least I understand how the odd error happens.

This was too damn subtle. When you have to go read the compiler
sources to figure things like this out, you know you are too deep.

The fix should be pretty simple: remove almost all of BOOTCFLAGS from
BOOTAFLAGS.

But sadly, "almost all" isn't "all". There's the include path stuff,
there's the ABI and endianness, and there's the bit size ones.

So I think the fix is either

 (a) remove that

         -include $(srctree)/include/linux/compiler_attributes.h

     thing entirely, and add it as required to the C files.

OR

 (b) something like this ENTIRELY UNTESTED ATTACHED patch

I will leave it to the powerpc people to make the right choice.

               Linus

[-- Attachment #2: patch.diff --]
[-- Type: text/x-patch, Size: 1611 bytes --]

 arch/powerpc/boot/Makefile | 26 ++++++++++++++------------
 1 file changed, 14 insertions(+), 12 deletions(-)

diff --git a/arch/powerpc/boot/Makefile b/arch/powerpc/boot/Makefile
index 6900d0ac2421..9bcf62d65509 100644
--- a/arch/powerpc/boot/Makefile
+++ b/arch/powerpc/boot/Makefile
@@ -32,28 +32,30 @@ else
     BOOTAR := $(AR)
 endif
 
-BOOTCFLAGS    := -Wall -Wundef -Wstrict-prototypes -Wno-trigraphs \
-		 -fno-strict-aliasing -O2 -msoft-float -mno-altivec -mno-vsx \
-		 -pipe -fomit-frame-pointer -fno-builtin -fPIC -nostdinc \
-		 -include $(srctree)/include/linux/compiler_attributes.h \
-		 $(LINUXINCLUDE)
+BOOTCOREFLAGS := $(LINUXINCLUDE)
 
 ifdef CONFIG_PPC64_BOOT_WRAPPER
-BOOTCFLAGS	+= -m64
+BOOTCOREFLAGS	+= -m64
 else
-BOOTCFLAGS	+= -m32
+BOOTCOREFLAGS	+= -m32
 endif
 
-BOOTCFLAGS	+= -isystem $(shell $(BOOTCC) -print-file-name=include)
+BOOTCOREFLAGS	+= -isystem $(shell $(BOOTCC) -print-file-name=include)
 
 ifdef CONFIG_CPU_BIG_ENDIAN
-BOOTCFLAGS	+= -mbig-endian
+BOOTCOREFLAGS	+= -mbig-endian
 else
-BOOTCFLAGS	+= -mlittle-endian
-BOOTCFLAGS	+= $(call cc-option,-mabi=elfv2)
+BOOTCOREFLAGS	+= -mlittle-endian
+BOOTCOREFLAGS	+= $(call cc-option,-mabi=elfv2)
 endif
 
-BOOTAFLAGS	:= -D__ASSEMBLY__ $(BOOTCFLAGS) -nostdinc
+BOOTCFLAGS    := -Wall -Wundef -Wstrict-prototypes -Wno-trigraphs \
+		 -fno-strict-aliasing -O2 -msoft-float -mno-altivec -mno-vsx \
+		 -pipe -fomit-frame-pointer -fno-builtin -fPIC -nostdinc \
+		 -include $(srctree)/include/linux/compiler_attributes.h \
+		 $(BOOTCOREFLAGS)
+
+BOOTAFLAGS	:= -D__ASSEMBLY__ $(BOOTCOREFLAGS) -nostdinc
 
 BOOTARFLAGS	:= -crD
 

  reply	other threads:[~2021-09-14  1:29 UTC|newest]

Thread overview: 60+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-09-14  0:08 linux-next: build failure after merge of the origin tree Stephen Rothwell
2021-09-14  0:19 ` Linus Torvalds
2021-09-14  0:24   ` Linus Torvalds
2021-09-14  0:58     ` Stephen Rothwell
2021-09-14  1:29       ` Linus Torvalds [this message]
2021-09-14  1:37         ` Linus Torvalds
2021-09-14  2:03           ` Linus Torvalds
2021-09-14  2:08         ` Stephen Rothwell
2021-09-14  2:12           ` Linus Torvalds
2021-09-14  2:50             ` Michael Ellerman
2021-09-14 12:21             ` Michael Ellerman
2021-09-14  2:39           ` Stephen Rothwell
  -- strict thread matches above, loose matches on Subject: below --
2023-06-30  2:59 Stephen Rothwell
2023-06-30  3:43 ` Linus Torvalds
2021-09-19 23:42 Stephen Rothwell
2021-09-07 23:07 Stephen Rothwell
2021-09-07 23:09 ` Stephen Rothwell
2021-09-07 23:17   ` Marco Elver
2021-09-07 23:38     ` Miguel Ojeda
2020-07-30 22:58 Stephen Rothwell
2020-07-30 23:15 ` Stephen Rothwell
2020-07-29 23:08 Stephen Rothwell
2020-07-29 23:43 ` Linus Torvalds
2020-07-30  0:09   ` Linus Torvalds
2020-07-30  2:12     ` Linus Torvalds
2020-07-30  2:30       ` Willy Tarreau
2020-07-30  3:17   ` Kees Cook
2020-07-30  3:22     ` Willy Tarreau
2020-07-30  6:14       ` Willy Tarreau
2020-07-30  9:59         ` Marc Zyngier
2020-07-30 10:09           ` Catalin Marinas
2020-07-30 15:00             ` Will Deacon
2020-07-30 17:49         ` Kees Cook
2020-07-30 18:24     ` Linus Torvalds
2020-07-30 18:47       ` Kees Cook
2020-06-04 22:37 Stephen Rothwell
2020-06-05  0:04 ` Josh Poimboeuf
2020-06-05  9:48   ` Jessica Yu
2020-04-20 10:23 Stephen Rothwell
2020-01-31  4:12 Stephen Rothwell
2020-01-31  4:17 ` Randy Dunlap
2020-01-31  9:39   ` Daniel Lezcano
2012-10-09 23:21 Stephen Rothwell
2012-10-09 23:45 ` Andrew Morton
2012-10-09 23:52   ` Yasuaki Ishimatsu
2012-10-10  3:12     ` Stephen Rothwell
2012-10-10  0:07   ` Stephen Rothwell
2012-06-04  2:57 Stephen Rothwell
2012-06-04  7:39 ` Paul Mundt
2012-01-18 23:31 Stephen Rothwell
2012-01-19  8:21 ` Jens Axboe
2012-01-19  8:23   ` Jens Axboe
2011-11-06 23:12 Stephen Rothwell
2011-11-07  1:52 ` David Miller
2011-11-07  2:47   ` Stephen Rothwell
2011-11-07  3:36     ` David Miller
2011-11-07  5:29       ` Kirsher, Jeffrey T
2011-11-07 16:46         ` Rose, Gregory V
2011-11-07 17:46           ` Rose, Gregory V
2011-07-25  1:16 Stephen Rothwell

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to='CAHk-=whyWUdJDeOBN1hRWYSkQkvzYiQ5RbSW5rJjExgnbSNX9Q@mail.gmail.com' \
    --to=torvalds@linux-foundation.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-next@vger.kernel.org \
    --cc=linuxppc-dev@lists.ozlabs.org \
    --cc=mpe@ellerman.id.au \
    --cc=sfr@canb.auug.org.au \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).