Re: Wrong AC_TRY_COMPILE idiom

2017-09-25 Thread Chet Ramey
On 9/25/17 1:14 PM, Christian Weisgerber wrote:
> I'm forwarding this bug report by Robert Nagy ,
> which also concerns bash 4.4:
> 
> >
> Unbreak autoconf checks with clang by not using nested functions
> in the checks.

Thanks for the report. This has clearly not been too serious a problem,
since the code in question has been in place since October, 2002.  I'll
fix it for the next bash release.

Chet
-- 
``The lyf so short, the craft so long to lerne.'' - Chaucer
 ``Ars longa, vita brevis'' - Hippocrates
Chet Ramey, UTech, CWRUc...@case.eduhttp://cnswww.cns.cwru.edu/~chet/



Wrong AC_TRY_COMPILE idiom

2017-09-25 Thread Christian Weisgerber
I'm forwarding this bug report by Robert Nagy ,
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.acMon Sep 25 19:03:03 2017
@@ -808,7 +808,7 @@
 AC_CACHE_VAL(bash_cv_strtold_broken,
[AC_TRY_COMPILE(
[#include ],
-   [int main() { long double r; char *foo, bar; r = strtold(foo, 
);}],
+   [long double r; char *foo, bar; r = strtold(foo, );],
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  na...@mips.inka.de