bug-gnulib
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

inline related build failures on MacOS X 10.5


From: Bruno Haible
Subject: inline related build failures on MacOS X 10.5
Date: Fri, 11 Apr 2008 15:14:07 +0200
User-agent: KMail/1.5.4

On MacOS X 10.5.2, GNU cpio-2.9 and GNU tar-1.18 exhibit build failures.

This is for cpio:

  gcc -std=gnu99  -g -O2   -o cpio  copyin.o copyout.o copypass.o defer.o 
dstring.o global.o main.o tar.o util.o filemode.o idcache.o makepath.o 
userspec.o ../lib/libcpio.a -L/Users/bruno/data/local-macos/lib -lintl -liconv 
-lc  -Wl,-framework -Wl,CoreFoundation 
  ld: duplicate symbol _argp_fmtstream_putc in 
../lib/libcpio.a(argp-fmtstream.o) and ../lib/libcpio.a(argp-help.o)
  collect2: ld returned 1 exit status
  make[2]: *** [cpio] Error 1

This is for tar:

  gcc -std=gnu99  -g -O2   -o tar  buffer.o compare.o create.o delete.o 
extract.o xheader.o incremen.o list.o misc.o names.o sparse.o system.o tar.o 
transform.o update.o utf8.o ../lib/libtar.a -L/Users/bruno/data/local-macos/lib 
-lintl -liconv -lc  -Wl,-framework -Wl,CoreFoundation 
-L/Users/bruno/data/local-macos/lib -liconv  
  ld: duplicate symbol _argp_fmtstream_write in ../lib/libtar.a(argp-help.o) 
and tar.o
  collect2: ld returned 1 exit status
  make[2]: *** [tar] Error 1

The reason is that the ARGP_FS_EI in argp-fmtstream.h expands to 'extern 
inline',
and the gcc compiler generates a symbol with global visibility for it (just a
plain .globl, no weak stuff).

  $ gcc -v 2>&1 | tail -1
  gcc version 4.0.1 (Apple Inc. build 5465)

It appears to be a GCC 4.0.x with some backports from the GCC 4.2 and 4.3
development.

For 'extern inline', this gcc generates a symbol with global visibility in
"gcc -std=gnu99" mode, but not in the default mode. The macro that allows to
distinguish the two cases is '#define __STDC_VERSION__ 199901L' in the
"gcc -std=gnu99" mode, not defined in the default mode.

Instead of 'extern inline', one cannot use
'extern inline __attribute__ ((__gnu_inline__))'
because that yields warnings:
  argp-fmtstream.h:231: warning: '__gnu_inline__' attribute directive ignored
But one can use 'inline'. I.e. __GNUC_STDC_INLINE__ should be defined but
isn't.

This should ideally be solved through autoconf (let autoconf try
"-std=gnu99 -D__GNUC_STDC_INLINE__" instead of "-std=gnu99"), but since I
don't know when the next autoconf release will be, I'm adding this to gnulib.
Tested with
  $ ./gnulib-tool --create-testdir --with-tests --dir=/dev/shm/testdir argp 
stdarg

Eric or Ralf: I tried to add this piece of #defines to config.h only if
AC_PROG_CC_STDC is defined. Something like

AC_DEFUN([gl_COMMON_BODY], [
  m4_define([AC_PROG_CC_STDC], m4_defn([AC_PROG_CC_STDC])[
    AH_VERBATIM([...])
  ])
])

but since I'm not sure whether augmenting predefined macros like this works,
I left it out.


2008-04-11  Bruno Haible  <address@hidden>

        Fix __GNUC_STDC_INLINE__ predefine with Apple GCC on MacOS X 10.5.
        * gnulib-tool (func_emit_initmacro_start): Emit an invocation of
        gl_COMMON.
        * m4/gnulib-common.m4 (gl_COMMON, gl_COMMON_BODY): New macros.

*** gnulib-tool.orig    2008-04-11 15:05:11.000000000 +0200
--- gnulib-tool 2008-04-11 14:58:09.000000000 +0200
***************
*** 2046,2051 ****
--- 2046,2052 ----
    # We let automake know about the files to be distributed through the
    # EXTRA_lib_SOURCES variable.
    echo "  m4_pushdef([AC_LIBSOURCES], 
m4_defn([${macro_prefix_arg}_LIBSOURCES]))"
+   echo "  gl_COMMON"
  }
  
  # func_emit_initmacro_end macro_prefix
*** m4/gnulib-common.m4.orig    2008-04-11 15:05:11.000000000 +0200
--- m4/gnulib-common.m4 2008-04-11 15:04:28.000000000 +0200
***************
*** 1,9 ****
! # gnulib-common.m4 serial 3
! dnl Copyright (C) 2007 Free Software Foundation, Inc.
  dnl This file is free software; the Free Software Foundation
  dnl gives unlimited permission to copy and/or distribute it,
  dnl with or without modifications, as long as this notice is preserved.
  
  # gl_MODULE_INDICATOR([modulename])
  # defines a C macro indicating the presence of the given module.
  AC_DEFUN([gl_MODULE_INDICATOR],
--- 1,28 ----
! # gnulib-common.m4 serial 4
! dnl Copyright (C) 2007-2008 Free Software Foundation, Inc.
  dnl This file is free software; the Free Software Foundation
  dnl gives unlimited permission to copy and/or distribute it,
  dnl with or without modifications, as long as this notice is preserved.
  
+ # gl_COMMON
+ # is expanded unconditionally through gnulib-tool magic.
+ AC_DEFUN([gl_COMMON], [
+   dnl Use AC_REQUIRE here, so that the code is expanded once only.
+   AC_REQUIRE([gl_COMMON_BODY])
+ ])
+ AC_DEFUN([gl_COMMON_BODY], [
+   AH_VERBATIM([isoc99_inline],
+ [/* Work around a bug in Apple GCC 4.0.1 build 5465: In C99 mode, it supports
+    the ISO C 99 semantics of 'extern inline' (unlike the GNU C semantics of
+    earlier versions), but does not display it by setting __GNUC_STDC_INLINE__.
+    __APPLE__ && __MACH__ test for MacOS X.
+    __APPLE_CC__ tests for the Apple compiler and its version.
+    __STDC_VERSION__ tests for the C99 mode.  */
+ #if defined __APPLE__ && defined __MACH__ && __APPLE_CC__ >= 5465 && !defined 
__cplusplus && __STDC_VERSION__ >= 199901L && !defined __GNUC_STDC_INLINE__
+ # define __GNUC_STDC_INLINE__ 1
+ #endif])
+ ])
+ 
  # gl_MODULE_INDICATOR([modulename])
  # defines a C macro indicating the presence of the given module.
  AC_DEFUN([gl_MODULE_INDICATOR],





reply via email to

[Prev in Thread] Current Thread [Next in Thread]