Subject: linux-next: build failure after merge of the origin tree

From: Stephen Rothwell <[email-masked]>
Date: Tue, 14 Sep 2021 10:08:53 +1000

Hi all,

After merging the origin tree, today's linux-next build (powerpc
ppc64_defconfig) failed like this:

In file included from <command-line>:
include/linux/compiler_attributes.h:62:5: warning: "__has_attribute" is not defined, evaluates to 0 [-Wundef]
   62 | #if __has_attribute(__assume_aligned__)
      |     ^~~~~~~~~~~~~~~
include/linux/compiler_attributes.h:62:20: error: missing binary operator before token "("
   62 | #if __has_attribute(__assume_aligned__)
      |                    ^
include/linux/compiler_attributes.h:88:5: warning: "__has_attribute" is not defined, evaluates to 0 [-Wundef]
   88 | #if __has_attribute(__copy__)
      |     ^~~~~~~~~~~~~~~
include/linux/compiler_attributes.h:88:20: error: missing binary operator before token "("
   88 | #if __has_attribute(__copy__)
      |                    ^
include/linux/compiler_attributes.h:113:5: warning: "__has_attribute" is not defined, evaluates to 0 [-Wundef]
  113 | #if __has_attribute(__designated_init__)
      |     ^~~~~~~~~~~~~~~
include/linux/compiler_attributes.h:113:20: error: missing binary operator before token "("
  113 | #if __has_attribute(__designated_init__)
      |                    ^
include/linux/compiler_attributes.h:124:5: warning: "__has_attribute" is not defined, evaluates to 0 [-Wundef]
  124 | #if __has_attribute(__error__)
      |     ^~~~~~~~~~~~~~~
include/linux/compiler_attributes.h:124:20: error: missing binary operator before token "("
  124 | #if __has_attribute(__error__)
      |                    ^
include/linux/compiler_attributes.h:135:5: warning: "__has_attribute" is not defined, evaluates to 0 [-Wundef]
  135 | #if __has_attribute(__externally_visible__)
      |     ^~~~~~~~~~~~~~~
include/linux/compiler_attributes.h:135:20: error: missing binary operator before token "("
  135 | #if __has_attribute(__externally_visible__)
      |                    ^
In file included from <command-line>:
include/linux/compiler_attributes.h:171:5: warning: "__has_attribute" is not defined, evaluates to 0 [-Wundef]
  171 | #if __has_attribute(__no_caller_saved_registers__)
      |     ^~~~~~~~~~~~~~~
include/linux/compiler_attributes.h:171:20: error: missing binary operator before token "("
  171 | #if __has_attribute(__no_caller_saved_registers__)
      |                    ^
include/linux/compiler_attributes.h:182:5: warning: "__has_attribute" is not defined, evaluates to 0 [-Wundef]
  182 | #if __has_attribute(__noclone__)
      |     ^~~~~~~~~~~~~~~
include/linux/compiler_attributes.h:182:20: error: missing binary operator before token "("
  182 | #if __has_attribute(__noclone__)
      |                    ^
include/linux/compiler_attributes.h:199:5: warning: "__has_attribute" is not defined, evaluates to 0 [-Wundef]
  199 | #if __has_attribute(__fallthrough__)
      |     ^~~~~~~~~~~~~~~
include/linux/compiler_attributes.h:199:20: error: missing binary operator before token "("
  199 | #if __has_attribute(__fallthrough__)
      |                    ^
include/linux/compiler_attributes.h:226:5: warning: "__has_attribute" is not defined, evaluates to 0 [-Wundef]
  226 | #if __has_attribute(__nonstring__)
      |     ^~~~~~~~~~~~~~~
include/linux/compiler_attributes.h:226:20: error: missing binary operator before token "("
  226 | #if __has_attribute(__nonstring__)
      |                    ^
include/linux/compiler_attributes.h:238:5: warning: "__has_attribute" is not defined, evaluates to 0 [-Wundef]
  238 | #if __has_attribute(__no_profile_instrument_function__)
      |     ^~~~~~~~~~~~~~~
include/linux/compiler_attributes.h:238:20: error: missing binary operator before token "("
  238 | #if __has_attribute(__no_profile_instrument_function__)
      |                    ^
include/linux/compiler_attributes.h:296:5: warning: "__has_attribute" is not defined, evaluates to 0 [-Wundef]
  296 | #if __has_attribute(__warning__)
      |     ^~~~~~~~~~~~~~~
include/linux/compiler_attributes.h:296:20: error: missing binary operator before token "("
  296 | #if __has_attribute(__warning__)
      |                    ^
make[2]: *** [arch/powerpc/boot/Makefile:225: arch/powerpc/boot/crt0.o] Error 1

Exposed by commit

  6d2ef226f2f1 ("compiler_attributes.h: drop __has_attribute() support for gcc4")

Powerpc uses BOOTAS to build arch/powerpc/boot/crt0.o (and others)
which (with V=1) is

  gcc -Wp,-MD,arch/powerpc/boot/.crt0.o.d -D__ASSEMBLY__ -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 /home/sfr/next/next/include/linux/compiler_attributes.h -I/home/sfr/next/next/arch/powerpc/include -I./arch/powerpc/include/generated -I/home/sfr/next/next/include -I./include -I/home/sfr/next/next/arch/powerpc/include/uapi -I./arch/powerpc/include/generated/uapi -I/home/sfr/next/next/include/uapi -I./include/generated/uapi -include /home/sfr/next/next/include/linux/compiler-version.h -include /home/sfr/next/next/include/linux/kconfig.h -m32 -isystem /usr/lib/gcc/powerpc64le-linux-gnu/10/include -mbig-endian -nostdinc -c -o arch/powerpc/boot/crt0.o /home/sfr/next/next/arch/powerpc/boot/crt0.S

I am not sure what is missing here to get __has_attribute defined.

I have reverted the above commit for today ( and reapplied the bits
from commits

  7ed012969bbc ("Compiler Attributes: fix __has_attribute(__no_sanitize_coverage__) for GCC 4")
  b83a908498d6 ("compiler_attributes.h: move __compiletime_{error|warning}")
).

I assume that this needs some work in the powerpc arch Makfile(s) ...
-- 
Cheers,
Stephen Rothwell