Hi Guys, PR 68913 notes that the test gcc.dg/lto/pr61886_0.c test fails on targets whose C library does not provide a __fread_chk function.
Since the purpose of the test is to show that GCC will correctly discard the invocation of __fread_chk_warn, we do not need to actually link against a real __fread_chk function. A dummy will do. Hence I would like to apply the patch below. This patch resolves unexpected failures of the pr61886_0.c test on targets like spu-elf and sparc64-elf. Cheers Nick gcc/testsuite/ChangeLog 2015-12-18 Nick Clifton <ni...@redhat.com> PR 68913 * gcc.dg/lto/pr61886_0.c (__fread_chk): Provide a weak definition of this function. Index: gcc/testsuite/gcc.dg/lto/pr61886_0.c =================================================================== --- gcc/testsuite/gcc.dg/lto/pr61886_0.c (revision 231805) +++ gcc/testsuite/gcc.dg/lto/pr61886_0.c (working copy) @@ -4,7 +4,21 @@ typedef __SIZE_TYPE__ size_t; typedef struct _IO_FILE FILE; -extern size_t __fread_chk (void *__restrict __ptr, size_t __ptrlen, size_t __size, size_t __n, FILE *__restrict __stream) __asm__ ("" "__fread_chk") __attribute__ ((__warn_unused_result__)); +/* PR 68913: Not all targets have __fread_chk available, + so we provide our own version for this function here. */ + +size_t __fread_chk (void *__restrict, size_t, size_t, size_t, FILE *__restrict) __attribute__ ((__warn_unused_result__,weak)); +size_t +__fread_chk (void *__restrict __ptr __attribute__((unused)), + size_t __ptrlen __attribute__((unused)), + size_t __size __attribute__((unused)), + size_t __n __attribute__((unused)), + FILE *__restrict __stream __attribute__((unused))) +{ + return 0; +} + + extern size_t __fread_chk_warn (void *__restrict __ptr, size_t __ptrlen, size_t __size, size_t __n, FILE *__restrict __stream) __asm__ ("" "__fread_chk") __attribute__ ((__warn_unused_result__)) __attribute__((__warning__ ("fread called with bigger size * nmemb than length " "of destination buffer"))); extern __inline __attribute__ ((__always_inline__)) __attribute__ ((__gnu_inline__)) __attribute__ ((__artificial__)) __attribute__ ((__warn_unused_result__))