bug-gnulib
[Top][All Lists]
Advanced

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

Re: speed up 'configure' by removing HAVE_RAW_DECL_*


From: Bruno Haible
Subject: Re: speed up 'configure' by removing HAVE_RAW_DECL_*
Date: Sun, 23 Jan 2011 12:21:11 +0100
User-agent: KMail/1.9.9

Hi Paul,

> one way to would be to follow the example of
> gl_ASSERT_NO_GNULIB_TESTS, and add a macro
> gl_ASSERT_NO_GNULIB_POSIXCHECK that says "we don't want support for
> GNULIB_POSIXCHECK", as follows:
> 
>    +# gl_ASSERT_NO_GNULIB_POSIXCHECK
>    +# asserts that there will never be a need to #define GNULIB_POSIXCHECK.
>    +# and thereby enables an optimization of configure and config.h.
>    +# Used by Emacs.
>    +AC_DEFUN([gl_ASSERT_NO_GNULIB_POSIXCHECK],
>    +[
>    +  dnl Override gl_WARN_ON_USE_PREPARE.
>    +  AC_DEFUN([gl_WARN_ON_USE_PREPARE], [])
>    +])

This sounds acceptable.

> Another possibility would be to remove all the HAVE_RAW_DECL_*
> symbols, and remove gl_WARN_ON_USE_PREPARE entirely, and replace all
> .h code that looks like this:
> 
>   #elif defined GNULIB_POSIXCHECK
>   # undef chown
>   # if HAVE_RAW_DECL_CHOWN
>   _GL_WARN_ON_USE (chown, "chown fails to follow symlinks on some systems and 
> "
>                  "doesn't treat a uid or gid of -1 on some systems - "
>                  "use gnulib module chown for portability");
>   # endif
>   #endif
> 
> with code that omits the HAVE_RAW_DECL_* check:
> 
>   #elif defined GNULIB_POSIXCHECK
>   # undef chown
>   _GL_WARN_ON_USE (chown, "chown fails to follow symlinks on some systems and 
> "
>                  "doesn't treat a uid or gid of -1 on some systems - "
>                  "use gnulib module chown for portability");
>   #endif
> 
> The latter approach would speed up 'configure' for all packages, not
> just Emacs.  Another advantage of the latter approach is that it would
> still let Emacs developers try GNULIB_POSIXCHECK if they're brave
> enough to do that.  The only downside that I see is that when
> GNULIB_POSIXCHECK is in effect, then on platforms
> that lack chown the latter approach will have compilations succeed
> (with warnings) and later links will fail (because chown is missing),
> rather than have compilations fail right away.

It's the opposite. On platforms that lack the chown function, the
_GL_WARN_ON_USE (chown, ...) macro causes a compilation failure:

$ cat foo.c
# if 4 < __GNUC__ || (__GNUC__ == 4 && 3 <= __GNUC_MINOR__)
/* A compiler attribute is available in gcc versions 4.3.0 and later.  */
#  define _GL_WARN_ON_USE(function, message) \
extern __typeof__ (function) function __attribute__ ((__warning__ (message)))
# elif __GNUC__ >= 3 && GNULIB_STRICT_CHECKING
/* Verify the existence of the function.  */
#  define _GL_WARN_ON_USE(function, message) \
extern __typeof__ (function) function
# else /* Unsupported.  */
#  define _GL_WARN_ON_USE(function, message) \
_GL_WARN_EXTERN_C int _gl_warn_on_use
# endif

  _GL_WARN_ON_USE (chown, "chown fails to follow symlinks on some systems and "
                   "doesn't treat a uid or gid of -1 on some systems - "
                   "use gnulib module chown for portability");
$ gcc -c foo.c
foo.c:14: error: ‘chown’ undeclared here (not in a function)

But the GNULIB_POSIXCHECK feature would be useless in practice, if just one
missing declaration out of 277 is sufficient to stop the compilation of the
entire program.

That's the very reason why Eric introduced the HAVE_RAW_DECL_* macros. [1]

Bruno

[1] http://lists.gnu.org/archive/html/bug-gnulib/2009-12/msg00434.html



reply via email to

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