This service will be undergoing maintenance at 00:00 UTC, 2017-10-23 It is expected to last about 30 minutes
Bug 18829 - autoconf broken with c++ in AC_TRY_RUN
autoconf broken with c++ in AC_TRY_RUN
Status: CLOSED RAWHIDE
Product: Red Hat Linux
Classification: Retired
Component: autoconf (Show other bugs)
7.0
i386 Linux
medium Severity medium
: ---
: ---
Assigned To: Jens Petersen
David Lawrence
:
Depends On:
Blocks:
  Show dependency treegraph
 
Reported: 2000-10-10 12:35 EDT by Stefan Sorensen
Modified: 2007-04-18 12:29 EDT (History)
5 users (show)

See Also:
Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of:
Environment:
Last Closed: 2001-07-10 07:02:46 EDT
Type: ---
Regression: ---
Mount Type: ---
Documentation: ---
CRM:
Verified Versions:
Category: ---
oVirt Team: ---
RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: ---


Attachments (Terms of Use)

  None (edit)
Description Stefan Sorensen 2000-10-10 12:35:25 EDT
AC_TRY_RUN tests that include stdlib.h and with the language set to c++
fails with the error:

===
In file included from configure:541:
/usr/include/stdlib.h:578: declaration of `void exit (int) throw ()' 
throws different exceptions
configure:538: than previous declaration `void exit (int)'
configure: failed program was:
#line 536 "configure"
#include "confdefs.h"
#ifdef __cplusplus
extern "C" void exit(int);
#endif

#include <stdlib.h>
===

