exynos-linux-stable/tools/include/linux
Vitaly Chikunov 0d65b36e13 tools lib: Fix builds when glibc contains strlcpy()
commit 6c4798d3f08b81c2c52936b10e0fa872590c96ae 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 13:05:44 +00:00
..
atomic.h tools include: Introduce atomic_cmpxchg_{relaxed,release}() 2018-06-05 10:28:56 +02:00
bitmap.h tools: add more bitmap functions 2018-06-05 10:28:55 +02:00
bitops.h tools include: Adopt linux/bits.h 2019-05-31 06:48:13 -07:00
bits.h tools include: Adopt linux/bits.h 2019-05-31 06:48:13 -07:00
bug.h tools include: Introduce linux/bug.h, from the kernel sources 2018-06-05 10:28:56 +02:00
compiler-gcc.h tools include: Adopt __same_type() and __must_be_array() from the kernel 2018-06-05 10:28:56 +02:00
compiler.h tools include: Adopt __same_type() and __must_be_array() from the kernel 2018-06-05 10:28:56 +02:00
coresight-pmu.h tools: Copy coresight-pmu.h header file needed by perf tools 2016-08-23 15:37:33 -03:00
err.h tools: Fix shadowed declaration in err.h 2015-09-30 18:34:22 -03:00
export.h tools: Restore export.h 2015-08-25 09:44:22 +02:00
filter.h perf tools: Copy linux/filter.h to tools/include 2015-09-02 16:30:46 -03:00
hash.h tools: Copy linux/{hash,poison}.h and check for drift 2016-07-18 18:41:50 -03:00
hashtable.h tools include: Drop ARRAY_SIZE() definition from linux/hashtable.h 2018-06-05 10:28:57 +02:00
kernel.h tools include: Move ARRAY_SIZE() to linux/kernel.h 2018-06-05 10:28:57 +02:00
list.h tools: Make list.h self-sufficient 2016-01-12 12:42:07 -03:00
log2.h tools include: Include missing headers for fls() and types in linux/log2.h 2018-06-05 10:28:57 +02:00
poison.h tools include: Do not use poison with C++ 2017-12-09 22:01:49 +01:00
rbtree.h tools: Move rbtree.h from tools/perf/ 2015-07-05 22:54:01 -03:00
rbtree_augmented.h tools: Copy rbtree_augmented.h from the kernel 2015-07-05 22:59:05 -03:00
refcount.h tools include: Adopt kernel's refcount.h 2018-06-05 10:28:56 +02:00
spinlock.h radix tree test suite: Remove types.h 2018-06-05 10:28:56 +02:00
string.h tools lib: Fix builds when glibc contains strlcpy() 2020-02-05 13:05:44 +00:00
stringify.h tools include: Copy linux/stringify.h from the kernel 2016-03-23 15:14:27 -03:00
time64.h tools: Introduce tools/include/linux/time64.h for *SEC_PER_*SEC macros 2016-08-23 15:37:33 -03:00
types.h tools include uapi: Grab copies of stat.h and fcntl.h 2018-06-05 10:28:56 +02:00