autoconf-patches
[Top][All Lists]
Advanced

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

Re: hp cc +O3 and AC_CHECK_FUNCS


From: Akim Demaille
Subject: Re: hp cc +O3 and AC_CHECK_FUNCS
Date: 12 Nov 2002 12:09:09 +0100
User-agent: Gnus/5.0808 (Gnus v5.8.8) XEmacs/21.4 (Honest Recruiter)

| With a recent HP cc +O3 on ia64 (at testdrive.compaq.com), all
| AC_CHECK_FUNCS claim their function exists, irrespective of whether it
| does or not.  I'd like to propose this change to fix that.
| 
| The name "conftest_$1" for the second function tries to avoid
| conflicting with $1 or any standard function.  Perhaps some fixed
| unlikely name would be enough.
| 
|         * lib/autoconf/c.m4 (AC_LANG_FUNC_LINK_TRY(C)): Put f=$1 in another
|         function, not main, to avoid HP cc +O3 optimizing it away.
| 
| 
| --- c.m4.~1.171.~     2002-11-09 08:33:24.000000000 +1000
| +++ c.m4      2002-11-09 08:37:44.000000000 +1000
| @@ -165,6 +165,13 @@
|  # Don't include <ctype.h> because on OSF/1 3.0 it includes
|  # <sys/types.h> which includes <sys/select.h> which contains a
|  # prototype for select.  Similarly for bzero.
| +#
| +# HP unbundled cc A.05.36 for ia64 under +O3 will optimize away "f=$1" if
| +# it's the last thing in main, apparently on the basis that such an
| +# assignment is unnecessary if the program is about to exit (a rash
| +# assumption if some atexits are about to run).  Putting f=$1 in another
| +# function prevents it getting removed and losing the link reference to $1.
| +#
|  m4_define([AC_LANG_FUNC_LINK_TRY(C)],
|  [AC_LANG_PROGRAM(
|  [/* System header to define __stub macros and hopefully few prototypes,
| @@ -183,7 +190,11 @@
|  }
|  #endif
|  ],
| -[/* The GNU C library defines this for functions which it implements
| +[}
| +int
| +conftest_$1()
| +{
| +/* The GNU C library defines this for functions which it implements
|      to always fail with ENOSYS.  Some functions are actually named
|      something starting with __ and the normal name is an alias.  */
|  #if defined (__stub_$1) || defined (__stub___$1)

Well, the bad news is that now we can trigger warnings for people
using something like

`-Wmissing-prototypes (C only)'
     Warn if a global function is defined without a previous prototype
     declaration.  This warning is issued even if the definition itself
     provides a prototype.  The aim is to detect global functions that
     fail to be declared in header files.

But if we add static, it's even worse since the function is not
called.  Therefore, I think that the function should be static and
called from main.

But Paul's opinion is, as always, valuable here.




reply via email to

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