Skip to contentSkip to conversation

include/linux/compiler-gcc.h:153:5: note: in expansion of macro '__has_attribute'

PATCH Applied kernel test robot 6 participants 7 messages Jun 15, 2020 – Jun 17, 2020 Compiler attributes

lore
Share & tools
lore

kernel test robot

author build bot
#0 lore raw
tree:   https://git.kernel.org/pub/scm/linux/kernel/git/peterz/queue.git x86/entry
head:   8e8bb06d199a5aa7a534aa3b3fc0abbbc11ca438
commit: 5144f8a8dfd7b3681f0a2b5bf599a210b2315018 [5/8] compiler_types.h: Add __no_sanitize_{address,undefined} to noinstr
config: i386-randconfig-a006-20200615 (attached as .config)
compiler: gcc-4.9 (Ubuntu 4.9.3-13ubuntu2) 4.9.3
reproduce (this is a W=1 build):
        git checkout 5144f8a8dfd7b3681f0a2b5bf599a210b2315018
        # save the attached .config to linux build tree
        make W=1 ARCH=i386 

If you fix the issue, kindly add following tag as appropriate

All warnings (new ones prefixed by >>, old ones prefixed by <<):

In file included from include/linux/compiler_types.h:59:0, from <command-line>:0:

>> include/linux/compiler_attributes.h:35:29: warning: "__GCC4_has_attribute___no_sanitize_undefined__" is not defined [-Wundef]
# define __has_attribute(x) __GCC4_has_attribute_##x
^
>> include/linux/compiler-gcc.h:153:5: note: in expansion of macro '__has_attribute'

#if __has_attribute(__no_sanitize_undefined__)
^
--
In file included from include/linux/compiler_types.h:59:0, from <command-line>:0:

>> include/linux/compiler_attributes.h:35:29: warning: "__GCC4_has_attribute___no_sanitize_undefined__" is not defined [-Wundef]
# define __has_attribute(x) __GCC4_has_attribute_##x
^
>> include/linux/compiler-gcc.h:153:5: note: in expansion of macro '__has_attribute'

#if __has_attribute(__no_sanitize_undefined__)
^
drivers/xen/xenbus/xenbus_client.c: In function 'xenbus_va_dev_error':
drivers/xen/xenbus/xenbus_client.c:276:2: warning: function might be possible candidate for 'gnu_printf' format attribute [-Wsuggest-attribute=format] vsnprintf(printf_buffer + len, PRINTF_BUFFER_SIZE - len, fmt, ap);
^
--
In file included from include/linux/compiler_types.h:59:0,
from <command-line>:0:

>> include/linux/compiler_attributes.h:35:29: warning: "__GCC4_has_attribute___no_sanitize_undefined__" is not defined [-Wundef]
# define __has_attribute(x) __GCC4_has_attribute_##x
^
>> include/linux/compiler-gcc.h:153:5: note: in expansion of macro '__has_attribute'

#if __has_attribute(__no_sanitize_undefined__)
^
lib/math/div64.c:29:32: warning: no previous prototype for '__div64_32' [-Wmissing-prototypes] uint32_t __attribute__((weak)) __div64_32(uint64_t *n, uint32_t base)
^
--
In file included from include/linux/compiler_types.h:59:0,
from <command-line>:0:

>> include/linux/compiler_attributes.h:35:29: warning: "__GCC4_has_attribute___no_sanitize_undefined__" is not defined [-Wundef]
# define __has_attribute(x) __GCC4_has_attribute_##x
^
>> include/linux/compiler-gcc.h:153:5: note: in expansion of macro '__has_attribute'

#if __has_attribute(__no_sanitize_undefined__)
^
drivers/regulator/core.c:3805:5: warning: no previous prototype for 'regulator_suspend_enable' [-Wmissing-prototypes] int regulator_suspend_enable(struct regulator_dev *rdev,
^
drivers/regulator/core.c:3812:5: warning: no previous prototype for 'regulator_suspend_disable' [-Wmissing-prototypes] int regulator_suspend_disable(struct regulator_dev *rdev,
^
drivers/regulator/core.c:3851:5: warning: no previous prototype for 'regulator_set_suspend_voltage' [-Wmissing-prototypes] int regulator_set_suspend_voltage(struct regulator *regulator, int min_uV,
^
--
In file included from include/linux/compiler_types.h:59:0,
from <command-line>:0:

>> include/linux/compiler_attributes.h:35:29: warning: "__GCC4_has_attribute___no_sanitize_undefined__" is not defined [-Wundef]
# define __has_attribute(x) __GCC4_has_attribute_##x
^
>> include/linux/compiler-gcc.h:153:5: note: in expansion of macro '__has_attribute'

#if __has_attribute(__no_sanitize_undefined__)
^
drivers/regulator/da9063-regulator.c:515:3: warning: initialized field overwritten [-Woverride-init]
.suspend = BFIELD(DA9063_REG_LDO9_CONT, DA9063_VLDO9_SEL),
^
drivers/regulator/da9063-regulator.c:515:3: warning: (near initialization for 'da9063_regulator_info[11].suspend') [-Woverride-init] --
In file included from include/linux/compiler_types.h:59:0,
from <command-line>:0:

>> include/linux/compiler_attributes.h:35:29: warning: "__GCC4_has_attribute___no_sanitize_undefined__" is not defined [-Wundef]
# define __has_attribute(x) __GCC4_has_attribute_##x
^
>> include/linux/compiler-gcc.h:153:5: note: in expansion of macro '__has_attribute'

#if __has_attribute(__no_sanitize_undefined__)
^
drivers/regulator/tps65218-regulator.c: In function 'tps65218_pmic_set_suspend_enable':
drivers/regulator/tps65218-regulator.c:131:10: warning: comparison of unsigned expression < 0 is always false [-Wtype-limits] if (rid < TPS65218_DCDC_1 || rid > TPS65218_LDO_1)
^
drivers/regulator/tps65218-regulator.c: In function 'tps65218_pmic_set_suspend_disable':
drivers/regulator/tps65218-regulator.c:144:10: warning: comparison of unsigned expression < 0 is always false [-Wtype-limits] if (rid < TPS65218_DCDC_1 || rid > TPS65218_LDO_1)
^
--
In file included from include/linux/compiler_types.h:59:0,
from <command-line>:0:

>> include/linux/compiler_attributes.h:35:29: warning: "__GCC4_has_attribute___no_sanitize_undefined__" is not defined [-Wundef]
# define __has_attribute(x) __GCC4_has_attribute_##x
^
>> include/linux/compiler-gcc.h:153:5: note: in expansion of macro '__has_attribute'

#if __has_attribute(__no_sanitize_undefined__)
^
arch/x86/lib/cmdline.c:204:5: warning: no previous prototype for 'cmdline_find_option_bool' [-Wmissing-prototypes] int cmdline_find_option_bool(const char *cmdline, const char *option)
^
arch/x86/lib/cmdline.c:209:5: warning: no previous prototype for 'cmdline_find_option' [-Wmissing-prototypes] int cmdline_find_option(const char *cmdline, const char *option, char *buffer,
^
--
In file included from include/linux/compiler_types.h:59:0,
from <command-line>:0:

>> include/linux/compiler_attributes.h:35:29: warning: "__GCC4_has_attribute___no_sanitize_undefined__" is not defined [-Wundef]
# define __has_attribute(x) __GCC4_has_attribute_##x
^
>> include/linux/compiler-gcc.h:153:5: note: in expansion of macro '__has_attribute'

#if __has_attribute(__no_sanitize_undefined__)
^
arch/x86/lib/misc.c:7:5: warning: no previous prototype for 'num_digits' [-Wmissing-prototypes] int num_digits(int val)
^
--
In file included from include/linux/compiler_types.h:59:0,
from <command-line>:0:

>> include/linux/compiler_attributes.h:35:29: warning: "__GCC4_has_attribute___no_sanitize_undefined__" is not defined [-Wundef]
# define __has_attribute(x) __GCC4_has_attribute_##x
^
>> include/linux/compiler-gcc.h:153:5: note: in expansion of macro '__has_attribute'

#if __has_attribute(__no_sanitize_undefined__)
^
arch/x86/lib/msr.c:39:5: warning: no previous prototype for 'msr_read' [-Wmissing-prototypes] int msr_read(u32 msr, struct msr *m)
^
arch/x86/lib/msr.c:57:5: warning: no previous prototype for 'msr_write' [-Wmissing-prototypes] int msr_write(u32 msr, struct msr *m)
^
--
In file included from include/linux/compiler_types.h:59:0,
from <command-line>:0:

>> include/linux/compiler_attributes.h:35:29: warning: "__GCC4_has_attribute___no_sanitize_undefined__" is not defined [-Wundef]
# define __has_attribute(x) __GCC4_has_attribute_##x
^
>> include/linux/compiler-gcc.h:153:5: note: in expansion of macro '__has_attribute'

#if __has_attribute(__no_sanitize_undefined__)
^
fs/ext4/super.c: In function 'ext4_remount':
fs/ext4/super.c:5384:6: warning: variable 'enable_quota' set but not used [-Wunused-but-set-variable] int enable_quota = 0;
^
--
In file included from include/linux/compiler_types.h:59:0,
from <command-line>:0:

>> include/linux/compiler_attributes.h:35:29: warning: "__GCC4_has_attribute___no_sanitize_undefined__" is not defined [-Wundef]
# define __has_attribute(x) __GCC4_has_attribute_##x
^
>> include/linux/compiler-gcc.h:153:5: note: in expansion of macro '__has_attribute'

#if __has_attribute(__no_sanitize_undefined__)
^
drivers/tty/tty_ldisc.c:884:6: warning: no previous prototype for 'tty_sysctl_init' [-Wmissing-prototypes] void tty_sysctl_init(void)
^
..

vim +/__has_attribute +153 include/linux/compiler-gcc.h

152

 > 153	#if __has_attribute(__no_sanitize_undefined__)

154 #define __no_sanitize_undefined __attribute__((no_sanitize_undefined))
155 #else
156 #define __no_sanitize_undefined
157 #endif
158

---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/kbuild-all(a)lists.01.org

#1 lore raw

PATCH 1/1 compiler_attributes.h: Support no_sanitize_undefined check with GCC 4

UBSAN is supported since GCC 4.9, which unfortunately did not yet have __has_attribute(). To work around, the __GCC4_has_attribute workaround requires defining which compiler version supports the given attribute.

In the case of no_sanitize_undefined, it is the first version that supports UBSAN, which is GCC 4.9.

---

Doing a 'make W=1' with GCC 4.9 and the provided config fixes the build robot's report.

Peter: Feel free to either squash this patch into the one adding __no_sanitize_undefined or apply on top.

Although at this point we don't have any users of __no_sanitize_undefined anymore since objtool resolved the noinstr problem for UBSAN differently. We should probably keep the attribute around because eventually somebody will need it.

Thanks,
-- Marco

---
 include/linux/compiler_attributes.h | 1 +
 1 file changed, 1 insertion(+)
include/linux/compiler_attributes.h +1 -0
index cdf016596659..c8f03d2969df 100644
@@ -40,6 +40,7 @@
 # define __GCC4_has_attribute___noclone__             1
 # define __GCC4_has_attribute___nonstring__           0
 # define __GCC4_has_attribute___no_sanitize_address__ (__GNUC_MINOR__ >= 8)
+# define __GCC4_has_attribute___no_sanitize_undefined__ (__GNUC_MINOR__ >= 9)
 # define __GCC4_has_attribute___fallthrough__         0
 #endif
 
Signature · 1 line
2.27.0.290.gba653c62da-goog
Reviewed-by on v1 1/1
#2 lore raw

Re: [PATCH] compiler_attributes.h: Support no_sanitize_undefined check with GCC 4

Hi Marco,

Quoted 11 lines · Marco Elver

UBSAN is supported since GCC 4.9, which unfortunately did not yet have __has_attribute(). To work around, the __GCC4_has_attribute workaround requires defining which compiler version supports the given attribute.

In the case of no_sanitize_undefined, it is the first version that supports UBSAN, which is GCC 4.9.

---

I am happy to see the __GCC4_has_attribute workaround is useful outside the file, too (originally the list was meant to be used inside the file itself, but I see it is good to reuse it).

Cheers,
Miguel

#3 lore raw

Re: [PATCH] compiler_attributes.h: Support no_sanitize_undefined check with GCC 4

In reply to Marco Elver
Quoted 9 lines · Marco Elver

UBSAN is supported since GCC 4.9, which unfortunately did not yet have __has_attribute(). To work around, the __GCC4_has_attribute workaround requires defining which compiler version supports the given attribute.

In the case of no_sanitize_undefined, it is the first version that supports UBSAN, which is GCC 4.9.

Quoted 7 lines

---

Doing a 'make W=1' with GCC 4.9 and the provided config fixes the build robot's report.

Peter: Feel free to either squash this patch into the one adding __no_sanitize_undefined or apply on top.

Yeah, argh! So I only saw this thread now, even though I'd already pushed out x86/entry to tip last night due to getting:

301805 N + Jun 16 kernel test rob (5.8K) [peterz-queue:x86/entry] BUILD SUCCESS 8e8bb06d199a5aa7a534aa3b3fc0abbbc11ca438

Why that thing is claiming SUCCESS when it introduces a build error I don't know.

Anyway, let me go push this thing on top.

#4 lore raw

Re: [kbuild-all] Re: [PATCH] compiler_attributes.h: Support no_sanitize_undefined check with GCC 4

Quoted 18 lines · Peter Zijlstra
Quoted 9 lines · Marco Elver

UBSAN is supported since GCC 4.9, which unfortunately did not yet have __has_attribute(). To work around, the __GCC4_has_attribute workaround requires defining which compiler version supports the given attribute.

In the case of no_sanitize_undefined, it is the first version that supports UBSAN, which is GCC 4.9.

Quoted 7 lines

---

Doing a 'make W=1' with GCC 4.9 and the provided config fixes the build robot's report.

Peter: Feel free to either squash this patch into the one adding __no_sanitize_undefined or apply on top.

Quoted 8 lines

Yeah, argh! So I only saw this thread now, even though I'd already pushed out x86/entry to tip last night due to getting:

301805 N + Jun 16 kernel test rob (5.8K) [peterz-queue:x86/entry] BUILD SUCCESS 8e8bb06d199a5aa7a534aa3b3fc0abbbc11ca438

Why that thing is claiming SUCCESS when it introduces a build error I don't know.

Hi Peter,

Sorry for the misunderstanding, some folks complained that it's too noisy when there're only new warnings in a "BUILD REGRESSION" report, so we changed to use "BUILD SUCCESS" if there's no new build error. To avoid misunderstanding, we'll change build complete report title to "BUILD SUCCESS WITH WARNING" for new warnings.

Best Regards,
Rong Chen

#5 lore raw

Re: [kbuild-all] Re: [PATCH] compiler_attributes.h: Support no_sanitize_undefined check with GCC 4

Quoted 4 lines · Rong Chen
Quoted 2 lines · Peter Zijlstra

301805 N + Jun 16 kernel test rob (5.8K) [peterz-queue:x86/entry] BUILD SUCCESS 8e8bb06d199a5aa7a534aa3b3fc0abbbc11ca438

Quoted 8 lines
Quoted 2 lines

Why that thing is claiming SUCCESS when it introduces a build error I don't know.

Sorry for the misunderstanding, some folks complained that it's too noisy when there're only new warnings in a "BUILD REGRESSION" report, so we changed to use "BUILD SUCCESS" if there's no new build error. To avoid misunderstanding, we'll change build complete report title to "BUILD SUCCESS WITH WARNING" for new warnings.

Thanks Rong!

merge bot Applied
#6 lore raw

[tip: x86/entry] compiler_attributes.h: Support no_sanitize_undefined check with GCC 4

In reply to Marco Elver
The following commit has been merged into the x86/entry branch of tip:

The following commit has been merged into the x86/entry branch of tip:

Commit-ID:     33aea07f30c261eff7ba229f19fd1b161e0fb851
Gitweb:        https://git.kernel.org/tip/33aea07f30c261eff7ba229f19fd1b161e0fb851
Author:        Marco Elver <[email protected]>
AuthorDate:    Tue, 16 Jun 2020 01:15:29 +02:00
Committer:     Peter Zijlstra <[email protected]>
CommitterDate: Tue, 16 Jun 2020 15:35:02 +02:00

compiler_attributes.h: Support no_sanitize_undefined check with GCC 4

UBSAN is supported since GCC 4.9, which unfortunately did not yet have __has_attribute(). To work around, the __GCC4_has_attribute workaround requires defining which compiler version supports the given attribute.

In the case of no_sanitize_undefined, it is the first version that supports UBSAN, which is GCC 4.9.

---
 include/linux/compiler_attributes.h | 1 +
 1 file changed, 1 insertion(+)
include/linux/compiler_attributes.h +1 -0
index cdf0165..c8f03d2 100644
@@ -40,6 +40,7 @@
 # define __GCC4_has_attribute___noclone__             1
 # define __GCC4_has_attribute___nonstring__           0
 # define __GCC4_has_attribute___no_sanitize_address__ (__GNUC_MINOR__ >= 8)
+# define __GCC4_has_attribute___no_sanitize_undefined__ (__GNUC_MINOR__ >= 9)
 # define __GCC4_has_attribute___fallthrough__         0
 #endif