Reproduced by the following configure.in script:
===
AC_INIT(configure.in)
AC_LANG_CPLUSPLUS
AC_TRY_RUN([#include <stdlib.h>], , AC_MSG_ERROR(Aaaaargh))
AC_OUTPUT()
===

Patch:

--- autoconf-2.13/acgeneral.m4.orig     Sat Sep 23 12:00:12 2000
+++ autoconf-2.13/acgeneral.m4  Sat Sep 23 12:00:23 2000
@@ -1817,10 +1817,6 @@
 [cat > conftest.$ac_ext <<EOF
 [#]line __oline__ "configure"
 #include "confdefs.h"
-ifelse(AC_LANG, CPLUSPLUS, [#ifdef __cplusplus
-extern "C" void exit(int);
-#endif
-])dnl
 [$1]
 EOF
 if AC_TRY_EVAL(ac_link) && test -s conftest${ac_exeext} && (./conftest;
exit) 2>/dev/null
Comment 1 Nakai 2000-11-15 06:19:21 EST
This bug also cause a fatal error when we install the gtkmm and make new apps
that uses AM_PATH_GTKMM macro in its
configure.in.

But I think this is better patch for this.
Thank you.

--- autoconf-2.13/acgeneral.m4.orig	Tue Jan  5 22:27:37 1999
+++ autoconf-2.13/acgeneral.m4	Sun Nov 12 04:17:10 2000
@@ -1818,7 +1818,7 @@
 [#]line __oline__ "configure"
 #include "confdefs.h"
 ifelse(AC_LANG, CPLUSPLUS, [#ifdef __cplusplus
-extern "C" void exit(int);
+extern "C" void exit(int) throw();
 #endif
 ])dnl
 [$1]
Comment 2 tanner 2001-02-01 17:46:19 EST
Looks like there functional prototype is in more then just acgeneral.m4
.

# pwd
/usr/share/autoconf

# grep -i 'extern "C" void exit(int)' *
acgeneral.m4:extern "C" void exit(int) throw();
autoconf.m4f:extern "C" void exit(int);
autoheader.m4f:extern "C" void exit(int);

Trying to compile gnomemm-1.1.14 on Redhat 7.0

I applied the above patch to acgeneral.m4

$ pwd
/usr/src/redhat/BUILD/gnomemm-1.1.14
 
		Make sure to remove old configure and rebuild it
$ rm configure
$  automake ; autoconf
$ ./configure  --prefix=/usr --disable-maintainer-mode --disable-static
--enable-shared --enable-docs
 checking for GTK-- - version >= 1.2.3... no
*** Could not run GTK-- test program, checking why...
$ grep -i 'extern "C" void exit(int)' *
config.log:extern "C" void exit(int);
configure:extern "C" void exit(int);
configure:extern "C" void exit(int);

That patch is not pickedup by automake or autoconf. 

Comment 3 Murray Cumming 2001-03-06 15:20:27 EST
So how wil this be resolved? Is it an autoconf bug, or a gcc bug?
Comment 4 Jens Petersen 2001-06-21 01:17:31 EDT
[Yukihiro Nakai's patch is in autoconf-2.13-10 (Red Hat 7.1).]
And I checked that
   AC_LANG_CPLUSPLUS
   AC_TRY_RUN([#include <stdlib.h>], , AC_MSG_ERROR(Aaaaargh))
autoconf'ed ok with autoconf-2.13-10.

Also configure of gnomemm runs ok (both 1.1.14 and 1.1.21).

So since all the above seems to have been fixed in 7.1,
I suggest that this bug can be closed.
Comment 5 Murray Cumming 2001-06-21 03:08:12 EDT
No, gnomemm configure works because we patched our own copies of aclocal, or
edited the generated configure scripts before distributing gnomemm.

Yukihiro Nakai's patch would not work because it would create configure scripts
that worked on Redhat but not on other platforms. Our solution was to remove the
void exit declaration line completely.

To test any solution, you would need to autogen.sh gnomemm on both Redhat and an
older distribution, then try to configure the resultant distributions on the
other distributions.
Comment 6 Jens Petersen 2001-06-26 04:28:49 EDT
Thanks for the comment.

So I back-ported _AC_PROG_CXX_EXIT_DECLARATION from autoconf-2.50, where this
problem has already be addressed. The patch below should hopefully allow
autoconf to generate configure files for C++ that will work on many platforms.
I hope this makes C++ users happy.


--- autoconf-2.13/acgeneral.m4~	Tue Jun 26 17:00:28 2001
+++ autoconf-2.13/acgeneral.m4	Tue Jun 26 17:00:28 2001
@@ -1817,10 +1817,6 @@
 [cat > conftest.$ac_ext <<EOF
 [#]line __oline__ "configure"
 #include "confdefs.h"
-ifelse(AC_LANG, CPLUSPLUS, [#ifdef __cplusplus
-extern "C" void exit(int);
-#endif
-])dnl
 [$1]
 EOF
 if AC_TRY_EVAL(ac_link) && test -s conftest${ac_exeext} && (./conftest; exit)
2>/dev/null
--- autoconf-2.13/acspecific.m4~	Tue Jun 26 17:04:34 2001
+++ autoconf-2.13/acspecific.m4		Tue Jun 26 17:04:34 2001
@@ -152,8 +152,41 @@
     CXXFLAGS=
   fi
 fi
+
+AC_PROG_CXX_EXIT_DECLARATION
 ])
 
+
+# AC_PROG_CXX_EXIT_DECLARATION
+# -----------------------------
+# Find a valid prototype for exit and declare it in confdefs.h.
+AC_DEFUN(AC_PROG_CXX_EXIT_DECLARATION,
+[for ac_declaration in \
+   ''\
+   '#include <stdlib.h>' \
+   'extern "C" void std::exit (int) throw (); using std::exit;' \
+   'extern "C" void std::exit (int); using std::exit;' \
+   'extern "C" void exit (int) throw ();' \
+   'extern "C" void exit (int);' \
+   'void exit (int);'
+do
+  AC_TRY_COMPILE([#include <stdlib.h>
+$ac_declaration], 
+                 [exit (42);],
+                 [],
+                 [continue])
+  AC_TRY_COMPILE([$ac_declaration],
+                 [exit (42);],
+                 [break])
+done
+if test -n "$ac_declaration"; then
+  echo '#ifdef __cplusplus' >>confdefs.h
+  echo $ac_declaration      >>confdefs.h
+  echo '#endif'             >>confdefs.h
+fi
+])# AC_PROG_CXX_EXIT_DECLARATION
+
+
 dnl Determine a Fortran 77 compiler to use.  If `F77' is not already set
 dnl in the environment, check for `g77', `f77' and `f2c', in that order.
 dnl Set the output variable `F77' to the name of the compiler found.

Note You need to log in before you can comment on or make changes to this bug.