tools header compiler.h update
Subsystems (7)
Ian Rogers
reviewercover tools header compiler.h update
Update tools/include/linux/compiler.h so that the definition of noinline can be updated to avoid an LLVM libc breakage. Fix build issues and try to synchronize other pieces on the way. For atomic.h, don't try to synchronize and just punt to stdatomic.h that we can assume is present since the move to C11.
Ian Rogers (13):
tools bpf: Synchronize bpf.h with kernel uapi version
libbpf: Make __printf define conditional
libperf xyarray: Use correct stddef.h include
perf expr: Add missing stdbool.h include
perf expr: Tidy up header guard
perf debug: Add missing linux/types.h include
perf cacheline: Add missing linux/types.h include perf arm-spe: Add missing linux/types.h include tools headers: Rewrite linux/atomic.h using C11's stdatomic.h
asm-generic: Avoid transitive dependency for unaligned.h tools headers: Sync linux/overflow.h
tools headers: Sync compiler.h headers
tools headers: Rename noinline to __noinline
include/asm-generic/unaligned.h | 2 + tools/arch/x86/include/asm/atomic.h | 84 ---- tools/include/asm-generic/atomic-gcc.h | 95 ---- tools/include/asm-generic/bitops/non-atomic.h | 1 + tools/include/asm-generic/unaligned.h | 2 + tools/include/asm/atomic.h | 11 - tools/include/asm/rwonce.h | 63 +++ tools/include/linux/atomic.h | 107 ++++- tools/include/linux/compiler-clang.h | 124 +++++ tools/include/linux/compiler-gcc.h | 145 +++++- tools/include/linux/compiler.h | 221 ++------- tools/include/linux/compiler_attributes.h | 449 ++++++++++++++++++ tools/include/linux/compiler_types.h | 171 ++++++- tools/include/linux/overflow.h | 331 ++++++++++--- tools/include/linux/rbtree.h | 1 + tools/include/linux/string.h | 1 + tools/include/linux/types.h | 17 +- tools/include/uapi/linux/bpf.h | 1 + tools/lib/bpf/libbpf.c | 4 +- tools/lib/perf/include/internal/xyarray.h | 2 +- tools/perf/arch/x86/tests/bp-modify.c | 4 +- tools/perf/bench/find-bit-bench.c | 2 +- tools/perf/check-headers.sh | 4 + tools/perf/tests/bp_account.c | 2 +- tools/perf/tests/bp_signal.c | 2 +- tools/perf/tests/bp_signal_overflow.c | 2 +- tools/perf/tests/dwarf-unwind.c | 12 +- tools/perf/tests/workloads/leafloop.c | 8 +- tools/perf/tests/workloads/thloop.c | 4 +- .../util/arm-spe-decoder/arm-spe-decoder.h | 1 + .../arm-spe-decoder/arm-spe-pkt-decoder.c | 8 +- tools/perf/util/cacheline.h | 1 + tools/perf/util/debug.h | 1 + tools/perf/util/expr.h | 8 +- .../selftests/kvm/include/kvm_util_base.h | 3 +- 35 files changed, 1388 insertions(+), 506 deletions(-) delete mode 100644 tools/arch/x86/include/asm/atomic.h delete mode 100644 tools/include/asm-generic/atomic-gcc.h delete mode 100644 tools/include/asm/atomic.h create mode 100644 tools/include/asm/rwonce.h create mode 100644 tools/include/linux/compiler-clang.h create mode 100644 tools/include/linux/compiler_attributes.h
Signature · 1 line
2.44.0.278.ge034bb2e1d-goog
Ian Rogers
reviewerPATCH 1/13 tools bpf: Synchronize bpf.h with kernel uapi version
Commit 91051f003948 ("tcp: Dump bound-only sockets in inet_diag.") added BPF_TCP_BOUND_INACTIVE to the enum of tcp states in uapi's bpf.h. Synchronize the tools version of the file.
To avoid future divergence add uapi/linux/bpf.h, include/uapi/linux/bpf_common.h and include/uapi/linux/bpf_perf_event.h to the check-headers.sh script.
--- tools/include/uapi/linux/bpf.h | 1 + tools/perf/check-headers.sh | 3 +++ 2 files changed, 4 insertions(+)
tools/include/uapi/linux/bpf.h +1 -0
@@ -6904,6 +6904,7 @@ enum {BPF_TCP_LISTEN ,BPF_TCP_CLOSING ,/* Now a valid state */ BPF_TCP_NEW_SYN_RECV , +BPF_TCP_BOUND_INACTIVE , BPF_TCP_MAX_STATES /* Leave at the end! */ };
tools/perf/check-headers.sh +3 -0
@@ -6,6 +6,9 @@ NC='\033[0m' # No Color declare -a FILES FILES=( + "include/uapi/linux/bpf.h" + "include/uapi/linux/bpf_common.h" + "include/uapi/linux/bpf_perf_event.h" "include/uapi/linux/const.h" "include/uapi/drm/drm.h" "include/uapi/drm/i915_drm.h"
Signature · 1 line
2.44.0.278.ge034bb2e1d-goog
Ian Rogers
reviewerPATCH 2/13 libbpf: Make __printf define conditional
In reply to Ian Rogerslibbpf depends upon linux/err.h which has a linux/compiler.h dependency. In the kernel includes, as opposed to the tools version, linux/compiler.h includes linux/compiler_attributes.h which defines __printf. As the libbpf.c __printf definition isn't guarded by an ifndef, this leads to a duplicate definition compilation error when trying to update the tools/include/linux/compiler.h. Fix this by adding the missing ifndef.
--- tools/lib/bpf/libbpf.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
tools/lib/bpf/libbpf.c +3 -1
@@ -66,7 +66,9 @@*/ #pragma GCC diagnostic ignored "-Wformat-nonliteral" -#define __printf (a, b) __attribute__((format(printf, a, b))) +#ifndef __printf +# define __printf (a, b) __attribute__((format(printf, a, b))) +#endif static struct bpf_map *bpf_object__add_map (struct bpf_object *obj);static bool prog_is_subprog (const struct bpf_object *obj,const struct bpf_program *prog);
Signature · 1 line
2.44.0.278.ge034bb2e1d-goog
Re: [PATCH v1 02/13] libbpf: Make __printf define conditional
Quoted 19 lines · Ian Rogers
libbpf depends upon
linux/err.hwhich has alinux/compiler.hdependency. In the kernel includes, as opposed to the tools version,linux/compiler.hincludeslinux/compiler_attributes.hwhich defines__printf. As thelibbpf.c__printfdefinition isn't guarded by an ifndef, this leads to a duplicate definition compilation error when trying to update thetools/include/linux/compiler.h. Fix this by adding the missing ifndef.Signed-off-by Ian Rogers <[email protected]>--- tools/lib/bpf/libbpf.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)tools/lib/bpf/libbpf.c +0
-0
tools/lib/bpf/libbpf.c line 70
Quoted 6 lines
tools/lib/bpf/libbpf.c +2
-1@@ -66,7 +66,9 @@*/ #pragma GCC diagnostic ignored "-Wformat-nonliteral" -#define __printf (a, b) __attribute__((format(printf, a, b))) +#ifndef __printf +# define __printf (a, b) __attribute__((format(printf, a, b)))
styling nit: don't add spaces between # and define, please
overall LGTM
Two questions, though.
1. It seems like just dropping #define __printf in libbpf.c compiles fine (I checked both building libbpf directly, and BPF selftest, and perf, and bpftool directly, all of them built fine). So we can probably just drop this. I'll need to add __printf on Github, but that's fine.
2. Logistics. Which tree should this patch go through? Can I land it in bpf-next or it's too much inconvenience for you?
Quoted 7 lines
tools/lib/bpf/libbpf.c +1
-1+#endif static struct bpf_map *bpf_object__add_map (struct bpf_object *obj);static bool prog_is_subprog (const struct bpf_object *obj,const struct bpf_program *prog); --2.44.0.278.ge034bb2e1d-goog
Ian Rogers
reviewerRe: [PATCH v1 02/13] libbpf: Make __printf define conditional
Quoted 36 lines · Andrii Nakryiko
Quoted 19 lines · Ian Rogers
libbpf depends upon
linux/err.hwhich has alinux/compiler.hdependency. In the kernel includes, as opposed to the tools version,linux/compiler.hincludeslinux/compiler_attributes.hwhich defines__printf. As thelibbpf.c__printfdefinition isn't guarded by an ifndef, this leads to a duplicate definition compilation error when trying to update thetools/include/linux/compiler.h. Fix this by adding the missing ifndef.Signed-off-by Ian Rogers <[email protected]>--- tools/lib/bpf/libbpf.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)tools/lib/bpf/libbpf.c +0
-0tools/lib/bpf/libbpf.c line 70
Quoted 6 lines
tools/lib/bpf/libbpf.c +2
-1@@ -66,7 +66,9 @@*/ #pragma GCC diagnostic ignored "-Wformat-nonliteral" -#define __printf (a, b) __attribute__((format(printf, a, b))) +#ifndef __printf +# define __printf (a, b) __attribute__((format(printf, a, b)))styling nit: don't add spaces between # and define, please
overall LGTM
Acked-by Andrii Nakryiko <[email protected]>Two questions, though.
Quoted 8 lines
1. It seems like just dropping #define
__printfinlibbpf.ccompiles fine (I checked both building libbpf directly, and BPF selftest, and perf, and bpftool directly, all of them built fine). So we can probably just drop this. I'll need to add__printfon Github, but that's fine.2. Logistics. Which tree should this patch go through? Can I land it in bpf-next or it's too much inconvenience for you?
Thanks Andrii,
dropping the #define (1) sgtm but the current compiler.h will fail to build libbpf.c without the later compiler.h update in this series. This causes another logistic issue for your point 2. Presumably if this patch goes through bpf-next, the first patch "tools bpf:
Synchronize bpf.h with kernel uapi version" should also go through the bpf-next.
Thanks,
Ian
Quoted 7 lines
Quoted 7 lines
tools/lib/bpf/libbpf.c +1
-1+#endif static struct bpf_map *bpf_object__add_map (struct bpf_object *obj);static bool prog_is_subprog (const struct bpf_object *obj,const struct bpf_program *prog); --2.44.0.278.ge034bb2e1d-goog
Re: [PATCH v1 02/13] libbpf: Make __printf define conditional
Quoted 48 lines · Ian Rogers
Quoted 36 lines · Andrii Nakryiko
Quoted 19 lines · Ian Rogers
libbpf depends upon
linux/err.hwhich has alinux/compiler.hdependency. In the kernel includes, as opposed to the tools version,linux/compiler.hincludeslinux/compiler_attributes.hwhich defines__printf. As thelibbpf.c__printfdefinition isn't guarded by an ifndef, this leads to a duplicate definition compilation error when trying to update thetools/include/linux/compiler.h. Fix this by adding the missing ifndef.Signed-off-by Ian Rogers <[email protected]>--- tools/lib/bpf/libbpf.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)tools/lib/bpf/libbpf.c +0
-0tools/lib/bpf/libbpf.c line 70
Quoted 6 lines
tools/lib/bpf/libbpf.c +2
-1@@ -66,7 +66,9 @@*/ #pragma GCC diagnostic ignored "-Wformat-nonliteral" -#define __printf (a, b) __attribute__((format(printf, a, b))) +#ifndef __printf +# define __printf (a, b) __attribute__((format(printf, a, b)))styling nit: don't add spaces between # and define, please
overall LGTM
Acked-by Andrii Nakryiko <[email protected]>Two questions, though.
Quoted 8 lines
1. It seems like just dropping #define
__printfinlibbpf.ccompiles fine (I checked both building libbpf directly, and BPF selftest, and perf, and bpftool directly, all of them built fine). So we can probably just drop this. I'll need to add__printfon Github, but that's fine.2. Logistics. Which tree should this patch go through? Can I land it in bpf-next or it's too much inconvenience for you?
Quoted 9 lines
Thanks Andrii,
dropping the #define (1) sgtm but the current
compiler.hwill fail to buildlibbpf.cwithout the latercompiler.hupdate in this series. This causes another logistic issue for your point 2. Presumably if this patch goes through bpf-next, the first patch "tools bpf:
Synchronizebpf.hwith kernel uapi version" should also go through the bpf-next.
That's what I'm saying, it seems to work without your patches already. At least on bpf-next/master. But it's ok, let's keep it and just add #ifndef guard, that will make my life easier when syncing to Github later one. Then the patch can go through other trees and eventually make it into bpf-next and then Github. So please keep my ack for #ifndef version, thanks.
Quoted 11 lines
Thanks,
IanQuoted 7 lines
Quoted 7 lines
tools/lib/bpf/libbpf.c +1
-1+#endif static struct bpf_map *bpf_object__add_map (struct bpf_object *obj);static bool prog_is_subprog (const struct bpf_object *obj,const struct bpf_program *prog); --2.44.0.278.ge034bb2e1d-goog
Ian Rogers
reviewerPATCH 3/13 libperf xyarray: Use correct stddef.h include
In reply to Ian Rogerssys/types.h may not define both NULL and size_t used in this file. Change the dependency to the correct stddef.h one.
--- tools/lib/perf/include/internal/xyarray.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
tools/lib/perf/include/internal/xyarray.h +1 -1
@@ -3,7 +3,7 @@#define __LIBPERF_INTERNAL_XYARRAY_H#include <linux/compiler.h> -#include <sys/types.h> +#include <stddef.h> struct xyarray {size_t row_size;
Signature · 1 line
2.44.0.278.ge034bb2e1d-goog
Ian Rogers
reviewerPATCH 4/13 perf expr: Add missing stdbool.h include
In reply to Ian Rogersbool is used in this header and so stdbool.h is necessary. Add to avoid compilation errors that aren't currently seen due to transitive dependencies.
--- tools/perf/util/expr.h | 2 ++ 1 file changed, 2 insertions(+)
tools/perf/util/expr.h +2 -0
@@ -2,6 +2,8 @@#ifndef PARSE_CTX_H #define PARSE_CTX_H 1 +#include <stdbool.h> +struct hashmap ;struct metric_ref ;
Signature · 1 line
2.44.0.278.ge034bb2e1d-goog
Ian Rogers
reviewerPATCH 5/13 perf expr: Tidy up header guard
In reply to Ian RogersMake the header guard reflect the name of the file and add a comment to the terminating endif.
--- tools/perf/util/expr.h | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
tools/perf/util/expr.h +3 -3
@@ -1,6 +1,6 @@/* SPDX-License-Identifier: GPL-2.0 */ -#ifndef PARSE_CTX_H -#define PARSE_CTX_H 1 +#ifndef __PERF_EXPR_H +#define __PERF_EXPR_H 1#include <stdbool.h>
@@ -59,4 +59,4 @@ double expr__get_literal(const char *literal, const struct expr_scanner_ctx *ctxdouble expr__has_event (const struct expr_parse_ctx *ctx,bool compute_ids,const char *id);double expr__strcmp_cpuid_str (const struct expr_parse_ctx *ctx,bool compute_ids,const char *id); -#endif +#endif /* __PERF_EXPR_H */
Signature · 1 line
2.44.0.278.ge034bb2e1d-goog
Ian Rogers
reviewerPATCH 6/13 perf debug: Add missing linux/types.h include
In reply to Ian Rogersu64 is used in this header for eprintf_time and so linux/types.h is necessary. Add to avoid compilation errors that aren't currently seen due to transitive dependencies.
--- tools/perf/util/debug.h | 1 + 1 file changed, 1 insertion(+)
tools/perf/util/debug.h +1 -0
@@ -7,6 +7,7 @@#include <stdbool.h> #include <stdio.h> #include <linux/compiler.h> +#include <linux/types.h> extern int verbose;extern int debug_kmaps;
Signature · 1 line
2.44.0.278.ge034bb2e1d-goog
Ian Rogers
reviewerPATCH 7/13 perf cacheline: Add missing linux/types.h include
In reply to Ian Rogersu64 is used in this header for cl_address and cl_offset, so linux/types.h is necessary. Add to avoid compilation errors that aren't currently seen due to transitive dependencies.
--- tools/perf/util/cacheline.h | 1 + 1 file changed, 1 insertion(+)
tools/perf/util/cacheline.h +1 -0
@@ -3,6 +3,7 @@#define PERF_CACHELINE_H #include <linux/compiler.h> +#include <linux/types.h> int __pure cacheline_size (void );
Signature · 1 line
2.44.0.278.ge034bb2e1d-goog
Ian Rogers
reviewerPATCH 8/13 perf arm-spe: Add missing linux/types.h include
In reply to Ian Rogersu64 is used for various structs in arm-spe-decoder.h, while uint64_t is used in arm-spe-pkt-decoder.h. Avoid transitive dependencies bringing in linux/types.h and directly depend upon it in arm-spe-decoder.h. Fix arm-spe-decoder.c to use uint64_t, as the header file does.
--- tools/perf/util/arm-spe-decoder/arm-spe-decoder.h | 1 + tools/perf/util/arm-spe-decoder/arm-spe-pkt-decoder.c | 8 ++++---- 2 files changed, 5 insertions(+), 4 deletions(-)
tools/perf/util/arm-spe-decoder/arm-spe-decoder.h +1 -0
@@ -10,6 +10,7 @@#include <stdbool.h> #include <stddef.h> #include <stdint.h> +#include <linux/types.h> #include "arm-spe-pkt-decoder.h"
tools/perf/util/arm-spe-decoder/arm-spe-pkt-decoder.c +4 -4
@@ -292,7 +292,7 @@ static int arm_spe_pkt_out_string(int *err, char **buf_p, size_t *blen,static int arm_spe_pkt_desc_event (const struct arm_spe_pkt *packet,char *buf,size_t buf_len) { -u64 payload = packet->payload; +uint64_t payload = packet->payload;int err =0 ;arm_spe_pkt_out_string (&err, &buf, &buf_len,"EV" );
@@ -332,7 +332,7 @@ static int arm_spe_pkt_desc_event(const struct arm_spe_pkt *packet,static int arm_spe_pkt_desc_op_type (const struct arm_spe_pkt *packet,char *buf,size_t buf_len) { -u64 payload = packet->payload; +uint64_t payload = packet->payload;int err =0 ;switch (packet->index) {
@@ -429,7 +429,7 @@ static int arm_spe_pkt_desc_addr(const struct arm_spe_pkt *packet, {int ns, el, idx = packet->index;int ch, pat; -u64 payload = packet->payload; +uint64_t payload = packet->payload;int err =0 ;static const char *idx_name[] = {"PC" ,"TGT" ,"VA" ,"PA" ,"PBT" };
@@ -469,7 +469,7 @@ static int arm_spe_pkt_desc_addr(const struct arm_spe_pkt *packet,static int arm_spe_pkt_desc_counter (const struct arm_spe_pkt *packet,char *buf,size_t buf_len) { -u64 payload = packet->payload; +uint64_t payload = packet->payload;const char *name =arm_spe_pkt_name (packet->type);int err =0 ;
Signature · 1 line
2.44.0.278.ge034bb2e1d-goog
Ian Rogers
reviewerPATCH 9/13 tools headers: Rewrite linux/atomic.h using C11's stdatomic.h
In reply to Ian RogersCode in tools tries to follow the patterns of the kernel, so the atomic functions names match. However, having include/linux/atomic.h in tools complicates building code in tools as assembly and other functions are necessary - these are often configured in the kernel using CONFIG options. As tools C code is compiled with the -std=gnu11 flag, it is possible to use stdatomic.h and move the build and other complications to the compiler/libc.
--- tools/arch/x86/include/asm/atomic.h | 84 -------------- tools/include/asm-generic/atomic-gcc.h | 95 ---------------- tools/include/asm/atomic.h | 11 -- tools/include/linux/atomic.h | 107 ++++++++++++++++-- tools/include/linux/types.h | 15 ++- .../selftests/kvm/include/kvm_util_base.h | 3 +- 6 files changed, 110 insertions(+), 205 deletions(-) delete mode 100644 tools/arch/x86/include/asm/atomic.h delete mode 100644 tools/include/asm-generic/atomic-gcc.h delete mode 100644 tools/include/asm/atomic.h
tools/arch/x86/include/asm/atomic.h deleted +0 -84
@@ -1,84 +0,0 @@ -/* SPDX-License-Identifier: GPL-2.0 */ -#ifndef _TOOLS_LINUX_ASM_X86_ATOMIC_H -#define _TOOLS_LINUX_ASM_X86_ATOMIC_H - -#include <linux/compiler.h> -#include <linux/types.h> -#include "rmwcc.h" - -#define LOCK_PREFIX "\n\tlock; " - -#include <asm/asm.h> -#include <asm/cmpxchg.h> - -/* - * Atomic operations that C can't guarantee us. Useful for - * resource counting etc.. - */ - -#define ATOMIC_INIT(i) { (i) } - -/** - * atomic_read - read atomic variable - * @v: pointer of type atomic_t - * - * Atomically reads the value of @v. - */ -static inline int atomic_read(const atomic_t *v) -{ - return READ_ONCE((v)->counter); -} - -/** - * atomic_set - set atomic variable - * @v: pointer of type atomic_t - * @i: required value - * - * Atomically sets the value of @v to @i. - */ -static inline void atomic_set(atomic_t *v, int i) -{ - v->counter = i; -} - -/** - * atomic_inc - increment atomic variable - * @v: pointer of type atomic_t - * - * Atomically increments @v by 1. - */ -static inline void atomic_inc(atomic_t *v) -{ - asm volatile(LOCK_PREFIX "incl %0" - : "+m" (v->counter)); -} - -/** - * atomic_dec_and_test - decrement and test - * @v: pointer of type atomic_t - * - * Atomically decrements @v by 1 and - * returns true if the result is 0, or false for all other - * cases. - */ -static inline int atomic_dec_and_test(atomic_t *v) -{ - GEN_UNARY_RMWcc(LOCK_PREFIX "decl", v->counter, "%0", "e"); -} - -static __always_inline int atomic_cmpxchg(atomic_t *v, int old, int new) -{ - return cmpxchg(&v->counter, old, new); -} - -static inline int test_and_set_bit(long nr, unsigned long *addr) -{ - GEN_BINARY_RMWcc(LOCK_PREFIX __ASM_SIZE(bts), *addr, "Ir", nr, "%0", "c"); -} - -static inline int test_and_clear_bit(long nr, unsigned long *addr) -{ - GEN_BINARY_RMWcc(LOCK_PREFIX __ASM_SIZE(btc), *addr, "Ir", nr, "%0", "c"); -} - -#endif /* _TOOLS_LINUX_ASM_X86_ATOMIC_H */
tools/include/asm-generic/atomic-gcc.h deleted +0 -95
95 lines not on this page · raw message
tools/include/asm/atomic.h deleted +0 -11
@@ -1,11 +0,0 @@ -/* SPDX-License-Identifier: GPL-2.0 */ -#ifndef __TOOLS_LINUX_ASM_ATOMIC_H -#define __TOOLS_LINUX_ASM_ATOMIC_H - -#if defined(__i386__) || defined(__x86_64__) -#include "../../arch/x86/include/asm/atomic.h" -#else -#include <asm-generic/atomic-gcc.h> -#endif - -#endif /* __TOOLS_LINUX_ASM_ATOMIC_H */
tools/include/linux/atomic.h +100 -7
114 lines not on this page · raw message
tools/include/linux/types.h +9 -6
@@ -74,13 +74,16 @@ typedef u64 phys_addr_t;typedef u32 phys_addr_t ;#endif -typedef struct { -int counter; -}atomic_t ; +#ifndef __cplusplus +/* C++17 doesn't support stdatomic.h but C++23 does. */ +#include <stdatomic.h> -typedef struct { -long counter; -}atomic_long_t ; +typedef atomic_int atomic_t ; + +#define ATOMIC_INIT (i) (i) + +typedef atomic_long atomic_long_t ; +#endif #ifndef __aligned_u64# define __aligned_u64 __u64 __attribute__((aligned(8)))
tools/testing/selftests/kvm/include/kvm_util_base.h +1 -2
@@ -9,6 +9,7 @@#include "test_util.h" +#include <linux/atomic.h> #include <linux/compiler.h> #include "linux/hashtable.h" #include "linux/list.h"
@@ -17,8 +18,6 @@#include "linux/rbtree.h" #include <linux/types.h> -#include <asm/atomic.h> -#include <sys/ioctl.h> #include "sparsebit.h"
Signature · 1 line
2.44.0.278.ge034bb2e1d-goog
Ian Rogers
reviewerPATCH 10/13 asm-generic: Avoid transitive dependency for unaligned.h
In reply to Ian Rogersunaligned.h uses types from linux/types.h such as u64, but doesn't directly import linux/types.h. This can cause breakages when the declarations of the types is reliant on a transitive dependency and the dependencies change. Add the missing header file to avoid this.
--- include/asm-generic/unaligned.h | 2 ++ tools/include/asm-generic/unaligned.h | 2 ++ 2 files changed, 4 insertions(+)
include/asm-generic/unaligned.h +2 -0
@@ -2,6 +2,8 @@#ifndef __ASM_GENERIC_UNALIGNED_H#define __ASM_GENERIC_UNALIGNED_H +#include <linux/types.h> +/* * This is the most generic implementation of unaligned accesses * and should work almost anywhere.
tools/include/asm-generic/unaligned.h +2 -0
@@ -2,6 +2,8 @@#ifndef __ASM_GENERIC_UNALIGNED_H#define __ASM_GENERIC_UNALIGNED_H +#include <linux/types.h> +/* * This is the most generic implementation of unaligned accesses * and should work almost anywhere.
Signature · 1 line
2.44.0.278.ge034bb2e1d-goog
Ian Rogers
reviewerPATCH 11/13 tools headers: Sync linux/overflow.h
In reply to Ian RogersBring in the changes:
26dd68d293fd overflow: add DEFINE_FLEX() for on-stack allocs d67790ddf021 overflow: Add struct_size_t() helper 4b21d25bf519 overflow: Introduce overflows_type() and castable_to_type() 31970608a6d3 overflow: Fix kern-doc markup for functions d219d2a9a92e overflow: Allow mixed type arguments 92d23c6e9415 overflow, tracing: Define the is_signed_type() macro once 230f6fa2c1db overflow: Provide constant expression struct_size e1be43d9b5d0 overflow: Implement size_t saturating arithmetic helpers
Add file to check-headers.sh, so there is a warning if the tools version of the file drifts from the kernel's version.
--- tools/include/linux/overflow.h | 331 ++++++++++++++++++++++++++------- tools/perf/check-headers.sh | 1 + 2 files changed, 268 insertions(+), 64 deletions(-)
tools/include/linux/overflow.h +267 -64
@@ -3,6 +3,8 @@#define __LINUX_OVERFLOW_H#include <linux/compiler.h> +#include <linux/limits.h> +#include <linux/const.h> /* * We need to compute the minimum and maximum values representable in a given
@@ -28,117 +30,318 @@* https://mail-index.netbsd.org/tech-misc/2007/02/05/0000.html - * credit to Christian Biere. */ -#define is_signed_type (type) (((type)(-1)) < (type)1)#define __type_half_max (type) ((type)1 << (8*sizeof(type) - 1 - is_signed_type(type)))#define type_max (T ) ((T)((__type_half_max(T) - 1) + __type_half_max(T)))#define type_min (T ) ((T)((T)-type_max(T)-(T)1))/* -* For simplicity and code hygiene, the fallback code below insists on -* a, b and *d having the same type (similar to the min() and max() -* macros), whereas gcc's type-generic overflow checkers accept -* different types. Hence we don't just make check_add_overflow an -* alias for __builtin_add_overflow, but add type checks similar to -* below. -*/ -#define check_add_overflow (a, b, d) ({ \ - typeof(a) __a = (a); \ - typeof(b) __b = (b); \ - typeof(d) __d = (d); \ - (void) (&__a == &__b); \ - (void) (&__a == __d); \ - __builtin_add_overflow(__a, __b, __d); \ -}) +* Avoids triggering -Wtype-limits compilation warning, +* while using unsigned data types to check a < 0. +*/ +#define is_non_negative (a) ((a) > 0 || (a) == 0) +#define is_negative (a) (!(is_non_negative(a))) -#define check_sub_overflow (a, b, d) ({ \ - typeof(a) __a = (a); \ - typeof(b) __b = (b); \ - typeof(d) __d = (d); \ - (void) (&__a == &__b); \ - (void) (&__a == __d); \ - __builtin_sub_overflow(__a, __b, __d); \ -}) +/* +* Allows for effectively applying __must_check to a macro so we can have +* both the type-agnostic benefits of the macros while also being able to +* enforce that the return value is, in fact, checked. +*/ +static inline bool __must_check __must_check_overflow (bool overflow) +{ +return unlikely (overflow); +} + +/** +* check_add_overflow() - Calculate addition with overflow checking +* @a: first addend +* @b: second addend +* @d: pointer to store sum +* +* Returns 0 on success. +* +* *@d holds the results of the attempted addition, but is not considered +* "safe for use" on a non-zero return value, which indicates that the +* sum has overflowed or been truncated. +*/ +#define check_add_overflow (a, b, d) \ + __must_check_overflow(__builtin_add_overflow(a, b, d)) + +/** +* check_sub_overflow() - Calculate subtraction with overflow checking +* @a: minuend; value to subtract from +* @b: subtrahend; value to subtract from @a +* @d: pointer to store difference +* +* Returns 0 on success. +* +* *@d holds the results of the attempted subtraction, but is not considered +* "safe for use" on a non-zero return value, which indicates that the +* difference has underflowed or been truncated. +*/ +#define check_sub_overflow (a, b, d) \ + __must_check_overflow(__builtin_sub_overflow(a, b, d)) + +/** +* check_mul_overflow() - Calculate multiplication with overflow checking +* @a: first factor +* @b: second factor +* @d: pointer to store product +* +* Returns 0 on success. +* +* *@d holds the results of the attempted multiplication, but is not +* considered "safe for use" on a non-zero return value, which indicates +* that the product has overflowed or been truncated. +*/ +#define check_mul_overflow (a, b, d) \ + __must_check_overflow(__builtin_mul_overflow(a, b, d)) + +/** +* check_shl_overflow() - Calculate a left-shifted value and check overflow +* @a: Value to be shifted +* @s: How many bits left to shift +* @d: Pointer to where to store the result +* +* Computes *@d = (@a << @s) +* +* Returns true if '*@d' cannot hold the result or when '@a << @s' doesn't +* make sense. Example conditions: +* +* - '@a << @s' causes bits to be lost when stored in *@d. +* - '@s' is garbage (e.g. negative) or so large that the result of +* '@a << @s' is guaranteed to be 0. +* - '@a' is negative. +* - '@a << @s' sets the sign bit, if any, in '*@d'. +* +* '*@d' will hold the results of the attempted shift, but is not +* considered "safe for use" if true is returned. +*/ +#define check_shl_overflow (a, s, d) __must_check_overflow(({ \ + typeof(a) _a = a; \ + typeof(s) _s = s; \ + typeof(d) _d = d; \ + u64 _a_full = _a; \ + unsigned int _to_shift = \ + is_non_negative(_s) && _s < 8 * sizeof(*d) ? _s : 0; \ + *_d = (_a_full << _to_shift); \ + (_to_shift != _s || is_negative(*_d) || is_negative(_a) || \ + (*_d >> _to_shift) != _a); \ +})) -#define check_mul_overflow (a, b, d) ({ \ - typeof(a) __a = (a); \ - typeof(b) __b = (b); \ - typeof(d) __d = (d); \ - (void) (&__a == &__b); \ - (void) (&__a == __d); \ - __builtin_mul_overflow(__a, __b, __d); \ +#define __overflows_type_constexpr (x,T ) ( \ + is_unsigned_type(typeof(x)) ? \ + (x) > type_max(typeof(T)) : \ + is_unsigned_type(typeof(T)) ? \ + (x) < 0 || (x) > type_max(typeof(T)) : \ + (x) < type_min(typeof(T)) || (x) > type_max(typeof(T))) + +#define __overflows_type (x,T ) ({ \ + typeof(T) v = 0; \ + check_add_overflow((x), v, &v); \ })/** -* array_size() - Calculate size of 2-dimensional array. +* overflows_type - helper for checking the overflows between value, variables, +* or data type * -* @a: dimension one -* @b: dimension two +* @n: source constant value or variable to be checked +* @T: destination variable or data type proposed to store @x * -* Calculates size of 2-dimensional array: @a * @b. +* Compares the @x expression for whether or not it can safely fit in +* the storage of the type in @T. @x and @T can have different types. +* If @x is a constant expression, this will also resolve to a constant +* expression. * -* Returns: number of bytes needed to represent the array or SIZE_MAX on -* overflow. +* Returns: true if overflow can occur, false otherwise. +*/ +#define overflows_type (n,T ) \ + __builtin_choose_expr(__is_constexpr(n), \ + __overflows_type_constexpr(n, T), \ + __overflows_type(n, T)) + +/** +* castable_to_type - like __same_type(), but also allows for casted literals +* +* @n: variable or constant value +* @T: variable or data type +* +* Unlike the __same_type() macro, this allows a constant value as the +* first argument. If this value would not overflow into an assignment +* of the second argument's type, it returns true. Otherwise, this falls +* back to __same_type(). */ -static inline __must_check size_t array_size (size_t a,size_t b) +#define castable_to_type (n,T ) \ + __builtin_choose_expr(__is_constexpr(n), \ + !__overflows_type_constexpr(n, T), \ + __same_type(n, T)) + +/** +* size_mul() - Calculate size_t multiplication with saturation at SIZE_MAX +* @factor1: first factor +* @factor2: second factor +* +* Returns: calculate @factor1 * @factor2, both promoted to size_t, +* with any overflow causing the return value to be SIZE_MAX. The +* lvalue must be size_t to avoid implicit type conversion. +*/ +static inline size_t __must_check size_mul (size_t factor1,size_t factor2) {size_t bytes; -if (check_mul_overflow (a, b, &bytes)) +if (check_mul_overflow (factor1, factor2, &bytes))return SIZE_MAX ;return bytes; }/** -* array3_size() - Calculate size of 3-dimensional array. +* size_add() - Calculate size_t addition with saturation at SIZE_MAX +* @addend1: first addend +* @addend2: second addend * -* @a: dimension one -* @b: dimension two -* @c: dimension three -* -* Calculates size of 3-dimensional array: @a * @b * @c. -* -* Returns: number of bytes needed to represent the array or SIZE_MAX on -* overflow. +* Returns: calculate @addend1 + @addend2, both promoted to size_t, +* with any overflow causing the return value to be SIZE_MAX. The +* lvalue must be size_t to avoid implicit type conversion. */ -static inline __must_check size_t array3_size (size_t a,size_t b,size_t c) +static inline size_t __must_check size_add (size_t addend1,size_t addend2) {size_t bytes; -if (check_mul_overflow (a, b, &bytes)) -return SIZE_MAX ; -if (check_mul_overflow (bytes, c, &bytes)) +if (check_add_overflow (addend1, addend2, &bytes))return SIZE_MAX ;return bytes; } -static inline __must_check size_t __ab_c_size (size_t n,size_t size,size_t c) +/** +* size_sub() - Calculate size_t subtraction with saturation at SIZE_MAX +* @minuend: value to subtract from +* @subtrahend: value to subtract from @minuend +* +* Returns: calculate @minuend - @subtrahend, both promoted to size_t, +* with any overflow causing the return value to be SIZE_MAX. For +* composition with the size_add() and size_mul() helpers, neither +* argument may be SIZE_MAX (or the result with be forced to SIZE_MAX). +* The lvalue must be size_t to avoid implicit type conversion. +*/ +static inline size_t __must_check size_sub (size_t minuend,size_t subtrahend) {size_t bytes; -if (check_mul_overflow (n, size, &bytes)) -return SIZE_MAX ; -if (check_add_overflow (bytes, c, &bytes)) +if (minuend ==SIZE_MAX || subtrahend ==SIZE_MAX || +check_sub_overflow (minuend, subtrahend, &bytes))return SIZE_MAX ;return bytes; }/** -* struct_size() - Calculate size of structure with trailing array. +* array_size() - Calculate size of 2-dimensional array. +* @a: dimension one +* @b: dimension two +* +* Calculates size of 2-dimensional array: @a * @b. +* +* Returns: number of bytes needed to represent the array or SIZE_MAX on +* overflow. +*/ +#define array_size (a, b) size_mul(a, b) + +/** +* array3_size() - Calculate size of 3-dimensional array. +* @a: dimension one +* @b: dimension two +* @c: dimension three +* +* Calculates size of 3-dimensional array: @a * @b * @c. +* +* Returns: number of bytes needed to represent the array or SIZE_MAX on +* overflow. +*/ +#define array3_size (a, b, c) size_mul(size_mul(a, b), c) + +/** +* flex_array_size() - Calculate size of a flexible array member +* within an enclosing structure. * @p: Pointer to the structure. +* @member: Name of the flexible array member. +* @count: Number of elements in the array. +* +* Calculates size of a flexible array of @count number of @member +* elements, at the end of structure @p. +* +* Return: number of bytes needed or SIZE_MAX on overflow. +*/ +#define flex_array_size (p, member, count) \ + __builtin_choose_expr(__is_constexpr(count), \ + (count) * sizeof(*(p)->member) + __must_be_array((p)->member), \ + size_mul(count, sizeof(*(p)->member) + __must_be_array((p)->member))) + +/** +* struct_size() - Calculate size of structure with trailing flexible array. +* @p: Pointer to the structure. +* @member: Name of the array member. +* @count: Number of elements in the array. +* +* Calculates size of memory needed for structure of @p followed by an +* array of @count number of @member elements. +* +* Return: number of bytes needed or SIZE_MAX on overflow. +*/ +#define struct_size (p, member, count) \ + __builtin_choose_expr(__is_constexpr(count), \ + sizeof(*(p)) + flex_array_size(p, member, count), \ + size_add(sizeof(*(p)), flex_array_size(p, member, count))) + +/** +* struct_size_t() - Calculate size of structure with trailing flexible array +* @type: structure type name. * @member: Name of the array member. -* @n: Number of elements in the array. +* @count: Number of elements in the array. * -* Calculates size of memory needed for structure @p followed by an -* array of @n @member elements. +* Calculates size of memory needed for structure @type followed by an +* array of @count number of @member elements. Prefer using struct_size() +* when possible instead, to keep calculations associated with a specific +* instance variable of type @type. * * Return: number of bytes needed or SIZE_MAX on overflow. */ -#define struct_size (p, member, n) \ - __ab_c_size(n, \ - sizeof(*(p)->member) + __must_be_array((p)->member),\ - sizeof(*(p))) +#define struct_size_t (type, member, count) \ + struct_size((type *)NULL, member, count) + +/** +* _DEFINE_FLEX() - helper macro for DEFINE_FLEX() family. +* Enables caller macro to pass (different) initializer. +* +* @type: structure type name, including "struct" keyword. +* @name: Name for a variable to define. +* @member: Name of the array member. +* @count: Number of elements in the array; must be compile-time const. +* @initializer: initializer expression (could be empty for no init). +*/ +#define _DEFINE_FLEX (type, name, member, count, initializer) \ + _Static_assert(__builtin_constant_p(count), \ + "onstack flex array members require compile-time const count"); \ + union { \ + u8 bytes[struct_size_t(type, member, count)]; \ + type obj; \ + } name##_u initializer; \ + type *name = (type *)&name##_u + +/** +* DEFINE_FLEX() - Define an on-stack instance of structure with a trailing +* flexible array member. +* +* @type: structure type name, including "struct" keyword. +* @name: Name for a variable to define. +* @member: Name of the array member. +* @count: Number of elements in the array; must be compile-time const. +* +* Define a zeroed, on-stack, instance of @type structure with a trailing +* flexible array member. +* Use __struct_size(@name) to get compile-time size of it afterwards. +*/ +#define DEFINE_FLEX (type, name, member, count) \ + _DEFINE_FLEX(type, name, member, count, = {})#endif /* __LINUX_OVERFLOW_H */
tools/perf/check-headers.sh +1 -0
@@ -35,6 +35,7 @@ FILES=( "include/vdso/const.h" "include/linux/hash.h" "include/linux/list-sort.h" + "include/linux/overflow.h" "include/uapi/linux/hw_breakpoint.h" "arch/x86/include/asm/disabled-features.h" "arch/x86/include/asm/required-features.h"
Signature · 1 line
2.44.0.278.ge034bb2e1d-goog
Ian Rogers
reviewerPATCH 12/13 tools headers: Sync compiler.h headers
In reply to Ian Rogerscompiler.h - synced from include/linux/compiler.h, guards were
added to definitions to avoid redefinition of macros in libc. ftrace, CONFIG_OBJTOOL and kentry logic was removed as redundant.
compiler-gcc.h - synced from include/linux/compiler-gcc.h
compiler-clang.h - added from include/linux/compiler-gcc.h
compiler_attributes.h - added from
include/linux/compiler_attributes.h,
guards were added to definitions to avoid redefinition of macros in libc.
compiler_types.h - added from include/linux/compiler_types.h,
guards were added to definitions to avoid redefinition of macros in libc.
asm/rwonce.h - added as dependency of compiler.h but added from
asm-generic/rwonce.h.
asm-generic/bitops/non-atomic.h - add linux/types.h so that bool
is defined. This file is heavily forked from the kernel one and so synchronizing with the kernel version was infeasible.
rbtree.h - add linux/types.h so that bool is defined. This file
is heavily forked from the kernel one and so synchronizing with the kernel version was infeasible.
string.h - add compiler.h include as definitions from types.h
were removed to avoid compiler.h collisions. This file is heavily forked from the kernel one and so synchronizing with the kernel version was infeasible.
types.h - remove __must_check definition that conflicts with
compiler.h.
--- tools/include/asm-generic/bitops/non-atomic.h | 1 + tools/include/asm/rwonce.h | 63 +++ tools/include/linux/compiler-clang.h | 124 +++++ tools/include/linux/compiler-gcc.h | 145 +++++- tools/include/linux/compiler.h | 221 ++------- tools/include/linux/compiler_attributes.h | 449 ++++++++++++++++++ tools/include/linux/compiler_types.h | 171 ++++++- tools/include/linux/rbtree.h | 1 + tools/include/linux/string.h | 1 + tools/include/linux/types.h | 2 +- 10 files changed, 968 insertions(+), 210 deletions(-) create mode 100644 tools/include/asm/rwonce.h create mode 100644 tools/include/linux/compiler-clang.h create mode 100644 tools/include/linux/compiler_attributes.h
tools/include/asm-generic/bitops/non-atomic.h +1 -0
@@ -3,6 +3,7 @@#define _ASM_GENERIC_BITOPS_NON_ATOMIC_H_#include <linux/bits.h> +#include <linux/types.h> /* for bool */ /** * ___set_bit - Set a bit in memory
tools/include/asm/rwonce.h new file +63 -0
63 lines not on this page · raw message
tools/include/linux/compiler-clang.h new file +124 -0
124 lines not on this page · raw message
tools/include/linux/compiler-gcc.h +125 -20
167 lines not on this page · raw message
tools/include/linux/compiler.h +37 -184
252 lines not on this page · raw message
tools/include/linux/compiler_attributes.h new file +449 -0
449 lines not on this page · raw message
tools/include/linux/compiler_types.h +166 -5
205 lines not on this page · raw message
tools/include/linux/rbtree.h +1 -0
@@ -19,6 +19,7 @@#include <linux/kernel.h> #include <linux/stddef.h> +#include <linux/types.h> /* for bool */ struct rb_node {unsigned long __rb_parent_color;
tools/include/linux/string.h +1 -0
@@ -3,6 +3,7 @@#define _TOOLS_LINUX_STRING_H_#include <linux/types.h> /* for size_t */ +#include <linux/compiler.h> #include <string.h> void *memdup (const void *src,size_t len);
tools/include/linux/types.h +1 -1
@@ -55,7 +55,7 @@ typedef __s8 s8;#ifndef __user#define __user#endif -#define __must_check +#define __coldtypedef __u16 __bitwise __le16 ;
Signature · 1 line
2.44.0.278.ge034bb2e1d-goog
Re: [PATCH v1 12/13] tools headers: Sync compiler.h headers
Quoted 5 lines · Ian Rogers
compiler_attributes.h- added from
include/linux/compiler_attributes.h,
guards were added to definitions to avoid redefinition of macros in libc.
Do you have an example for context?
Thanks!
Cheers,
Miguel
kernel test robot
build botRe: [PATCH v1 12/13] tools headers: Sync compiler.h headers
In reply to Ian Rogerskernel test robot noticed the following build warnings:
Hi Ian,
kernel test robot noticed the following build warnings:
[auto build test WARNING on perf-tools-next/perf-tools-next] [also build test WARNING on perf-tools/perf-tools tip/perf/core] [cannot apply to linus/master acme/perf/core v6.8-rc7 next-20240308] [If your patch is applied to the wrong git tree, kindly drop us a note. And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch#_base_tree_information]
url: https://github.com/intel-lab-lkp/linux/commits/Ian-Rogers/tools-bpf-Synchronize-bpf-h-with-kernel-uapi-version/20240310-101251 base: https://git.kernel.org/pub/scm/linux/kernel/git/perf/perf-tools-next.git perf-tools-next patch link: https://lore.kernel.org/r/20240310020509.647319-13-irogers%40google.com patch subject: [PATCH v1 12/13] tools headers: Sync compiler.h headers config: x86_64-allnoconfig (https://download.01.org/0day-ci/archive/20240311/[email protected]/config) compiler: clang version 17.0.6 (https://github.com/llvm/llvm-project 6009708b4367171ccdbf4b5905cb6a803753fe18) reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20240311/[email protected]/reproduce)
If you fix the issue in a separate patch/commit (i.e. not just a new version of the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <[email protected]>
| Closes: https://lore.kernel.org/oe-kbuild-all/[email protected]/
All warnings (new ones prefixed by >>):
In file included from exec-cmd.c:2:
In file included from tools/include/linux/compiler.h:5:
In file included from tools/include/linux/compiler_types.h:78:
>> tools/include/linux/compiler-clang.h:117:5: warning: 'CONFIG_CLANG_VERSION' is not defined, evaluates to 0 [-Wundef] 117 | #if CONFIG_CLANG_VERSION >= 110000 | ^ In file included from parse-options.c:2: In file included from tools/include/linux/compiler.h:5: In file included from tools/include/linux/compiler_types.h:78: >> tools/include/linux/compiler-clang.h:117:5: warning: 'CONFIG_CLANG_VERSION' is not defined, evaluates to 0 [-Wundef] 117 | #if CONFIG_CLANG_VERSION >= 110000 | ^ In file included from run-command.c:7: In file included from tools/include/linux/string.h:6: In file included from tools/include/linux/compiler.h:5: In file included from tools/include/linux/compiler_types.h:78: >> tools/include/linux/compiler-clang.h:117:5: warning: 'CONFIG_CLANG_VERSION' is not defined, evaluates to 0 [-Wundef] 117 | #if CONFIG_CLANG_VERSION >= 110000 | ^ In file included from help.c:5: In file included from tools/include/linux/string.h:6: In file included from tools/include/linux/compiler.h:5: In file included from tools/include/linux/compiler_types.h:78: >> tools/include/linux/compiler-clang.h:117:5: warning: 'CONFIG_CLANG_VERSION' is not defined, evaluates to 0 [-Wundef] 117 | #if CONFIG_CLANG_VERSION >= 110000 | ^ In file included from sigchain.c:3: In file included from ./subcmd-util.h:8: In file included from tools/include/linux/compiler.h:5: In file included from tools/include/linux/compiler_types.h:78: >> tools/include/linux/compiler-clang.h:117:5: warning: 'CONFIG_CLANG_VERSION' is not defined, evaluates to 0 [-Wundef] 117 | #if CONFIG_CLANG_VERSION >= 110000 | ^ 1 warning generated. 1 warning generated. 1 warning generated. 1 warning generated. 1 warning generated. In file included from weak.c:10: In file included from tools/objtool/include/objtool/objtool.h:10: In file included from tools/include/linux/list.h:7: In file included from tools/include/linux/kernel.h:8: In file included from tools/include/linux/build_bug.h:5: In file included from tools/include/linux/compiler.h:5: In file included from tools/include/linux/compiler_types.h:78: >> tools/include/linux/compiler-clang.h:117:5: warning: 'CONFIG_CLANG_VERSION' is not defined, evaluates to 0 [-Wundef] 117 | #if CONFIG_CLANG_VERSION >= 110000 | ^ In file included from builtin-check.c:6: In file included from tools/objtool/libsubcmd/include/subcmd/parse-options.h:5: In file included from tools/include/linux/kernel.h:8: In file included from tools/include/linux/build_bug.h:5: In file included from tools/include/linux/compiler.h:5: In file included from tools/include/linux/compiler_types.h:78: >> tools/include/linux/compiler-clang.h:117:5: warning: 'CONFIG_CLANG_VERSION' is not defined, evaluates to 0 [-Wundef] 117 | #if CONFIG_CLANG_VERSION >= 110000 | ^ In file included from special.c:15: In file included from tools/objtool/include/objtool/builtin.h:8: In file included from tools/objtool/libsubcmd/include/subcmd/parse-options.h:5: In file included from tools/include/linux/kernel.h:8: In file included from tools/include/linux/build_bug.h:5: In file included from tools/include/linux/compiler.h:5: In file included from tools/include/linux/compiler_types.h:78: >> tools/include/linux/compiler-clang.h:117:5: warning: 'CONFIG_CLANG_VERSION' is not defined, evaluates to 0 [-Wundef] 117 | #if CONFIG_CLANG_VERSION >= 110000 | ^ In file included from arch/x86/special.c:4: In file included from tools/objtool/include/objtool/special.h:10: In file included from tools/objtool/include/objtool/check.h:10: In file included from tools/objtool/include/objtool/cfi.h:10: In file included from tools/include/linux/list.h:7: In file included from tools/include/linux/kernel.h:8: In file included from tools/include/linux/build_bug.h:5: In file included from tools/include/linux/compiler.h:5: In file included from tools/include/linux/compiler_types.h:78: >> tools/include/linux/compiler-clang.h:117:5: warning: 'CONFIG_CLANG_VERSION' is not defined, evaluates to 0 [-Wundef] 117 | #if CONFIG_CLANG_VERSION >= 110000 | ^ In file included from check.c:11: In file included from tools/objtool/include/objtool/builtin.h:8: In file included from tools/objtool/libsubcmd/include/subcmd/parse-options.h:5: In file included from tools/include/linux/kernel.h:8: In file included from tools/include/linux/build_bug.h:5: In file included from tools/include/linux/compiler.h:5: In file included from tools/include/linux/compiler_types.h:78: >> tools/include/linux/compiler-clang.h:117:5: warning: 'CONFIG_CLANG_VERSION' is not defined, evaluates to 0 [-Wundef] 117 | #if CONFIG_CLANG_VERSION >= 110000 | ^ In file included from orc_dump.c:7: In file included from tools/arch/x86/include/asm/orc_types.h:10: In file included from tools/include/linux/compiler.h:5: In file included from tools/include/linux/compiler_types.h:78: >> tools/include/linux/compiler-clang.h:117:5: warning: 'CONFIG_CLANG_VERSION' is not defined, evaluates to 0 [-Wundef] 117 | #if CONFIG_CLANG_VERSION >= 110000 | ^ In file included from ../lib/ctype.c:8: In file included from tools/include/linux/ctype.h:5: In file included from tools/include/linux/compiler.h:5: In file included from tools/include/linux/compiler_types.h:78: >> tools/include/linux/compiler-clang.h:117:5: warning: 'CONFIG_CLANG_VERSION' is not defined, evaluates to 0 [-Wundef] 117 | #if CONFIG_CLANG_VERSION >= 110000 | ^ In file included from objtool.c:13: In file included from tools/include/linux/kernel.h:8: In file included from tools/include/linux/build_bug.h:5: In file included from tools/include/linux/compiler.h:5: In file included from tools/include/linux/compiler_types.h:78: >> tools/include/linux/compiler-clang.h:117:5: warning: 'CONFIG_CLANG_VERSION' is not defined, evaluates to 0 [-Wundef] 117 | #if CONFIG_CLANG_VERSION >= 110000 | ^ In file included from orc_gen.c:10: In file included from tools/arch/x86/include/asm/orc_types.h:10: In file included from tools/include/linux/compiler.h:5: In file included from tools/include/linux/compiler_types.h:78: >> tools/include/linux/compiler-clang.h:117:5: warning: 'CONFIG_CLANG_VERSION' is not defined, evaluates to 0 [-Wundef] 117 | #if CONFIG_CLANG_VERSION >= 110000 | ^ In file included from special.c:16: In file included from tools/objtool/include/objtool/special.h:10: In file included from tools/objtool/include/objtool/check.h:11: In file included from tools/objtool/include/objtool/arch.h:11: >> tools/objtool/include/objtool/objtool.h:15:9: warning: '__weak' macro redefined [-Wmacro-redefined]In file included from elf.c:19: In file included from tools/include/linux/interval_tree_generic.h:10: In file included from tools/include/linux/rbtree_augmented.h:18: In file included from tools/include/linux/compiler.h:5: In file included from tools/include/linux/compiler_types.h:78: >> tools/include/linux/compiler-clang.h:117:5: warning: 'CONFIG_CLANG_VERSION' is not defined, evaluates to 0 [-Wundef]
117 | #if CONFIG_CLANG_VERSION >= 110000
| ^
--
15 | #define __weak __attribute__((weak))
| ^
tools/include/linux/compiler_attributes.h:437:10: note: previous definition is here
437 | # define __weak __attribute__In file included from ../lib/rbtree.c:12:
In file included from tools/include/linux/rbtree_augmented.h:18:
In file included from tools/include/linux/compiler.h:5:
In file included from tools/include/linux/compiler_types.h:78:
>> tools/include/linux/compiler-clang.h:117:5: warning: 'CONFIG_CLANG_VERSION' is not defined, evaluates to 0 [-Wundef] 117 | #if CONFIG_CLANG_VERSION >= 110000 | ^ ((__weak__)) | ^ 1 warning generated. In file included from weak.c:10: >> tools/objtool/include/objtool/objtool.h:15:9: warning: '__weak' macro redefined [-Wmacro-redefined] 15 | #define __weak __attribute__((weak)) | ^ tools/include/linux/compiler_attributes.h:437:10: note: previous definition is here 437 | # define __weak __attribute__((__weak__)) | ^ In file included from arch/x86/special.c:4: In file included from tools/objtool/include/objtool/special.h:10: In file included from tools/objtool/include/objtool/check.h:11: In file included from tools/objtool/include/objtool/arch.h:11: >> tools/objtool/include/objtool/objtool.h:15:9: warning: '__weak' macro redefined [-Wmacro-redefined] 15 | #define __weak __attribute__((weak)) | ^ tools/include/linux/compiler_attributes.h:437:10: note: previous definition is here 437 | # define __weak __attribute__((__weak__)) | ^ In file included from 2 warnings generated. ../lib/string.c:19: In file included from tools/include/linux/string.h:6: In file included from tools/include/linux/compiler.h:5: In file included from tools/include/linux/compiler_types.h:78: >> tools/include/linux/compiler-clang.h:117:5: warning: 'CONFIG_CLANG_VERSION' is not defined, evaluates to 0 [-Wundef] 117 | #if CONFIG_CLANG_VERSION >= 110000 | ^ In file included from orc_gen.c:12: In file included from tools/objtool/include/objtool/check.h:11: In file included from tools/objtool/include/objtool/arch.h:11: >> tools/objtool/include/objtool/objtool.h:15:9: warning: '__weak' macro redefined [-Wmacro-redefined] 15 | #define __weak __attribute__((weak)) | ^ tools/include/linux/compiler_attributes.h:437:10: note: previous definition is here 437 | # define __weak __attribute__((__weak__)) | ^ In file included from objtool.c:16: >> tools/objtool/include/objtool/objtool.h:15:9: warning: '__weak' macro redefined [-Wmacro-redefined] 15 | #define __weak __attribute__((weak)) | ^ tools/include/linux/compiler_attributes.h:437:10: note: previous definition is here 437 | # define __weak __attribute__((__weak__)) | ^ In file included from builtin-check.c:10: >> tools/objtool/include/objtool/objtool.h:15:9: warning: '__weak' macro redefined [-Wmacro-redefined] 15 | #define __weak __attribute__((weak)) | ^ tools/include/linux/compiler_attributes.h:437:10: note: previous definition is here 437 | # define __weak __attribute__((__weak__)) | ^ In file included from check.c:13: In file included from tools/objtool/include/objtool/arch.h:11: >> tools/objtool/include/objtool/objtool.h:15:9: warning: '__weak' macro redefined [-Wmacro-redefined] 15 | #define __weak __attribute__((weak)) | ^ tools/include/linux/compiler_attributes.h:437:10: note: previous definition is here 437 | # define __weak __attribute__((__weak__)) | ^ 2 warnings generated. In file included from orc_dump.c:8: >> tools/objtool/include/objtool/objtool.h:15:9: warning: '__weak' macro redefined [-Wmacro-redefined] 15 | #define __weak __attribute__((weak)) | ^ tools/include/linux/compiler_attributes.h:437:10: note: previous definition is here 437 | # define __weak __attribute__((__weak__)) | ^ 2 warnings generated. 2 warnings generated. In file included from arch/x86/decode.c:12: In file included from arch/x86/../../../arch/x86/lib/insn.c:8: In file included from tools/include/linux/kernel.h:8: In file included from tools/include/linux/build_bug.h:5: In file included from tools/include/linux/compiler.h:5: In file included from tools/include/linux/compiler_types.h:78: >> tools/include/linux/compiler-clang.h:117:5: warning: 'CONFIG_CLANG_VERSION' is not defined, evaluates to 0 [-Wundef] 117 | #if CONFIG_CLANG_VERSION >= 110000 | ^ 2 warnings generated. 2 warnings generated. In file included from ../lib/str_error_r.c:5: In file included from tools/include/linux/string.h:6: In file included from tools/include/linux/compiler.h:5: In file included from tools/include/linux/compiler_types.h:78: >> tools/include/linux/compiler-clang.h:117:5: warning: 'CONFIG_CLANG_VERSION' is not defined, evaluates to 0 [-Wundef] 117 | #if CONFIG_CLANG_VERSION >= 110000 | ^ 1 warning generated. 1 warning generated. In file included from arch/x86/decode.c:18: In file included from tools/objtool/include/objtool/check.h:11: In file included from tools/objtool/include/objtool/arch.h:11: >> tools/objtool/include/objtool/objtool.h:15:9: warning: '__weak' macro redefined [-Wmacro-redefined]
15 | #define __weak __attribute__((weak))
| ^
tools/include/linux/compiler_attributes.h:437:10: note: previous definition is here
437 | # define __weak __attribute__((__weak__))
| ^
2 warnings generated.
1 warning generated.
2 warnings generated.
1 warning generated.
2 warnings generated.
--
In file included from exec-cmd.c:2:
In file included from tools/include/linux/compiler.h:5:
In file included from tools/include/linux/compiler_types.h:78:
>> tools/include/linux/compiler-clang.h:117:5: warning: 'CONFIG_CLANG_VERSION' is not defined, evaluates to 0 [-Wundef]
117 | #if CONFIG_CLANG_VERSION >= 110000
| ^
In file included from parse-options.c:2:
In file included from tools/include/linux/compiler.h:5:
In file included from tools/include/linux/compiler_types.h:78:
>> tools/include/linux/compiler-clang.h:117:5: warning: 'CONFIG_CLANG_VERSION' is not defined, evaluates to 0 [-Wundef]
117 | #if CONFIG_CLANG_VERSION >= 110000
| ^
In file included from help.c:5:
In file included from tools/include/linux/string.h:6:
In file included from tools/include/linux/compiler.h:5:
In file included from tools/include/linux/compiler_types.h:78:
>> tools/include/linux/compiler-clang.h:117:5: warning: 'CONFIG_CLANG_VERSION' is not defined, evaluates to 0 [-Wundef]
117 | #if CONFIG_CLANG_VERSION >= 110000
| ^
In file included from sigchain.c:3:
In file included from ./subcmd-util.h:8:
In file included from tools/include/linux/compiler.h:5:
In file included from tools/include/linux/compiler_types.h:78:
>> tools/include/linux/compiler-clang.h:117:5: warning: 'CONFIG_CLANG_VERSION' is not defined, evaluates to 0 [-Wundef]
117 | #if CONFIG_CLANG_VERSION >= 110000
| ^
In file included from run-command.c:7:
In file included from tools/include/linux/string.h:6:
In file included from tools/include/linux/compiler.h:5:
In file included from tools/include/linux/compiler_types.h:78:
>> tools/include/linux/compiler-clang.h:117:5: warning: 'CONFIG_CLANG_VERSION' is not defined, evaluates to 0 [-Wundef]
117 | #if CONFIG_CLANG_VERSION >= 110000
| ^
1 warning generated.
1 warning generated.
1 warning generated.
1 warning generated.
1 warning generated.
In file included from weak.c:10:
In file included from tools/objtool/include/objtool/objtool.h:10:
In file included from tools/include/linux/list.h:7:
In file included from tools/include/linux/kernel.h:8:
In file included from tools/include/linux/build_bug.h:5:
In file included from tools/include/linux/compiler.h:5:
In file included from tools/include/linux/compiler_types.h:78:
>> tools/include/linux/compiler-clang.h:117:5: warning: 'CONFIG_CLANG_VERSION' is not defined, evaluates to 0 [-Wundef]
117 | #if CONFIG_CLANG_VERSION >= 110000
| ^
In file included from builtin-check.c:6:
In file included from tools/objtool/libsubcmd/include/subcmd/parse-options.h:5:
In file included from tools/include/linux/kernel.h:8:
In file included from tools/include/linux/build_bug.h:5:
In file included from tools/include/linux/compiler.h:5:
In file included from tools/include/linux/compiler_types.h:78:
>> tools/include/linux/compiler-clang.h:117:5: warning: 'CONFIG_CLANG_VERSION' is not defined, evaluates to 0 [-Wundef]
117 | #if CONFIG_CLANG_VERSION >= 110000
| ^
In file included from elf.c:19:
In file included from tools/include/linux/interval_tree_generic.h:10:
In file included from tools/include/linux/rbtree_augmented.h:18:
In file included from tools/include/linux/compiler.h:5:
In file included from tools/include/linux/compiler_types.h:78:
>> tools/include/linux/compiler-clang.h:117:5: warning: 'CONFIG_CLANG_VERSION' is not defined, evaluates to 0 [-Wundef]
117 | #if CONFIG_CLANG_VERSION >= 110000
| ^
In file included from orc_gen.c:10:
In file included from tools/arch/x86/include/asm/orc_types.h:10:
In file included from tools/include/linux/compiler.h:5:
In file included from tools/include/linux/compiler_types.h:78:
>> tools/include/linux/compiler-clang.h:117:5: warning: 'CONFIG_CLANG_VERSION' is not defined, evaluates to 0 [-Wundef]
117 | #if CONFIG_CLANG_VERSION >= 110000
| ^
In file included from arch/x86/special.c:4:
In file included from tools/objtool/include/objtool/special.h:10:
In file included from tools/objtool/include/objtool/check.h:10:
In file included from tools/objtool/include/objtool/cfi.h:10:
In file included from tools/include/linux/list.h:7:
In file included from tools/include/linux/kernel.h:8:
In file included from tools/include/linux/build_bug.h:5:
In file included from tools/include/linux/compiler.h:5:
In file included from tools/include/linux/compiler_types.h:78:
>> tools/include/linux/compiler-clang.h:117:5: warning: 'CONFIG_CLANG_VERSION' is not defined, evaluates to 0 [-Wundef]
117 | #if CONFIG_CLANG_VERSION >= 110000
| ^
In file included from ../lib/string.c:19:
In file included from tools/include/linux/string.h:6:
In file included from tools/include/linux/compiler.h:5:
In file included from tools/include/linux/compiler_types.h:78:
>> tools/include/linux/compiler-clang.h:117:5: warning: 'CONFIG_CLANG_VERSION' is not defined, evaluates to 0 [-Wundef]
117 | #if CONFIG_CLANG_VERSION >= 110000
| ^
In file included from special.c:15:
In file included from tools/objtool/include/objtool/builtin.h:8:
In file included from tools/objtool/libsubcmd/include/subcmd/parse-options.h:5:
In file included from tools/include/linux/kernel.h:8:
In file included from tools/include/linux/build_bug.h:5:
In file included from tools/include/linux/compiler.h:5:
In file included from tools/include/linux/compiler_types.h:78:
>> tools/include/linux/compiler-clang.h:117:5: warning: 'CONFIG_CLANG_VERSION' is not defined, evaluates to 0 [-Wundef]
In file included from orc_dump.c:7:
In file included from tools/arch/x86/include/asm/orc_types.h:10:
In file included from tools/include/linux/compiler.h:5:
In file included from tools/include/linux/compiler_types.h:78:
>> tools/include/linux/compiler-clang.h:117:5: warning: 'CONFIG_CLANG_VERSION' is not defined, evaluates to 0 [-Wundef]
117 | #if CONFIG_CLANG_VERSION >= 110000
| ^
In file included from weak.c:10:
>> tools/objtool/include/objtool/objtool.h:15:9: warning: '__weak' macro redefined [-Wmacro-redefined]
15 | #define __weak __aIn file included from ttribute__((weak))
| ^
tools/include/linux/compiler_attributes.h:437:10: note: previous definition is here
437 | # define __weak __attribute__((__weak__))
| ^
117 | #if CONFIG_CLANG_VERSION >= 110000
| ^
../lib/ctype.c:8:
In file included from tools/include/linux/ctype.h:5:
In file included from tools/include/linux/compiler.h:5:
In file included from tools/include/linux/compiler_types.h:78:
>> tools/include/linux/compiler-clang.h:117:5: warning: 'CONFIG_CLANG_VERSION' is not defined, evaluates to 0 [-Wundef]
117 | #if CONFIG_CLANG_VERSION >= 110000
| ^
In file included from objtool.c:13:
In file included from tools/include/linux/kernel.h:8:
In file included from tools/include/linux/build_bug.h:5:
In file included from tools/include/linux/compiler.h:5:
In file included from tools/include/linux/compiler_types.h:78:
>> tools/include/linux/compiler-clang.h:117:5: warning: 'CONFIG_CLANG_VERSION' is not defined, evaluates to 0 [-Wundef]
117 | #if CONFIG_CLANG_VERSION >= 110000
| ^
In file included from check.c:11:
In file included from tools/objtool/include/objtool/builtin.h:8:
In file included from tools/objtool/libsubcmd/include/subcmd/parse-options.h:5:
In file included from tools/include/linux/kernel.h:8:
In file included from tools/include/linux/build_bug.h:5:
In file included from tools/include/linux/compiler.h:5:
In file included from tools/include/linux/compiler_types.h:78:
>> tools/include/linux/compiler-clang.h:117:5: warning: 'CONFIG_CLANG_VERSION' is not defined, evaluates to 0 [-Wundef]
117 | #if CONFIG_CLANG_VERSION >= 110000
| ^
In file included from ../lib/rbtree.c:12:
In file included from tools/include/linux/rbtree_augmented.h:18:
In file included from tools/include/linux/compiler.h:5:
In file included from tools/include/linux/compiler_types.h:78:
>> tools/include/linux/compiler-clang.h:117:5: warning: 'CONFIG_CLANG_VERSION' is not defined, evaluates to 0 [-Wundef]
117 | #if CONFIG_CLANG_VERSION >= 110000
| ^
1 warning generated.
2 warnings generated.
In file included from orc_gen.c:12:
In file included from tools/objtool/include/objtool/check.h:11:
In file included from tools/objtool/include/objtool/arch.h:11:
>> tools/objtool/include/objtool/objtool.h:15:9: warning: '__weak' macro redefined [-Wmacro-redefined]
15 | #define __weak __attribute__((weak))
| ^
tools/include/linux/compiler_attributes.h:437:10: note: previous definition is here
437 | # define __weak __attribute__((__weak__))
| ^
In file included from arch/x86/decode.c:12:
In file included from arch/x86/../../../arch/x86/lib/insn.c:8:
In file included from tools/include/linux/kernel.h:8:
In file included from tools/include/linux/build_bug.h:5:
In file included from tools/include/linux/compiler.h:5:
In file included from tools/include/linux/compiler_types.h:78:
>> tools/include/linux/compiler-clang.h:117:5: warning: 'CONFIG_CLANG_VERSION' is not defined, evaluates to 0 [-Wundef]
117 | #if CONFIG_CLANG_VERSION >= 110000
| ^
In file included from builtin-check.c:10:
tools/objtool/include/objtool/objtool.h:15:9: warning: '__weak' macro redefined [-Wmacro-redefined]
15 | #define __weak __attribute__((weak))
| ^
tools/include/linux/compiler_attributes.h:437:10: note: previous definition is here
437 | # define __weak __attribute__((__weak__))
| ^
In file included from arch/x86/special.c:4:
In file included from tools/objtool/include/objtool/special.h:10:
In file included from tools/objtool/include/objtool/check.h:11:
In file included from tools/objtool/include/objtool/arch.h:11:
tools/objtool/include/objtool/objtool.h:15:9: warning: '__weak' macro redefined [-Wmacro-redefined]
15 | #define __weak __attribute__((weak))
| ^
tools/include/linux/compiler_attributes.h:437:10: note: previous definition is here
437 | # define __weak __attribute__((__weak__))
| ^
1 warning generated.
In file included from orc_dump.c:8:
tools/objtool/include/objtool/objtool.h:15:9: warning: '__weak' macro redefined [-Wmacro-redefined]
15 | #define __weak __attribute__((weak))
| ^
tools/include/linux/compiler_attributes.h:437:10: note: previous definition is here
437 | # define __weak __attribute__((__weak__))
| ^
2 warnings generated.
In file included from In file included from check.c:13:
In file included from tools/objtool/include/objtool/arch.h:11:
tools/objtool/include/objtool/objtool.h:15:9: warning: '__weak' macro redefined [-Wmacro-redefined]
15 | #define __weak __attribute__((weak))
| ^
tools/include/linux/compiler_attributes.h:437:10: note: previous definition is here
437 | # define __weak __attribute__((__weak__))
| ^
In file included from arch/x86/decode.c:18:
In file included from tools/objtool/include/objtool/check.h:11:
In file included from tools/objtool/include/objtool/arch.h:11:
tools/objtool/include/objtool/objtool.h:15:9: warning: '__weak' macro redefined [-Wmacro-redefined]
15 | #define __weak __attributespecial.c__((weak))
| ^
tools/include/linux/compiler_attributes.h:437:10: note: previous definition is here
437 | # define __weak __attribute__((__weak__))
| ^
:16:
In file included from tools/objtool/include/objtool/special.h:10:
In file included from tools/objtool/include/objtool/check.h:11:
In file included from tools/objtool/include/objtool/arch.h:11:
tools/objtool/include/objtool/objtool.h:15:9: warning: '__weak' macro redefined [-Wmacro-redefined]
15 | #define __weak __attribute__((weak))
| ^
tools/include/linux/compiler_attributes.h:437:10: note: previous definition is here
437 | # define __weak __attribute__((__weak__))
| ^
In file included from objtool.c:16:
tools/objtool/include/objtool/objtool.h:15:9: warning: '__weak' macro redefined [-Wmacro-redefined]
15 | #define __weak __attribute__((weak))
| ^
tools/include/linux/compiler_attributes.h:437:10: note: previous definition is here
437 | # define __weak __attribute__((__weak__))
| ^
2 warnings generated.
2 warnings generated.
In file included from ../lib/str_error_r.c:5:
In file included from tools/include/linux/string.h:6:
In file included from tools/include/linux/compiler.h:5:
In file included from tools/include/linux/compiler_types.h:78:
tools/include/linux/compiler-clang.h:117:5: warning: 'CONFIG_CLANG_VERSION' is not defined, evaluates to 0 [-Wundef]
117 | #if CONFIG_CLANG_VERSION >= 110000
| ^ 2 warnings generated.
1 warning generated.
2 warnings generated.
2 warnings generated.
1 warning generated.
2 warnings generated.
1 warning generated.
2 warnings generated.
vim +/CONFIG_CLANG_VERSION +117 tools/include/linux/compiler-clang.h
116
> 117 #if CONFIG_CLANG_VERSION >= 110000
118 #define __diag_clang_11(s) __diag(s)
119 #else
120 #define __diag_clang_11(s)
121 #endif
122
Signature · 2 lines
0-DAY CI Kernel Test Service https://github.com/intel/lkp-tests/wiki
kernel test robot
build botRe: [PATCH v1 12/13] tools headers: Sync compiler.h headers
In reply to Ian Rogerskernel test robot noticed the following build warnings:
Hi Ian,
kernel test robot noticed the following build warnings:
[auto build test WARNING on perf-tools-next/perf-tools-next] [also build test WARNING on perf-tools/perf-tools tip/perf/core] [cannot apply to linus/master acme/perf/core v6.8 next-20240308] [If your patch is applied to the wrong git tree, kindly drop us a note. And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch#_base_tree_information]
url: https://github.com/intel-lab-lkp/linux/commits/Ian-Rogers/tools-bpf-Synchronize-bpf-h-with-kernel-uapi-version/20240310-101251 base: https://git.kernel.org/pub/scm/linux/kernel/git/perf/perf-tools-next.git perf-tools-next patch link: https://lore.kernel.org/r/20240310020509.647319-13-irogers%40google.com patch subject: [PATCH v1 12/13] tools headers: Sync compiler.h headers config: x86_64-defconfig (https://download.01.org/0day-ci/archive/20240311/[email protected]/config) compiler: gcc-11 (Debian 11.3.0-12) 11.3.0 reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20240311/[email protected]/reproduce)
If you fix the issue in a separate patch/commit (i.e. not just a new version of the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <[email protected]>
| Closes: https://lore.kernel.org/oe-kbuild-all/[email protected]/
All warnings (new ones prefixed by >>):
In file included from tools/objtool/include/objtool/arch.h:11,
from tools/objtool/include/objtool/check.h:11,
from tools/objtool/include/objtool/special.h:10,
from special.c:16:
>> tools/objtool/include/objtool/objtool.h:15: warning: "__weak" redefined
15 | #define __weak __attribute__((weak))
|
In file included from tools/include/linux/compiler_types.h:74,
from tools/include/linux/compiler.h:5,
from tools/include/linux/build_bug.h:5,
from tools/include/linux/kernel.h:8,
from tools/objtool/libsubcmd/include/subcmd/parse-options.h:5,
from tools/objtool/include/objtool/builtin.h:8,
from special.c:15:
tools/include/linux/compiler_attributes.h:437: note: this is the location of the previous definition
437 | # define __weak __attribute__((__weak__))
|
In file included from weak.c:10:
>> tools/objtool/include/objtool/objtool.h:15: warning: "__weak" redefined
15 | #define __weak __attribute__((weak))
|
In file included from tools/include/linux/compiler_types.h:74,
from tools/include/linux/compiler.h:5,
from tools/include/linux/build_bug.h:5,
from tools/include/linux/kernel.h:8,
from tools/include/linux/list.h:7,
from tools/objtool/include/objtool/objtool.h:10,
from weak.c:10:
tools/include/linux/compiler_attributes.h:437: note: this is the location of the previous definition
437 | # define __weak __attribute__((__weak__))
|
In file included from tools/objtool/include/objtool/arch.h:11,
from tools/objtool/include/objtool/check.h:11,
from tools/objtool/include/objtool/special.h:10,
from arch/x86/special.c:4:
>> tools/objtool/include/objtool/objtool.h:15: warning: "__weak" redefined
15 | #define __weak __attribute__((weak))
|
In file included from tools/include/linux/compiler_types.h:74,
from tools/include/linux/compiler.h:5,
from tools/include/linux/build_bug.h:5,
from tools/include/linux/kernel.h:8,
from tools/include/linux/list.h:7,
from tools/objtool/include/objtool/cfi.h:10,
from tools/objtool/include/objtool/check.h:10,
from tools/objtool/include/objtool/special.h:10,
from arch/x86/special.c:4:
tools/include/linux/compiler_attributes.h:437: note: this is the location of the previous definition
437 | # define __weak __attribute__((__weak__))
|
In file included from tools/objtool/include/objtool/arch.h:11,
from check.c:13:
>> tools/objtool/include/objtool/objtool.h:15: warning: "__weak" redefined
15 | #define __weak __attribute__((weak))
|
In file included from tools/include/linux/compiler_types.h:74,
from tools/include/linux/compiler.h:5,
from tools/include/linux/build_bug.h:5,
from tools/include/linux/kernel.h:8,
from tools/objtool/libsubcmd/include/subcmd/parse-options.h:5,
from tools/objtool/include/objtool/builtin.h:8,
from check.c:11:
tools/include/linux/compiler_attributes.h:437: note: this is the location of the previous definition
437 | # define __weak __attribute__((__weak__))
|
In file included from builtin-check.c:10:
>> tools/objtool/include/objtool/objtool.h:15: warning: "__weak" redefined
15 | #define __weak __attribute__((weak))
|
In file included from tools/include/linux/compiler_types.h:74,
from tools/include/linux/compiler.h:5,
from tools/include/linux/build_bug.h:5,
from tools/include/linux/kernel.h:8,
from tools/objtool/libsubcmd/include/subcmd/parse-options.h:5,
from builtin-check.c:6:
tools/include/linux/compiler_attributes.h:437: note: this is the location of the previous definition
437 | # define __weak __attribute__((__weak__))
|
In file included from tools/objtool/include/objtool/arch.h:11,
from tools/objtool/include/objtool/check.h:11,
from orc_gen.c:12:
>> tools/objtool/include/objtool/objtool.h:15: warning: "__weak" redefined
15 | #define __weak __attribute__((weak))
|
In file included from tools/include/linux/compiler_types.h:74,
from tools/include/linux/compiler.h:5,
from tools/arch/x86/include/asm/orc_types.h:10,
from orc_gen.c:10:
tools/include/linux/compiler_attributes.h:437: note: this is the location of the previous definition
437 | # define __weak __attribute__((__weak__))
|
In file included from orc_dump.c:8:
>> tools/objtool/include/objtool/objtool.h:15: warning: "__weak" redefined
15 | #define __weak __attribute__((weak))
|
In file included from tools/include/linux/compiler_types.h:74,
from tools/include/linux/compiler.h:5,
from tools/arch/x86/include/asm/orc_types.h:10,
from orc_dump.c:7:
tools/include/linux/compiler_attributes.h:437: note: this is the location of the previous definition
437 | # define __weak __attribute__((__weak__))
|
In file included from objtool.c:16:
>> tools/objtool/include/objtool/objtool.h:15: warning: "__weak" redefined
15 | #define __weak __attribute__((weak))
|
In file included from tools/include/linux/compiler_types.h:74,
from tools/include/linux/compiler.h:5,
from tools/include/linux/build_bug.h:5,
from tools/include/linux/kernel.h:8,
from objtool.c:13:
tools/include/linux/compiler_attributes.h:437: note: this is the location of the previous definition
437 | # define __weak __attribute__((__weak__))
|
In file included from tools/objtool/include/objtool/arch.h:11,
from tools/objtool/include/objtool/check.h:11,
from arch/x86/decode.c:18:
>> tools/objtool/include/objtool/objtool.h:15: warning: "__weak" redefined
15 | #define __weak __attribute__((weak))
|
In file included from tools/include/linux/compiler_types.h:74,
from tools/include/linux/compiler.h:5,
from tools/include/linux/build_bug.h:5,
from tools/include/linux/kernel.h:8,
from arch/x86/../../../arch/x86/lib/insn.c:8,
from arch/x86/decode.c:12:
tools/include/linux/compiler_attributes.h:437: note: this is the location of the previous definition
437 | # define __weak __attribute__((__weak__))
|
--
In file included from weak.c:10:
>> tools/objtool/include/objtool/objtool.h:15: warning: "__weak" redefined
15 | #define __weak __attribute__((weak))
|
In file included from tools/include/linux/compiler_types.h:74,
from tools/include/linux/compiler.h:5,
from tools/include/linux/build_bug.h:5,
from tools/include/linux/kernel.h:8,
from tools/include/linux/list.h:7,
from tools/objtool/include/objtool/objtool.h:10,
from weak.c:10:
tools/include/linux/compiler_attributes.h:437: note: this is the location of the previous definition
437 | # define __weak __attribute__((__weak__))
|
In file included from tools/objtool/include/objtool/arch.h:11,
from tools/objtool/include/objtool/check.h:11,
from tools/objtool/include/objtool/special.h:10,
from special.c:16:
>> tools/objtool/include/objtool/objtool.h:15: warning: "__weak" redefined
15 | #define __weak __attribute__((weak))
|
In file included from tools/include/linux/compiler_types.h:74,
from tools/include/linux/compiler.h:5,
from tools/include/linux/build_bug.h:5,
from tools/include/linux/kernel.h:8,
from tools/objtool/libsubcmd/include/subcmd/parse-options.h:5,
from tools/objtool/include/objtool/builtin.h:8,
from special.c:15:
tools/include/linux/compiler_attributes.h:437: note: this is the location of the previous definition
437 | # define __weak __attribute__((__weak__))
|
In file included from tools/objtool/include/objtool/arch.h:11,
from check.c:13:
>> tools/objtool/include/objtool/objtool.h:15: warning: "__weak" redefined
15 | #define __weak __attribute__((weak))
|
In file included from tools/include/linux/compiler_types.h:74,
from tools/include/linux/compiler.h:5,
from tools/include/linux/build_bug.h:5,
from tools/include/linux/kernel.h:8,
from tools/objtool/libsubcmd/include/subcmd/parse-options.h:5,
from tools/objtool/include/objtool/builtin.h:8,
from check.c:11:
tools/include/linux/compiler_attributes.h:437: note: this is the location of the previous definition
437 | # define __weak __attribute__((__weak__))
|
In file included from builtin-check.c:10:
>> tools/objtool/include/objtool/objtool.h:15: warning: "__weak" redefined
15 | #define __weak __attribute__((weak))
|
In file included from tools/include/linux/compiler_types.h:74,
from tools/include/linux/compiler.h:5,
from tools/include/linux/build_bug.h:5,
from tools/include/linux/kernel.h:8,
from tools/objtool/libsubcmd/include/subcmd/parse-options.h:5,
from builtin-check.c:6:
tools/include/linux/compiler_attributes.h:437: note: this is the location of the previous definition
437 | # define __weak __attribute__((__weak__))
|
In file included from tools/objtool/include/objtool/arch.h:11,
from tools/objtool/include/objtool/check.h:11,
from tools/objtool/include/objtool/special.h:10,
from arch/x86/special.c:4:
>> tools/objtool/include/objtool/objtool.h:15: warning: "__weak" redefined
15 | #define __weak __attribute__((weak))
|
In file included from tools/include/linux/compiler_types.h:74,
from tools/include/linux/compiler.h:5,
from tools/include/linux/build_bug.h:5,
from tools/include/linux/kernel.h:8,
from tools/include/linux/list.h:7,
from tools/objtool/include/objtool/cfi.h:10,
from tools/objtool/include/objtool/check.h:10,
from tools/objtool/include/objtool/special.h:10,
from arch/x86/special.c:4:
tools/include/linux/compiler_attributes.h:437: note: this is the location of the previous definition
437 | # define __weak __attribute__((__weak__))
|
In file included from objtool.c:16:
>> tools/objtool/include/objtool/objtool.h:15: warning: "__weak" redefined
15 | #define __weak __attribute__((weak))
|
In file included from tools/include/linux/compiler_types.h:74,
from tools/include/linux/compiler.h:5,
from tools/include/linux/build_bug.h:5,
from tools/include/linux/kernel.h:8,
from objtool.c:13:
tools/include/linux/compiler_attributes.h:437: note: this is the location of the previous definition
437 | # define __weak __attribute__((__weak__))
|
In file included from orc_dump.c:8:
>> tools/objtool/include/objtool/objtool.h:15: warning: "__weak" redefined
15 | #define __weak __attribute__((weak))
|
In file included from tools/include/linux/compiler_types.h:74,
from tools/include/linux/compiler.h:5,
from tools/arch/x86/include/asm/orc_types.h:10,
from orc_dump.c:7:
tools/include/linux/compiler_attributes.h:437: note: this is the location of the previous definition
437 | # define __weak __attribute__((__weak__))
|
In file included from tools/objtool/include/objtool/arch.h:11,
from tools/objtool/include/objtool/check.h:11,
from orc_gen.c:12:
>> tools/objtool/include/objtool/objtool.h:15: warning: "__weak" redefined
15 | #define __weak __attribute__((weak))
|
In file included from tools/include/linux/compiler_types.h:74,
from tools/include/linux/compiler.h:5,
from tools/arch/x86/include/asm/orc_types.h:10,
from orc_gen.c:10:
tools/include/linux/compiler_attributes.h:437: note: this is the location of the previous definition
437 | # define __weak __attribute__((__weak__))
|
In file included from tools/objtool/include/objtool/arch.h:11,
from tools/objtool/include/objtool/check.h:11,
from arch/x86/decode.c:18:
>> tools/objtool/include/objtool/objtool.h:15: warning: "__weak" redefined
15 | #define __weak __attribute__((weak))
|
In file included from tools/include/linux/compiler_types.h:74,
from tools/include/linux/compiler.h:5,
from tools/include/linux/build_bug.h:5,
from tools/include/linux/kernel.h:8,
from arch/x86/../../../arch/x86/lib/insn.c:8,
from arch/x86/decode.c:12:
tools/include/linux/compiler_attributes.h:437: note: this is the location of the previous definition
437 | # define __weak __attribute__((__weak__))
| vim +/__weak +15 tools/objtool/include/objtool/objtool.h
d37c90d47fc465 tools/objtool/objtool.h Matt Helsley 2020-05-19 14eda3dc905834dc tools/objtool/objtool.h Julien Thierry 2020-09-04 @15 #define __weak __attribute__((weak)) eda3dc905834dc tools/objtool/objtool.h Julien Thierry 2020-09-04 16
Signature · 2 lines
0-DAY CI Kernel Test Service https://github.com/intel/lkp-tests/wiki
Re: [PATCH v1 12/13] tools headers: Sync compiler.h headers
In reply to Ian RogersQuoted 5 lines · Ian Rogers
compiler.h- synced frominclude/linux/compiler.h, guards were
added to definitions to avoid redefinition of macros in libc. ftrace,CONFIG_OBJTOOLand kentry logic was removed as redundant.
Hi Ian,
This commit breaks the Arm build (and cross compilation for Arm on x86):
$ make ARCH=arm64 CROSS_COMPILE=aarch64-linux-gnu-
Something like this, but I won't paste the whole output because it's huge:
tools/include/linux/ring_buffer.h: In function ‘ring_buffer_read_head’:
tools/include/asm/../../arch/arm64/include/asm/barrier.h:72:35: error:
‘__u8_alias_t’ undeclared (first use in this function)
72 | : "=r" (*(__u8_alias_t *)__u.__c)
\
| ^~~~~~~~~~~~
tools/include/linux/ring_buffer.h:59:16: note: in expansion of macro
‘smp_load_acquire’
59 | return smp_load_acquire(&base->data_head);
| ^~~~~~~~~~~~~~~~Thanks
James
Ian Rogers
reviewerRe: [PATCH v1 12/13] tools headers: Sync compiler.h headers
Quoted 23 lines · James Clark
Quoted 5 lines · Ian Rogers
compiler.h- synced frominclude/linux/compiler.h, guards were
added to definitions to avoid redefinition of macros in libc. ftrace,CONFIG_OBJTOOLand kentry logic was removed as redundant.Hi Ian,
This commit breaks the Arm build (and cross compilation for Arm on x86):
$ make ARCH=arm64 CROSS_COMPILE=aarch64-linux-gnu-Something like this, but I won't paste the whole output because it's huge:
tools/include/linux/ring_buffer.h: In function ‘ring_buffer_read_head’:
tools/include/asm/../../arch/arm64/include/asm/barrier.h:72:35: error:
‘__u8_alias_t’ undeclared (first use in this function)
72 | : "=r" (*(__u8_alias_t *)__u.__c)
Quoted 6 lines
\
| ^~~~~~~~~~~~
tools/include/linux/ring_buffer.h:59:16: note: in expansion of macro
‘smp_load_acquire’
59 | return smp_load_acquire(&base->data_head);
| ^~~~~~~~~~~~~~~~Sorry for this James, I was rushing. I'll address the issues in v2 but the one you highlight above doesn't look like a fun/simple issue to resolve :-( Tbh, I'm not sure how much value tools/include has in its current set up. It is weird the include order in perf prefers tools/include/linux over tools/include/uapi. Current tools/include seems to be trying to do a few different things:
1) provide headers like list.h so programs in tools can have linux style lists, etc.
2) stuff that (1) drags in .. do we really want the asm barrier code from arm? A sane user space program would be better using stdatomic.h, plus that'd give the user space program an ability to get compiled on to weirder targets like wasm. Plus we end up with weird type conflicts like bool coming from linux/types.h rather than stdbool.h.
3) copies of kernel uapi headers that may be more up-to-date that those in your system, thereby exposing constants that things like libbpf depend upon.
4) headers with the same name as and that resemble kernel headers but are really a reimplementation, like tools/include/linux/string.h
5) headers we have just so we can use shell scripts to scrape constants for beautifying things in perf trace
For (1) and (2) it seems a separate library would be cleaner than having the code in tools/include.
(3) feels like a legit use-case, so we should hold onto tools/include/uapi, but do we want the asm directories?
(4) sounds like it should be in a library, perhaps with (1) and (2).
(5) feels like the headers should be alongside the shell scripts to avoid polluting tools/include.
Not that I propose fixing any of this here.
Thanks,
Ian
Quoted 2 lines
Thanks
James
Arnaldo Carvalho de Melo
maintainerRe: [PATCH v1 12/13] tools headers: Sync compiler.h headers
Quoted 6 lines · Ian Rogers
5) headers we have just so we can use shell scripts to scrape constants for beautifying things in perf trace
(5) feels like the headers should be alongside the shell scripts to avoid polluting
tools/include.
Not that I propose fixing any of this here.
Yeah, 5 is why we have things used just for scrapping in tools/perf/trace/beauty/include/, that now has just socket.h, used by
⬢[acme@toolbox perf-tools-next]$ tools/perf/trace/beauty/socket.sh | head
static const char *socket_ipproto[] = {
[0] = "IP",
[1] = "ICMP",
[2] = "IGMP",
[4] = "IPIP",
[6] = "TCP",
[8] = "EGP",
[12] = "PUP",
[17] = "UDP",
[22] = "IDP",⬢[acme@toolbox perf-tools-next]$
I'll see if I get a series moving things that are just for scrapping to that directory, then test on the container build images I have.
- Arnaldo
Ian Rogers
reviewerPATCH 13/13 tools headers: Rename noinline to __noinline
In reply to Ian RogersAn issue was reported with clang and llvm libc where the noinline attribute [1] was being expanded due to the #define in linux/compiler.h (now in compiler_attributes.h). The expansion caused the __attribute__ to appear twice and break the build. To avoid this conflict, rename noinline to __noinline which is more consistent with other compiler attributes.
[1] https://clang.llvm.org/docs/AttributeReference.html#noinline
--- tools/include/linux/compiler_attributes.h | 4 ++-- tools/perf/arch/x86/tests/bp-modify.c | 4 ++-- tools/perf/bench/find-bit-bench.c | 2 +- tools/perf/tests/bp_account.c | 2 +- tools/perf/tests/bp_signal.c | 2 +- tools/perf/tests/bp_signal_overflow.c | 2 +- tools/perf/tests/dwarf-unwind.c | 12 ++++++------ tools/perf/tests/workloads/leafloop.c | 8 ++++---- tools/perf/tests/workloads/thloop.c | 4 ++-- 9 files changed, 20 insertions(+), 20 deletions(-)
tools/include/linux/compiler_attributes.h +2 -2
@@ -267,12 +267,12 @@# define __flatten __attribute__((flatten))/* -* Note the missing underscores. +* Note, the kernel version is missing the underscores. * * gcc: https://gcc.gnu.org/onlinedocs/gcc/Common-Function-Attributes.html#index-noinline-function-attribute * clang: mentioned */ -#define noinline __attribute__((__noinline__)) +#define __noinline __attribute__((__noinline__))/* * Optional: only supported since gcc >= 8
tools/perf/arch/x86/tests/bp-modify.c +2 -2
@@ -15,13 +15,13 @@#include "tests/tests.h" #include "arch-tests.h" -static noinline int bp_1(void) +static __noinline int bp_1(void) {pr_debug ("in %s\n" , __func__);return 0 ; } -static noinline int bp_2(void) +static __noinline int bp_2(void) {pr_debug ("in %s\n" , __func__);return 0 ;
tools/perf/bench/find-bit-bench.c +1 -1
@@ -31,7 +31,7 @@ static const char *const bench_usage[] = {static unsigned int accumulator;static unsigned int use_of_val; -static noinline void workload(int val) +static __noinline void workload(int val) { use_of_val += val; accumulator++;
tools/perf/tests/bp_account.c +1 -1
@@ -34,7 +34,7 @@static volatile long the_var; -static noinline int test_function(void) +static __noinline int test_function(void) {return 0 ; }
tools/perf/tests/bp_signal.c +1 -1
@@ -59,7 +59,7 @@ static void __test_function(volatile long *ptr) }#endif -static noinline int test_function(void) +static __noinline int test_function(void) {__test_function (&the_var); the_var++;
tools/perf/tests/bp_signal_overflow.c +1 -1
@@ -30,7 +30,7 @@static int overflows; -static noinline int test_function(void) +static __noinline int test_function(void) {return time (NULL ); }
tools/perf/tests/dwarf-unwind.c +6 -6
@@ -109,7 +109,7 @@ static int unwind_entry(struct unwind_entry *entry, void *arg)return strcmp ((const char *) symbol, funcs[idx]); } -NO_TAIL_CALL_ATTRIBUTE noinline int test_dwarf_unwind__thread(struct thread *thread) +NO_TAIL_CALL_ATTRIBUTE __noinline int test_dwarf_unwind__thread(struct thread *thread) {struct perf_sample sample;unsigned long cnt =0 ;
@@ -140,7 +140,7 @@ NO_TAIL_CALL_ATTRIBUTE noinline int test_dwarf_unwind__thread(struct thread *thrstatic int global_unwind_retval = -INT_MAX ; -NO_TAIL_CALL_ATTRIBUTE noinline int test_dwarf_unwind__compare(void *p1, void *p2) +NO_TAIL_CALL_ATTRIBUTE __noinline int test_dwarf_unwind__compare(void *p1, void *p2) {/* Any possible value should be 'thread' */ struct thread *thread = *(struct thread **)p1;
@@ -159,7 +159,7 @@ NO_TAIL_CALL_ATTRIBUTE noinline int test_dwarf_unwind__compare(void *p1, void *preturn p1 - p2; } -NO_TAIL_CALL_ATTRIBUTE noinline int test_dwarf_unwind__krava_3(struct thread *thread) +NO_TAIL_CALL_ATTRIBUTE __noinline int test_dwarf_unwind__krava_3(struct thread *thread) {struct thread *array[2 ] = {thread, thread};void *fp = &bsearch;
@@ -178,7 +178,7 @@ NO_TAIL_CALL_ATTRIBUTE noinline int test_dwarf_unwind__krava_3(struct thread *threturn global_unwind_retval; } -NO_TAIL_CALL_ATTRIBUTE noinline int test_dwarf_unwind__krava_2(struct thread *thread) +NO_TAIL_CALL_ATTRIBUTE __noinline int test_dwarf_unwind__krava_2(struct thread *thread) {int ret;
@@ -187,7 +187,7 @@ NO_TAIL_CALL_ATTRIBUTE noinline int test_dwarf_unwind__krava_2(struct thread *threturn ret; } -NO_TAIL_CALL_ATTRIBUTE noinline int test_dwarf_unwind__krava_1(struct thread *thread) +NO_TAIL_CALL_ATTRIBUTE __noinline int test_dwarf_unwind__krava_1(struct thread *thread) {int ret;
@@ -196,7 +196,7 @@ NO_TAIL_CALL_ATTRIBUTE noinline int test_dwarf_unwind__krava_1(struct thread *threturn ret; } -noinline int test__dwarf_unwind(struct test_suite *test __maybe_unused, +__noinline int test__dwarf_unwind(struct test_suite *test __maybe_unused,int subtest__maybe_unused ) {struct machine *machine;
tools/perf/tests/workloads/leafloop.c +4 -4
@@ -4,18 +4,18 @@#include "../tests.h" /* We want to check these symbols in perf script */ -noinline void leaf(volatile int b); -noinline void parent(volatile int b); +__noinline void leaf(volatile int b); +__noinline void parent(volatile int b);static volatile int a; -noinline void leaf(volatile int b) +__noinline void leaf(volatile int b) {for (;;) a += b; } -noinline void parent(volatile int b) +__noinline void parent(volatile int b) {leaf (b); }
tools/perf/tests/workloads/thloop.c +2 -2
@@ -9,14 +9,14 @@static volatile sig_atomic_t done;/* We want to check this symbol in perf report */ -noinline void test_loop(void); +__noinline void test_loop(void);static void sighandler (int sig__maybe_unused ) { done =1 ; } -noinline void test_loop(void) +__noinline void test_loop(void) {while (!done); }
Signature · 1 line
2.44.0.278.ge034bb2e1d-goog
Re: [PATCH v1 13/13] tools headers: Rename noinline to __noinline
Quoted 3 lines · Ian Rogers
[1] https://clang.llvm.org/docs/AttributeReference.html#noinline
Reported-by Christopher Di Bella <[email protected]>
Out of curiosity, was this due to the [[gnu::noinline]] or similar in e.g. src/string/memset_explicit.h?
tools/include/linux/compiler_attributes.h line 275
Quoted 2 lines
tools/include/linux/compiler_attributes.h +1
-1-#define noinline __attribute__((__noinline__)) +#define __noinline __attribute__((__noinline__))
I guess it does not matter since I don't see it used in tools/, but should the one inside __fix_address be updated too? Or is the idea to keep the diff as minimal as possible?
Cheers,
Miguel
Nick Desaulniers
Acked-byRe: [PATCH v1 13/13] tools headers: Rename noinline to __noinline
Quoted 8 lines · Miguel Ojeda
Quoted 3 lines · Ian Rogers
[1] https://clang.llvm.org/docs/AttributeReference.html#noinline
Reported-by Christopher Di Bella <[email protected]>Out of curiosity, was this due to the
[[gnu::noinline]]or similar in e.g.src/string/memset_explicit.h?
Yes, and in src/__support/threads/linux/thread.cpp's definition of start_thread().
Thanks for the patch!
Signature · 2 lines
Thanks, ~Nick Desaulniers
Re: [PATCH v1 13/13] tools headers: Rename noinline to __noinline
In reply to Ian RogersQuoted 8 lines · Ian Rogers
An issue was reported with clang and llvm libc where the noinline attribute [1] was being expanded due to the #define in
linux/compiler.h(now incompiler_attributes.h). The expansion caused the__attribute__to appear twice and break the build. To avoid this conflict, rename noinline to__noinlinewhich is more consistent with other compiler attributes.[1] https://clang.llvm.org/docs/AttributeReference.html#noinline
Following this link, I don't see __noinline there - only __noinline__ and noinline. What's up?
Als, pls add an empty line before tags.
Quoted 3 lines
Reported-by Christopher Di Bella <[email protected]>Signed-off-by Ian Rogers <[email protected]>
tags should not have empty lines between them.
Quoted 211 lines
--- tools/include/linux/compiler_attributes.h | 4 ++-- tools/perf/arch/x86/tests/bp-modify.c | 4 ++-- tools/perf/bench/find-bit-bench.c | 2 +- tools/perf/tests/bp_account.c | 2 +- tools/perf/tests/bp_signal.c | 2 +- tools/perf/tests/bp_signal_overflow.c | 2 +- tools/perf/tests/dwarf-unwind.c | 12 ++++++------ tools/perf/tests/workloads/leafloop.c | 8 ++++---- tools/perf/tests/workloads/thloop.c | 4 ++-- 9 files changed, 20 insertions(+), 20 deletions(-)tools/include/linux/compiler_attributes.h +2
-2@@ -267,12 +267,12 @@# define __flatten __attribute__((flatten))/* -* Note the missing underscores. +* Note, the kernel version is missing the underscores. * * gcc: https://gcc.gnu.org/onlinedocs/gcc/Common-Function-Attributes.html#index-noinline-function-attribute * clang: mentioned */ -#define noinline __attribute__((__noinline__)) +#define __noinline __attribute__((__noinline__))/* * Optional: only supported since gcc >= 8 tools/perf/arch/x86/tests/bp-modify.c +2
-2@@ -15,13 +15,13 @@#include "tests/tests.h" #include "arch-tests.h" -static noinline int bp_1(void) +static __noinline int bp_1(void) {pr_debug ("in %s\n" , __func__);return 0 ; } -static noinline int bp_2(void) +static __noinline int bp_2(void) {pr_debug ("in %s\n" , __func__);return 0 ;tools/perf/bench/find-bit-bench.c +1
-1@@ -31,7 +31,7 @@ static const char *const bench_usage[] = {static unsigned int accumulator;static unsigned int use_of_val; -static noinline void workload(int val) +static __noinline void workload(int val) { use_of_val += val; accumulator++;tools/perf/tests/bp_account.c +1
-1@@ -34,7 +34,7 @@static volatile long the_var; -static noinline int test_function(void) +static __noinline int test_function(void) {return 0 ; }tools/perf/tests/bp_signal.c +1
-1@@ -59,7 +59,7 @@ static void __test_function(volatile long *ptr) }#endif -static noinline int test_function(void) +static __noinline int test_function(void) {__test_function (&the_var); the_var++;tools/perf/tests/bp_signal_overflow.c +1
-1@@ -30,7 +30,7 @@static int overflows; -static noinline int test_function(void) +static __noinline int test_function(void) {return time (NULL ); }tools/perf/tests/dwarf-unwind.c +6
-6@@ -109,7 +109,7 @@ static int unwind_entry(struct unwind_entry *entry, void *arg)return strcmp ((const char *) symbol, funcs[idx]); } -NO_TAIL_CALL_ATTRIBUTE noinline int test_dwarf_unwind__thread(struct thread *thread) +NO_TAIL_CALL_ATTRIBUTE __noinline int test_dwarf_unwind__thread(struct thread *thread) {struct perf_sample sample;unsigned long cnt =0 ;@@ -140,7 +140,7 @@ NO_TAIL_CALL_ATTRIBUTE noinline int test_dwarf_unwind__thread(struct thread *thrstatic int global_unwind_retval = -INT_MAX ; -NO_TAIL_CALL_ATTRIBUTE noinline int test_dwarf_unwind__compare(void *p1, void *p2) +NO_TAIL_CALL_ATTRIBUTE __noinline int test_dwarf_unwind__compare(void *p1, void *p2) {/* Any possible value should be 'thread' */ struct thread *thread = *(struct thread **)p1;@@ -159,7 +159,7 @@ NO_TAIL_CALL_ATTRIBUTE noinline int test_dwarf_unwind__compare(void *p1, void *preturn p1 - p2; } -NO_TAIL_CALL_ATTRIBUTE noinline int test_dwarf_unwind__krava_3(struct thread *thread) +NO_TAIL_CALL_ATTRIBUTE __noinline int test_dwarf_unwind__krava_3(struct thread *thread) {struct thread *array[2 ] = {thread, thread};void *fp = &bsearch;@@ -178,7 +178,7 @@ NO_TAIL_CALL_ATTRIBUTE noinline int test_dwarf_unwind__krava_3(struct thread *threturn global_unwind_retval; } -NO_TAIL_CALL_ATTRIBUTE noinline int test_dwarf_unwind__krava_2(struct thread *thread) +NO_TAIL_CALL_ATTRIBUTE __noinline int test_dwarf_unwind__krava_2(struct thread *thread) {int ret;@@ -187,7 +187,7 @@ NO_TAIL_CALL_ATTRIBUTE noinline int test_dwarf_unwind__krava_2(struct thread *threturn ret; } -NO_TAIL_CALL_ATTRIBUTE noinline int test_dwarf_unwind__krava_1(struct thread *thread) +NO_TAIL_CALL_ATTRIBUTE __noinline int test_dwarf_unwind__krava_1(struct thread *thread) {int ret;@@ -196,7 +196,7 @@ NO_TAIL_CALL_ATTRIBUTE noinline int test_dwarf_unwind__krava_1(struct thread *threturn ret; } -noinline int test__dwarf_unwind(struct test_suite *test __maybe_unused, +__noinline int test__dwarf_unwind(struct test_suite *test __maybe_unused,int subtest__maybe_unused ) {struct machine *machine;tools/perf/tests/workloads/leafloop.c +4
-4@@ -4,18 +4,18 @@#include "../tests.h" /* We want to check these symbols in perf script */ -noinline void leaf(volatile int b); -noinline void parent(volatile int b); +__noinline void leaf(volatile int b); +__noinline void parent(volatile int b);static volatile int a; -noinline void leaf(volatile int b) +__noinline void leaf(volatile int b) {for (;;) a += b; } -noinline void parent(volatile int b) +__noinline void parent(volatile int b) {leaf (b); }tools/perf/tests/workloads/thloop.c +2
-2@@ -9,14 +9,14 @@static volatile sig_atomic_t done;/* We want to check this symbol in perf report */ -noinline void test_loop(void); +__noinline void test_loop(void);static void sighandler (int sig__maybe_unused ) { done =1 ; } -noinline void test_loop(void) +__noinline void test_loop(void) {while (!done); }Signature · 1 line
2.44.0.278.ge034bb2e1d-goog
Re: [PATCH v1 13/13] tools headers: Rename noinline to __noinline
Quoted 9 lines · Michael S. Tsirkin
Quoted 7 lines · Ian Rogers
An issue was reported with clang and llvm libc where the noinline attribute [1] was being expanded due to the #define in
linux/compiler.h(now incompiler_attributes.h). The expansion caused the__attribute__to appear twice and break the build. To avoid this conflict, rename noinline to__noinlinewhich is more consistent with other compiler attributes.
Quoted 4 lines
Quoted 1 line
[1] https://clang.llvm.org/docs/AttributeReference.html#noinline
Following this link, I don't see
__noinlinethere - only__noinline__and noinline. What's up?
__noinline (which is what this patch is changing the preprocessor define to) will not be expanded in the presence of __attribute__((__noinline__)), __attribute__((noinline)), or [[gnu::inline]], unlike the previous macro definition.
Signature · 2 lines
Thanks, ~Nick Desaulniers