After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 733715 - glib's configure.ac makes accidentally use of nested function
glib's configure.ac makes accidentally use of nested function
Status: RESOLVED FIXED
Product: glib
Classification: Platform
Component: build
unspecified
Other Linux
: Normal normal
: ---
Assigned To: gtkdev
gtkdev
Depends on:
Blocks:
 
 
Reported: 2014-07-25 08:16 UTC by Alessandro Di Federico
Modified: 2014-07-27 08:09 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
Patch to remove usage of nested functions in configure phase (1.76 KB, patch)
2014-07-25 08:16 UTC, Alessandro Di Federico
committed Details | Review
Updated patch (1.76 KB, patch)
2014-07-26 08:51 UTC, Alessandro Di Federico
none Details | Review

Description Alessandro Di Federico 2014-07-25 08:16:51 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
Comment 1 Allison Karlitskaya (desrt) 2014-07-26 08:04:59 UTC
Thank you for the detailed report and patch.  I've committed it and it will appear in the next release.
Comment 2 Alessandro Di Federico 2014-07-26 08:51:23 UTC
Created attachment 281756 [details] [review]
Updated patch
Comment 3 Alessandro Di Federico 2014-07-26 08:52:32 UTC
The attached patch had a remaining "}", this should be OK.
Comment 4 Allison Karlitskaya (desrt) 2014-07-27 08:09:06 UTC
I just pushed a fix.  Thanks again.