Subject: Re: bug#13495: Compilation fails on Mac OS X 10.8.0

From: Assaf Gordon <[email-masked]>
Date: Fri, 18 Jan 2013 17:45:30 -0500

More information:

Assaf Gordon wrote, On 01/18/2013 05:32 PM:
> Hello,
> 
> Trying to compile the latest coreutils on Mac OS X, I get the following compilation error:
> 
>     $ ./configure
>     [ works OK ]
>     $ make
>     [ ... ]
>       CC       lib/stpncpy.o
>     lib/stpncpy.c:34: error: expected declaration specifiers or '...' before numeric constant
>     lib/stpncpy.c:34: error: expected ')' before '!=' token
>     lib/stpncpy.c:34: error: expected ')' before '?' token
>     make[2]: *** [lib/stpncpy.o] Error 1
>     make[1]: *** [all-recursive] Error 1
>     make: *** [all] Error 2
> 
> This happens with the released version 8.20, and also with "8.20.90-e27bfd" (I had to git-pull on another machine and do "make dist" to generate it).
> 

-1-

I was wrong, the compiler was not "clang" - based on "config.log", it was GCC (or some gcc/llvm hybrid?) :

=== relevant fragment from config.log ===
configure:4681: checking for gcc
configure:4697: found /usr/bin/gcc
configure:4708: result: gcc
configure:4937: checking for C compiler version
configure:4946: gcc --version >&5
i686-apple-darwin11-llvm-gcc-4.2 (GCC) 4.2.1 (Based on Apple Inc. build 5658) (LLVM build 2336.11.00)
Copyright (C) 2007 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

