1
0
Fork 0
alistair23-linux/tools/include/linux
Vitaly Chikunov e77625d1f8 tools lib: Fix builds when glibc contains strlcpy()
commit 6c4798d3f0 upstream.

Disable a couple of compilation warnings (which are treated as errors)
on strlcpy() definition and declaration, allowing users to compile perf
and kernel (objtool) when:

1. glibc have strlcpy() (such as in ALT Linux since 2004) objtool and
   perf build fails with this (in gcc):

  In file included from exec-cmd.c:3:
  tools/include/linux/string.h:20:15: error: redundant redeclaration of ‘strlcpy’ [-Werror=redundant-decls]
     20 | extern size_t strlcpy(char *dest, const char *src, size_t size);

2. clang ignores `-Wredundant-decls', but produces another warning when
   building perf:

    CC       util/string.o
  ../lib/string.c:99:8: error: attribute declaration must precede definition [-Werror,-Wignored-attributes]
  size_t __weak strlcpy(char *dest, const char *src, size_t size)
  ../../tools/include/linux/compiler.h:66:34: note: expanded from macro '__weak'
  # define __weak                 __attribute__((weak))
  /usr/include/bits/string_fortified.h:151:8: note: previous definition is here
  __NTH (strlcpy (char *__restrict __dest, const char *__restrict __src,

Committer notes:

The

 #pragma GCC diagnostic

directive was introduced in gcc 4.6, so check for that as well.

Fixes: ce99091 ("perf tools: Move strlcpy() from perf to tools/lib/string.c")
Fixes: 0215d59 ("tools lib: Reinstate strlcpy() header guard with __UCLIBC__")
Resolves: https://bugzilla.kernel.org/show_bug.cgi?id=118481
Signed-off-by: Vitaly Chikunov <vt@altlinux.org>
Reviewed-by: Dmitry Levin <ldv@altlinux.org>
Cc: Dmitry Levin <ldv@altlinux.org>
Cc: Josh Poimboeuf <jpoimboe@redhat.com>
Cc: kbuild test robot <lkp@intel.com>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: stable@vger.kernel.org
Cc: Vineet Gupta <vineet.gupta1@synopsys.com>
Link: http://lore.kernel.org/lkml/20191224172029.19690-1-vt@altlinux.org
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2020-02-05 21:22:40 +00:00
..
sched tools/lib/lockdep: Remove private kernel headers 2017-06-05 09:28:14 +02:00
unaligned License cleanup: add SPDX GPL-2.0 license identifier to files with no license 2017-11-02 11:10:55 +01:00
atomic.h License cleanup: add SPDX GPL-2.0 license identifier to files with no license 2017-11-02 11:10:55 +01:00
bitmap.h xarray: Add XArray unconditional store operations 2018-10-21 10:45:57 -04:00
bitops.h tools headers: Add limits.h to access __WORDSIZE 2019-08-20 12:03:05 -03:00
bits.h tools headers: Synchronize linux/bits.h with the kernel sources 2019-08-20 12:09:21 -03:00
bug.h License cleanup: add SPDX GPL-2.0 license identifier to files with no license 2017-11-02 11:10:55 +01:00
compiler-gcc.h tools: bpftool: move "__printf()" attributes to header file 2019-08-15 22:06:46 -07:00
compiler.h tools headers: Restore READ_ONCE() C++ compatibility 2018-04-12 09:30:09 -03:00
const.h tools headers: Grab copy of linux/const.h, needed by linux/bits.h 2019-08-20 12:08:23 -03:00
coresight-pmu.h coresight: etm4x: Add kernel configuration for CONTEXTID 2019-04-25 22:00:16 +02:00
ctype.h tools perf: Move from sane_ctype.h obtained from git to the Linux's original 2019-06-25 21:02:47 -03:00
debug_locks.h License cleanup: add SPDX GPL-2.0 license identifier to files with no license 2017-11-02 11:10:55 +01:00
delay.h tools/lib/lockdep: Remove private kernel headers 2017-06-05 09:28:14 +02:00
err.h docs: fix broken documentation links 2019-06-08 13:42:13 -06:00
export.h tools: Restore export.h 2015-08-25 09:44:22 +02:00
filter.h bpf, selftest: test {rd, wr}only flags and direct value access 2019-04-09 17:05:47 -07:00
ftrace.h tools/lib/lockdep: Remove private kernel headers 2017-06-05 09:28:14 +02:00
gfp.h tools/lib/lockdep: Remove private kernel headers 2017-06-05 09:28:14 +02:00
hardirq.h License cleanup: add SPDX GPL-2.0 license identifier to files with no license 2017-11-02 11:10:55 +01:00
hash.h tools/headers: Synchronize kernel ABI headers 2017-11-04 09:27:46 +01:00
hashtable.h License cleanup: add SPDX GPL-2.0 license identifier to files with no license 2017-11-02 11:10:55 +01:00
interrupt.h tools/lib/lockdep: Remove private kernel headers 2017-06-05 09:28:14 +02:00
irqflags.h License cleanup: add SPDX GPL-2.0 license identifier to files with no license 2017-11-02 11:10:55 +01:00
jhash.h tools/lib/lockdep: Fix compilation for 4.11 2017-06-05 09:28:09 +02:00
kallsyms.h License cleanup: add SPDX GPL-2.0 license identifier to files with no license 2017-11-02 11:10:55 +01:00
kern_levels.h License cleanup: add SPDX GPL-2.0 license identifier to files with no license 2017-11-02 11:10:55 +01:00
kernel.h perf script: Pad DSO name for --call-trace 2019-05-28 18:37:44 -03:00
linkage.h tools/lib/lockdep: Remove private kernel headers 2017-06-05 09:28:14 +02:00
list.h License cleanup: add SPDX GPL-2.0 license identifier to files with no license 2017-11-02 11:10:55 +01:00
lockdep.h tools/lib/lockdep: Add dummy task_struct state member 2018-09-10 13:48:24 +02:00
log2.h treewide: Replace GPLv2 boilerplate/reference with SPDX - rule 152 2019-05-30 11:26:32 -07:00
module.h License cleanup: add SPDX GPL-2.0 license identifier to files with no license 2017-11-02 11:10:55 +01:00
mutex.h tools/lib/lockdep: Remove private kernel headers 2017-06-05 09:28:14 +02:00
nmi.h tools/lib/lockdep: Add empty nmi.h 2018-09-10 13:48:23 +02:00
numa.h tools/: replace open encodings for NUMA_NO_NODE 2019-03-05 21:07:14 -08:00
overflow.h tools: bpf: make use of reallocarray 2018-07-11 22:13:34 +02:00
poison.h Drop flex_arrays 2019-03-12 10:04:03 -07:00
proc_fs.h tools/lib/lockdep: Remove private kernel headers 2017-06-05 09:28:14 +02:00
rbtree.h rbtree: avoid generating code twice for the cached versions (tools copy) 2019-09-25 17:51:39 -07:00
rbtree_augmented.h augmented rbtree: rework the RB_DECLARE_CALLBACKS macro definition 2019-09-25 17:51:39 -07:00
rcu.h rcu: Don't return a value from rcu_assign_pointer() 2019-06-13 15:38:34 -07:00
refcount.h License cleanup: add SPDX GPL-2.0 license identifier to files with no license 2017-11-02 11:10:55 +01:00
ring_buffer.h tools headers: Add missing perf_event.h include 2019-08-22 11:12:36 -03:00
seq_file.h tools/lib/lockdep: Remove private kernel headers 2017-06-05 09:28:14 +02:00
sizes.h tools: bpftool: add "prog run" subcommand to test-run programs 2019-07-05 23:48:07 +02:00
spinlock.h xarray: Add XArray unconditional store operations 2018-10-21 10:45:57 -04:00
stacktrace.h License cleanup: add SPDX GPL-2.0 license identifier to files with no license 2017-11-02 11:10:55 +01:00
string.h tools lib: Fix builds when glibc contains strlcpy() 2020-02-05 21:22:40 +00:00
stringify.h License cleanup: add SPDX GPL-2.0 license identifier to files with no license 2017-11-02 11:10:55 +01:00
time64.h License cleanup: add SPDX GPL-2.0 license identifier to files with no license 2017-11-02 11:10:55 +01:00
types.h License cleanup: add SPDX GPL-2.0 license identifier to files with no license 2017-11-02 11:10:55 +01:00
zalloc.h tools lib: Adopt zalloc()/zfree() from tools/perf 2019-07-09 10:13:26 -03:00