bug-bash
[Top][All Lists]
Advanced

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

Wrong AC_TRY_COMPILE idiom


From: Christian Weisgerber
Subject: Wrong AC_TRY_COMPILE idiom
Date: Mon, 25 Sep 2017 19:14:38 +0200
User-agent: Mutt/1.9.0 (2017-09-02)

I'm forwarding this bug report by Robert Nagy <address@hidden>,
which also concerns bash 4.4:

---------------->
Unbreak autoconf checks with clang by not using nested functions
in the checks.

Someone clearly did not read the autoconf documentation because
using the following functions with a function declaration inside
the body will end up declaring a function inside a function.

- AC_TRY_COMPILE( [], [ int main() { return 0; } ],
- AC_LANG_PROGRAM([[]], [[int main (void) { return 0; }]])],
- AC_TRY_LINK([], [int main (void) { return 0; }],

Result:

int
main ()
{
int main (void) { return 0; }
  ;
  return 0;
}

nested functions is a gcc extension which is not supported by
clang.

test.c:4:17: error: function definition is not allowed here
int main (void) { return 0; }
                ^
1 error generated.

This causes tests to fail in the configure scripts resulting in
missing compile and link time flags from the builds.

This resulted in weird behaviour of several software, like gnome
hanging completely due to gtk+3 not being built properly.

This change intrudces the following fixes:

- remove int main() declaration from AC_TRY_COMPILE, AC_LANG_PROGRAM, 
AC_TRY_LINK
  as it comes with a declaration already, and people misused them

- change to use AC_LANG_SOURCE when needed in case a complete source block is 
specified

<----------------

Here's the trivial patch for bash 4.4:

--- configure.ac.orig   Wed Sep  7 22:56:28 2016
+++ configure.ac        Mon Sep 25 19:03:03 2017
@@ -808,7 +808,7 @@
     AC_CACHE_VAL(bash_cv_strtold_broken,
        [AC_TRY_COMPILE(
            [#include <stdlib.h>],
-           [int main() { long double r; char *foo, bar; r = strtold(foo, 
&bar);}],
+           [long double r; char *foo, bar; r = strtold(foo, &bar);],
            bash_cv_strtold_broken=no, bash_cv_strtold_broken=yes,
            [AC_MSG_WARN(cannot check for broken strtold if cross-compiling, 
defaulting to no)])
        ]

-- 
Christian "naddy" Weisgerber                          address@hidden



reply via email to

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