configure:4957: $? = 0
configure:4946: gcc -v >&5
Using built-in specs.
Target: i686-apple-darwin11
Configured with: /private/var/tmp/llvmgcc42/llvmgcc42-2336.11~67/src/configure --disable-checking --enable-werror --prefix=/Applications/Xcode.app/Contents/Developer/usr/llvm-gcc-4.2 --mandir=/share/man --enable-languages=c,objc,c++,obj-c++ --program-prefix=llvm- --program-transform-name=/^[cg][^.-]*$/s/$/-4.2/ --with-slibdir=/usr/lib --build=i686-apple-darwin11 --enable-llvm=/private/var/tmp/llvmgcc42/llvmgcc42-2336.11~67/dst-llvmCore/Developer/usr/local --program-prefix=i686-apple-darwin11- --host=x86_64-apple-darwin11 --target=i686-apple-darwin11 --with-gxx-include-dir=/usr/include/c++/4.2.1
Thread model: posix
gcc version 4.2.1 (Based on Apple Inc. build 5658) (LLVM build 2336.11.00)
configure:4957: $? = 0
configure:4946: gcc -V >&5
llvm-gcc-4.2: argument to `-V' is missing
configure:4957: $? = 1
configure:4946: gcc -qversion >&5
i686-apple-darwin11-llvm-gcc-4.2: no input files
===

-2- 

Trying to use clang, I get other errors (still in stpncpy.c):

$ ./configure CC=clang
[ works OK ]
$ make
[ ... ]
  CC       lib/stpncpy.o
lib/stpncpy.c:34:1: error: expected parameter declarator
__stpncpy (char *dest, const char *src, size_t n)
^
lib/stpncpy.c:28:20: note: expanded from macro '__stpncpy'
# define __stpncpy stpncpy
                   ^
/usr/include/secure/_string.h:110:5: note: expanded from macro 'stpncpy'
  ((__darwin_obsz0 (dest) != (size_t) -1)                               \
    ^
/usr/include/secure/_common.h:38:63: note: expanded from macro '__darwin_obsz0'
#define __darwin_obsz0(object) __builtin_object_size (object, 0)
                                                              ^
lib/stpncpy.c:34:1: error: expected ')'
__stpncpy (char *dest, const char *src, size_t n)
^
lib/stpncpy.c:28:20: note: expanded from macro '__stpncpy'
# define __stpncpy stpncpy
                   ^
/usr/include/secure/_string.h:110:5: note: expanded from macro 'stpncpy'
  ((__darwin_obsz0 (dest) != (size_t) -1)                               \
    ^
/usr/include/secure/_common.h:38:63: note: expanded from macro '__darwin_obsz0'
#define __darwin_obsz0(object) __builtin_object_size (object, 0)
                                                              ^
lib/stpncpy.c:34:1: note: to match this '('
__stpncpy (char *dest, const char *src, size_t n)
^
lib/stpncpy.c:28:20: note: expanded from macro '__stpncpy'
# define __stpncpy stpncpy
                   ^
/usr/include/secure/_string.h:110:5: note: expanded from macro 'stpncpy'
  ((__darwin_obsz0 (dest) != (size_t) -1)                               \
    ^
/usr/include/secure/_common.h:38:54: note: expanded from macro '__darwin_obsz0'
#define __darwin_obsz0(object) __builtin_object_size (object, 0)
                                                     ^
lib/stpncpy.c:34:1: error: expected ')'
__stpncpy (char *dest, const char *src, size_t n)
^
lib/stpncpy.c:28:20: note: expanded from macro '__stpncpy'
# define __stpncpy stpncpy
                   ^
/usr/include/secure/_string.h:110:27: note: expanded from macro 'stpncpy'
  ((__darwin_obsz0 (dest) != (size_t) -1)                               \
                          ^
lib/stpncpy.c:34:1: note: to match this '('
__stpncpy (char *dest, const char *src, size_t n)
^
lib/stpncpy.c:28:20: note: expanded from macro '__stpncpy'
# define __stpncpy stpncpy
                   ^
/usr/include/secure/_string.h:110:4: note: expanded from macro 'stpncpy'
  ((__darwin_obsz0 (dest) != (size_t) -1)                               \
   ^
lib/stpncpy.c:34:1: error: expected ')'
__stpncpy (char *dest, const char *src, size_t n)
^
lib/stpncpy.c:28:20: note: expanded from macro '__stpncpy'
# define __stpncpy stpncpy
                   ^
/usr/include/secure/_string.h:111:4: note: expanded from macro 'stpncpy'
   ? __builtin___stpncpy_chk (dest, src, len, __darwin_obsz (dest))     \
   ^
lib/stpncpy.c:34:1: note: to match this '('
__stpncpy (char *dest, const char *src, size_t n)
^
lib/stpncpy.c:28:20: note: expanded from macro '__stpncpy'
# define __stpncpy stpncpy
                   ^
/usr/include/secure/_string.h:110:3: note: expanded from macro 'stpncpy'
  ((__darwin_obsz0 (dest) != (size_t) -1)                               \
  ^
lib/stpncpy.c:34:1: error: conflicting types for '__builtin_object_size'
__stpncpy (char *dest, const char *src, size_t n)
^
lib/stpncpy.c:28:20: note: expanded from macro '__stpncpy'
# define __stpncpy stpncpy
                   ^
/usr/include/secure/_string.h:110:5: note: expanded from macro 'stpncpy'
  ((__darwin_obsz0 (dest) != (size_t) -1)                               \
    ^
/usr/include/secure/_common.h:38:32: note: expanded from macro '__darwin_obsz0'
#define __darwin_obsz0(object) __builtin_object_size (object, 0)
                               ^
/usr/include/secure/_string.h:61:56: note: '__builtin_object_size' is a builtin with type
      'unsigned long (const void *, int)'
  return __builtin___memcpy_chk (__dest, __src, __len, __darwin_obsz0(__dest));
                                                       ^
/usr/include/secure/_common.h:38:32: note: expanded from macro '__darwin_obsz0'
#define __darwin_obsz0(object) __builtin_object_size (object, 0)
                               ^
lib/stpncpy.c:34:1: error: definition of builtin function '__builtin_object_size'
__stpncpy (char *dest, const char *src, size_t n)
^
lib/stpncpy.c:28:20: note: expanded from macro '__stpncpy'
# define __stpncpy stpncpy
                   ^
/usr/include/secure/_string.h:110:5: note: expanded from macro 'stpncpy'
  ((__darwin_obsz0 (dest) != (size_t) -1)                               \
    ^
/usr/include/secure/_common.h:38:32: note: expanded from macro '__darwin_obsz0'
#define __darwin_obsz0(object) __builtin_object_size (object, 0)
                               ^
lib/stpncpy.c:39:7: error: use of undeclared identifier 'n'
  if (n >= 4)
      ^
lib/stpncpy.c:41:19: error: use of undeclared identifier 'n'
      size_t n4 = n >> 2;
                  ^
lib/stpncpy.c:45:16: error: use of undeclared identifier 'src'
          c = *src++;
               ^
lib/stpncpy.c:49:16: error: use of undeclared identifier 'src'
          c = *src++;
               ^
lib/stpncpy.c:53:16: error: use of undeclared identifier 'src'
          c = *src++;
               ^
lib/stpncpy.c:57:16: error: use of undeclared identifier 'src'
          c = *src++;
               ^
lib/stpncpy.c:64:7: error: use of undeclared identifier 'n'
      n -= dest - s;
      ^
lib/stpncpy.c:69:3: error: use of undeclared identifier 'n'
  n &= 3;
  ^
lib/stpncpy.c:70:7: error: use of undeclared identifier 'n'
  if (n == 0)
      ^
lib/stpncpy.c:75:12: error: use of undeclared identifier 'src'
      c = *src++;
           ^
lib/stpncpy.c:76:9: error: use of undeclared identifier 'n'
      --n;
        ^
lib/stpncpy.c:80:11: error: use of undeclared identifier 'n'
      if (n == 0)
          ^
lib/stpncpy.c:85:10: error: use of undeclared identifier 'n'
  while (n-- > 0)
         ^
fatal error: too many errors emitted, stopping now [-ferror-limit=]
20 errors generated.
make[2]: *** [lib/stpncpy.o] Error 1
make[1]: *** [all-recursive] Error 1
make: *** [all] Error 2