libbpf: Disable SEC pragma macro on GCC
It seems the gcc preprocessor breaks with pragmas when surrounding __attribute__. Disable these pragmas on GCC due to upstream bugs see: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=55578 https://gcc.gnu.org/bugzilla/show_bug.cgi?id=90400 Fixes errors like: error: expected identifier or '(' before '#pragma' 106 | SEC("cgroup/bind6") | ^~~ error: expected '=', ',', ';', 'asm' or '__attribute__' before '#pragma' 114 | char _license[] SEC("license") = "GPL"; | ^~~ Signed-off-by: James Hilliard <james.hilliard1@gmail.com> Signed-off-by: Andrii Nakryiko <andrii@kernel.org> Link: https://lore.kernel.org/bpf/20220706111839.1247911-1-james.hilliard1@gmail.com
This commit is contained in:
parent
d1a6edecc1
commit
18410251f6
|
@ -22,12 +22,25 @@
|
||||||
* To allow use of SEC() with externs (e.g., for extern .maps declarations),
|
* To allow use of SEC() with externs (e.g., for extern .maps declarations),
|
||||||
* make sure __attribute__((unused)) doesn't trigger compilation warning.
|
* make sure __attribute__((unused)) doesn't trigger compilation warning.
|
||||||
*/
|
*/
|
||||||
|
#if __GNUC__ && !__clang__
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Pragma macros are broken on GCC
|
||||||
|
* https://gcc.gnu.org/bugzilla/show_bug.cgi?id=55578
|
||||||
|
* https://gcc.gnu.org/bugzilla/show_bug.cgi?id=90400
|
||||||
|
*/
|
||||||
|
#define SEC(name) __attribute__((section(name), used))
|
||||||
|
|
||||||
|
#else
|
||||||
|
|
||||||
#define SEC(name) \
|
#define SEC(name) \
|
||||||
_Pragma("GCC diagnostic push") \
|
_Pragma("GCC diagnostic push") \
|
||||||
_Pragma("GCC diagnostic ignored \"-Wignored-attributes\"") \
|
_Pragma("GCC diagnostic ignored \"-Wignored-attributes\"") \
|
||||||
__attribute__((section(name), used)) \
|
__attribute__((section(name), used)) \
|
||||||
_Pragma("GCC diagnostic pop") \
|
_Pragma("GCC diagnostic pop") \
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
/* Avoid 'linux/stddef.h' definition of '__always_inline'. */
|
/* Avoid 'linux/stddef.h' definition of '__always_inline'. */
|
||||||
#undef __always_inline
|
#undef __always_inline
|
||||||
#define __always_inline inline __attribute__((always_inline))
|
#define __always_inline inline __attribute__((always_inline))
|
||||||
|
|
Loading…
Reference in New Issue