Skip to content

"less restrictive attribute than its target" warnings #135

@rountree

Description

@rountree

gcc 9 introduced warnings to catch attribute mismatches. These generated warnings in the linux kernel source until the kernel was updated around v5.0.

bug report
patch

In short: don't use gcc 9 when compiling against versions of linux less than 5.0. If you do, you'll get warnings like this:

In file included from /g/g24/rountree/v/tioga/repos/msr-safe/msr_entry.c:35:
/g/g24/rountree/v/tioga/repos/msr-safe/msr_entry.c: At top level:
./include/linux/module.h:129:6: warning: ‘init_module’ specifies less restrictive attribute than its target ‘msr_init’: ‘cold’ [-Wmissing-attributes]                                                                                                                        
  129 |  int init_module(void) __attribute__((alias(#initfn)));
      |      ^~~~~~~~~~~
/g/g24/rountree/v/tioga/repos/msr-safe/msr_entry.c:364:1: note: in expansion of macro ‘module_init’
  364 | module_init(msr_init);
      | ^~~~~~~~~~~
/g/g24/rountree/v/tioga/repos/msr-safe/msr_entry.c:267:19: note: ‘init_module’ target declared here
  267 | static int __init msr_init(void)
      |                   ^~~~~~~~
In file included from /g/g24/rountree/v/tioga/repos/msr-safe/msr_entry.c:35:
./include/linux/module.h:135:7: warning: ‘cleanup_module’ specifies less restrictive attribute than its target ‘msr_exit’: ‘cold’ [-Wmissing-attributes]                                                                                                                     
  135 |  void cleanup_module(void) __attribute__((alias(#exitfn)));
      |       ^~~~~~~~~~~~~~
/g/g24/rountree/v/tioga/repos/msr-safe/msr_entry.c:388:1: note: in expansion of macro ‘module_exit’
  388 | module_exit(msr_exit)
      | ^~~~~~~~~~~
/g/g24/rountree/v/tioga/repos/msr-safe/msr_entry.c:366:20: note: ‘cleanup_module’ target declared here
  366 | static void __exit msr_exit(void)
      |                    ^~~~~~~~

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions