Subject: Re: bug#18896: regressions in coreutils 8.23 on Yosemite

From: Jack Howarth <[email-masked]>
Date: Mon, 3 Nov 2014 14:40:42 -0500

On Mon, Nov 03, 2014 at 03:16:58PM +0100, Pádraig Brady wrote:
> On 10/31/2014 05:03 PM, Pádraig Brady wrote:
> > On 10/31/2014 03:41 PM, Jack Howarth wrote:
> >> On Fri, Oct 31, 2014 at 03:56:06AM +0000, Pádraig Brady wrote:
> >>> On 10/31/2014 03:30 AM, Jack Howarth wrote:
> >>>> On Fri, Oct 31, 2014 at 02:29:05AM +0000, Pádraig Brady wrote:
> >>>>>
> >>>>> So linkat() is now available but doesn't support hardlinks to symlinks
> >>>>> contrary to the POSIX spec. So it would be best we consider linkat()
> >>>>> unavailable, which can be done manually like:
> >>>>>
> >>>>>   ac_cv_func_linkat=no ./configure
> >>>>>
> >>>>> We'll have to augment the gnulib linkat check to actually check
> >>>>> that linkat() works, rather than just being available.
> >>>>
> >>>> Passing ac_cv_func_linkat=no to configure and using your attached patch
> >>>> results in a large number of failures on x86_64-apple-darwin14.
> >>>
> >>> Good that's better. coreutils tests have passed, and you're getting
> >>> to gnulib issues below.
> 
> I pushed the following slightly different more general patch
> to gnulib to address this issue:
> http://git.sv.gnu.org/gitweb/?p=gnulib.git;a=commitdiff;h=c8e57ce5
> 
> thanks,
> Pádraig.

Pádraig,
     Using a current checkout of gnulib git at commit c564172a11b94fed43632cbc854277d68d14e693
and the instructions at https://sourceware.org/glibc/wiki/Testing/Gnulib, I tested these
changes on x86_64-apple-darwin14. I had to pass -std=c89 to CFLAGS on configure to avoid...

mv -f $depbase.Tpo $depbase.Po
depbase=`echo symlinkat.o | sed 's|[^/]*$|.deps/&|;s|\.o$||'`;\
gcc -DHAVE_CONFIG_H -I. -I..  -DGNULIB_STRICT_CHECKING=1 -Wall  -g -O2 -MT symlinkat.o -MD -MP -MF $depbase.Tpo -c -o symlinkat.o symlinkat.c &&\
mv -f $depbase.Tpo $depbase.Po
symlinkat.c:31:16: warning: implicitly declaring library function 'strlen' with type 'unsigned long (const char *)'
  size_t len = strlen (name);
               ^
symlinkat.c:31:16: note: please include the header <string.h> or explicitly provide a declaration for 'strlen'
symlinkat.c:34:19: error: variable has incomplete type 'struct stat'
      struct stat st;
                  ^
symlinkat.c:34:14: note: forward declaration of 'struct stat'
      struct stat st;
             ^
symlinkat.c:35:11: warning: implicit declaration of function 'fstatat' is invalid in C99 [-Wimplicit-function-declaration]
      if (fstatat (fd, name, &st, 0) == 0)
          ^
2 warnings and 1 error generated.

to eliminate the C99 warning and '#include <string.h>' in symlinkat.c to eliminate the implicit declaration warning.
However this still leaves the compile failure of...

