GNOME Bugzilla – Bug 733715
glib's configure.ac makes accidentally use of nested function
Last modified: 2014-07-27 08:09:06 UTC
Created attachment 281665 [details] [review] Patch to remove usage of nested functions in configure phase When using AC_TRY_LINK and AC_TRY_COMPILE in configure.ac, in certain cases, a whole function (e.g. "int main() { return; }") is passed as second parameter: --------- 8< --------- LIBS= AC_TRY_LINK([], [int main (void) { return 0; }], AC_MSG_RESULT(yes) [ldflags_fatal=-Wl,--fatal-warnings], AC_MSG_RESULT(no) ldflags_fatal=) --------- 8< --------- However, as the doc [1] explains, the function _body_ should be used. This leads to a test file such as: --------- 8< --------- int main () { int main (void) { return 0; } ; return 0; } --------- 8< --------- This C file works under GCC but not with other compilers (e.g. Clang) which do not support nested functions, a GNU C extension. Clang fails with the following error message: --------- 8< --------- configure:28818: clang -o conftest -g -O2 -pthread -Wl,-Bsymbolic-functions conftest.c >&5 conftest.c:184:17: error: function definition is not allowed here int main (void) { return 0; } ^ 1 error generated. configure:28818: $? = 1 --------- 8< --------- This leads the test to fail disabling possibly important features. Attached you can find a patch for the 4 mistakes in glib's configure.ac, however, I'd suggest to give a grep shot on the whole gnome project to find similar issues. This bug has been discovered in the context of trying to prevent Glib from getting unloaded (which is unsupported) using `-z nodelete` [2]. [1] http://ftp.gnu.org/old-gnu/Manuals/autoconf-2.53/html_node/Examining-Libraries.html [2] https://bugs.gentoo.org/show_bug.cgi?id=405173
Thank you for the detailed report and patch. I've committed it and it will appear in the next release.
Created attachment 281756 [details] [review] Updated patch
The attached patch had a remaining "}", this should be OK.
I just pushed a fix. Thanks again.