[PATCH] acinclude.m4: fix __builtin_alloca availability test

Torbjorn Granlund tg at gmplib.org
Sat Dec 5 19:46:07 CET 2009


Yann Droneaud <yann at droneaud.fr> writes:

  Le jeudi 03 décembre 2009 à 21:48 +0100, Torbjorn Granlund a écrit :
  > Yann Droneaud <yann at droneaud.fr> writes:
  > 
  >   # HG changeset patch
  >   # User Yann Droneaud <yann at droneaud.fr>
  >   # Date 1259853333 18000
  >   # Node ID 3081e11883a3f2169a893e4f224d046f1f8ac93f
  >   # Parent  5f710b3ff8457795a4e376281561c1aeeee1d3d4
  >   acinclude.m4: fix __builtin_alloca availability test
  >   
  >   Use GMP_PROG_CC_WORKS_PART() instead of GMP_PROG_CC_WORKS_PART_TEST()
  >   otherwise main() is not declared and the test program failed to link
  >   
  >   diff -r 5f710b3ff845 -r 3081e11883a3 acinclude.m4
  >   --- a/acinclude.m4	Thu Dec 03 15:00:04 2009 +0100
  >   +++ b/acinclude.m4	Thu Dec 03 10:15:33 2009 -0500
  >   @@ -548,7 +548,7 @@
  >    
  >    # __builtin_alloca is not available everywhere, check it exists before
  >    # seeing that it works
  >   -GMP_PROG_CC_WORKS_PART_TEST([$1],[__builtin_alloca availability],
  >   +GMP_PROG_CC_WORKS_PART([$1],[__builtin_alloca availability],
  >    [int k; int foo () { __builtin_alloca (k); }],
  >      [GMP_PROG_CC_WORKS_PART([$1], [alloca array],
  >    [/* The following provokes an internal compiler error from Itanium HP-UX cc
  > 
  > This confuses me.
  > 
  > There is a main generated for this test, please see the generated
  > configure.
  > 
  
  Seems not:
  
  "
  # __builtin_alloca is not available everywhere, check it exists before
  # seeing that it works
  if test "$gmp_prog_cc_works" = yes; then
    # remove anything that might look like compiler output to our "||"
  expression
    rm -f conftest* a.out b.out a.exe a_out.exe
    cat >conftest.c <<EOF
  int k; int foo () { __builtin_alloca (k); }
  EOF
    echo "Test compile: __builtin_alloca availability" >&5
    gmp_compile="$cc $cflags $cppflags conftest.c >&5"
  "
  
  So it will always fail at link time.
  
I looked more carefully at this.

OK, so there are two code snippets involved here.  There is a main added
to the 2nd snippet; that's the main I saw.

The general GMP_PROG_CC_WORKS_PART_TEST is used since it has the three
action parameters; the success parameter is the 2nd code snippet.

Your change seems incorrect, since it replaces the 6 argument
GMP_PROG_CC_WORKS_PART_TEST with the 3 argument GMP_PROG_CC_WORKS_PART
without somehow handling that.

Do you agree?

A better change might be to put a dummy main into code snippet 1.

-- 
Torbjörn


More information about the gmp-devel mailing list