![Alexei Starovoitov](/assets/img/avatar_default.png)
clang started to error on invalid asm clobber usage in x86 headers and many bpf program samples failed to build with the message: CLANG-bpf /data/users/ast/bpf-next/samples/bpf/xdp_redirect_kern.o In file included from /data/users/ast/bpf-next/samples/bpf/xdp_redirect_kern.c:14: In file included from ../include/linux/in.h:23: In file included from ../include/uapi/linux/in.h:24: In file included from ../include/linux/socket.h:8: In file included from ../include/linux/uio.h:14: In file included from ../include/crypto/hash.h:16: In file included from ../include/linux/crypto.h:26: In file included from ../include/linux/uaccess.h:5: In file included from ../include/linux/sched.h:15: In file included from ../include/linux/sem.h:5: In file included from ../include/uapi/linux/sem.h:5: In file included from ../include/linux/ipc.h:9: In file included from ../include/linux/refcount.h:72: ../arch/x86/include/asm/refcount.h:72:36: error: asm-specifier for input or output variable conflicts with asm clobber list r->refs.counter, e, "er", i, "cx"); ^ ../arch/x86/include/asm/refcount.h:86:27: error: asm-specifier for input or output variable conflicts with asm clobber list r->refs.counter, e, "cx"); ^ 2 errors generated. Override volatile() to workaround the problem. Signed-off-by: Alexei Starovoitov <ast@kernel.org> Signed-off-by: Daniel Borkmann <daniel@iogearbox.net>
18 lines
453 B
C
18 lines
453 B
C
/* SPDX-License-Identifier: GPL-2.0 */
|
|
/* Copyright (c) 2019 Facebook */
|
|
#ifndef __ASM_GOTO_WORKAROUND_H
|
|
#define __ASM_GOTO_WORKAROUND_H
|
|
|
|
/* this will bring in asm_volatile_goto macro definition
|
|
* if enabled by compiler and config options.
|
|
*/
|
|
#include <linux/types.h>
|
|
|
|
#ifdef asm_volatile_goto
|
|
#undef asm_volatile_goto
|
|
#define asm_volatile_goto(x...) asm volatile("invalid use of asm_volatile_goto")
|
|
#endif
|
|
|
|
#define volatile(x...) volatile("")
|
|
#endif
|