make[4]: Entering directory `/private/tmp/testdir/gllib'
depbase=`echo symlinkat.o | sed 's|[^/]*$|.deps/&|;s|\.o$||'`;\
gcc -DHAVE_CONFIG_H -I. -I..  -DGNULIB_STRICT_CHECKING=1 -Wall -std=c89  -g -O2 -MT symlinkat.o -MD -MP -MF $depbase.Tpo -c -o symlinkat.o symlinkat.c &&\
mv -f $depbase.Tpo $depbase.Po
symlinkat.c:35:19: error: variable has incomplete type 'struct stat'
      struct stat st;
                  ^
symlinkat.c:35:14: note: forward declaration of 'struct stat'
      struct stat st;
             ^
symlinkat.c:36:11: warning: implicit declaration of function 'fstatat' [-Wimplicit-function-declaration]
      if (fstatat (fd, name, &st, 0) == 0)
          ^
1 warning and 1 error generated.

This required adding '#include <sys/stat.h> in symlinkat.c to eliminate the compilation failure.

diff --git a/lib/symlinkat.c b/lib/symlinkat.c
index 9797f46..5df605f 100644
--- a/lib/symlinkat.c
+++ b/lib/symlinkat.c
@@ -20,6 +20,8 @@
 
 #include <unistd.h>
 #include <errno.h>
+#include <string.h>
+#include <sys/stat.h>
 
 #if HAVE_SYMLINKAT
 # undef symlinkat

At this point, I am stuck on the a later compiler error...

gcc -DHAVE_CONFIG_H -I. -I..  -DGNULIB_STRICT_CHECKING=1 -DIN_GNULIB_TESTS=1 -I. -I. -I.. -I./.. -I../gllib -I./../gllib -Wall -std=c89  -g -O2 -MT test-stdnoreturn.o -MD -MP -MF $depbase.Tpo -c -o test-stdnoreturn.o test-stdnoreturn.c &&\
mv -f $depbase.Tpo $depbase.Po
In file included from test-stdnoreturn.c:23:
In file included from ../gllib/stdlib.h:36:
/usr/include/stdlib.h:128:19: error: use of undeclared identifier '__noreturn__'
void     abort(void) __dead2;
                     ^
/usr/include/sys/cdefs.h:135:33: note: expanded from macro '__dead2'
#define __dead2         __attribute__((noreturn))
                                       ^
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../lib/clang/6.0/include/stdnoreturn.h:27:18: note: 
      expanded from macro 'noreturn'
#define noreturn _Noreturn
                 ^
../config.h:4252:37: note: expanded from macro '_Noreturn'
#  define _Noreturn __attribute__ ((__noreturn__))
                                    ^
In file included from test-stdnoreturn.c:23:
In file included from ../gllib/stdlib.h:36:
/usr/include/stdlib.h:142:17: error: use of undeclared identifier '__noreturn__'
void     exit(int) __dead2;
                   ^
/usr/include/sys/cdefs.h:135:33: note: expanded from macro '__dead2'
#define __dead2         __attribute__((noreturn))
                                       ^
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../lib/clang/6.0/include/stdnoreturn.h:27:18: note: 
      expanded from macro 'noreturn'
#define noreturn _Noreturn
                 ^
../config.h:4252:37: note: expanded from macro '_Noreturn'
#  define _Noreturn __attribute__ ((__noreturn__))
                                    ^
In file included from test-stdnoreturn.c:23:
In file included from ../gllib/stdlib.h:36:
/usr/include/stdlib.h:182:17: error: use of undeclared identifier '__noreturn__'
void    _Exit(int) __dead2;
                   ^
/usr/include/sys/cdefs.h:135:33: note: expanded from macro '__dead2'
#define __dead2         __attribute__((noreturn))
                                       ^
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../lib/clang/6.0/include/stdnoreturn.h:27:18: note: 
      expanded from macro 'noreturn'
#define noreturn _Noreturn
                 ^
../config.h:4252:37: note: expanded from macro '_Noreturn'
#  define _Noreturn __attribute__ ((__noreturn__))
                                    ^
In file included from test-stdnoreturn.c:23:
In file included from ../gllib/stdlib.h:96:
In file included from ../gllib/unistd.h:40:
/usr/include/unistd.h:424:18: error: use of undeclared identifier '__noreturn__'
void     _exit(int) __dead2;
                    ^
/usr/include/sys/cdefs.h:135:33: note: expanded from macro '__dead2'
#define __dead2         __attribute__((noreturn))
                                       ^
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../lib/clang/6.0/include/stdnoreturn.h:27:18: note: 
      expanded from macro 'noreturn'
#define noreturn _Noreturn
                 ^
../config.h:4252:37: note: expanded from macro '_Noreturn'
#  define _Noreturn __attribute__ ((__noreturn__))
                                    ^
In file included from test-stdnoreturn.c:23:
In file included from ../gllib/stdlib.h:96:
In file included from ../gllib/unistd.h:40:
In file included from /usr/include/unistd.h:633:
In file included from ../gllib/sys/select.h:108:
In file included from ../gllib/signal.h:65:
In file included from ../gllib/pthread.h:30:
/usr/include/pthread.h:323:27: error: use of undeclared identifier '__noreturn__'
void pthread_exit(void *) __dead2;
                          ^
/usr/include/sys/cdefs.h:135:33: note: expanded from macro '__dead2'
#define __dead2         __attribute__((noreturn))
                                       ^
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../lib/clang/6.0/include/stdnoreturn.h:27:18: note: 
      expanded from macro 'noreturn'
#define noreturn _Noreturn
                 ^
../config.h:4252:37: note: expanded from macro '_Noreturn'
#  define _Noreturn __attribute__ ((__noreturn__))
                                    ^
In file included from test-stdnoreturn.c:23:
In file included from ../gllib/stdlib.h:96:
In file included from ../gllib/unistd.h:40:
/usr/include/unistd.h:640:18: error: use of undeclared identifier '__noreturn__'
void     _Exit(int) __dead2;
                    ^
/usr/include/sys/cdefs.h:135:33: note: expanded from macro '__dead2'
#define __dead2         __attribute__((noreturn))
                                       ^
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../lib/clang/6.0/include/stdnoreturn.h:27:18: note: 
      expanded from macro 'noreturn'
#define noreturn _Noreturn
                 ^
../config.h:4252:37: note: expanded from macro '_Noreturn'
#  define _Noreturn __attribute__ ((__noreturn__))
                                    ^
6 errors generated.

Any ideas on how to eliminate that?
           Jack