configure sometimes misses passing LDFLAGS when testing linker

Niels Möller nisse at lysator.liu.se
Thu Mar 28 06:06:11 UTC 2019


Jameson Nash <vtjnash at gmail.com> writes:

> OK, here's take 2, where I use that approach instead. You're right, this
> seems to a bit more precise about which calls to the compiler are using the
> linker.

This patch to acinclude.m4 (quoted below) looks good to me. I'm not that
familiar with gmp's compiler tests, though. Torbjörn, do you agree this
is the right fix?

> --- gmp-6.1.2/acinclude.m4	2016-12-16 10:45:27.000000000 -0500
> +++ gmp-6.1.2-LDFLAGS/acinclude.m4	2019-03-26 13:08:01.328189815 -0400
> @@ -826,7 +826,7 @@ AC_DEFUN([GMP_PROG_CC_WORKS_PART_TEST],
>  [$3]
>  EOF
>    echo "Test compile: [$2]" >&AC_FD_CC
> -  gmp_compile="$1 conftest.c >&AC_FD_CC"
> +  gmp_compile="$1 $LDFLAGS conftest.c >&AC_FD_CC"
>    if AC_TRY_EVAL(gmp_compile); then
>      cc_works_part=yes
>      if test "$cross_compiling" = no; then
> @@ -1147,7 +1147,7 @@ AC_DEFUN([GMP_GCC_NO_CPP_PRECOMP],
>    cat >conftest.c <<EOF
>  int main () { return 0; }
>  EOF
> -  gmp_compile="$2 $3 -no-cpp-precomp conftest.c >conftest.out 2>&1"
> +  gmp_compile="$2 $3 $LDFLAGS -no-cpp-precomp conftest.c >conftest.out 2>&1"
>    if AC_TRY_EVAL(gmp_compile); then
>      if grep "unrecognized option.*-no-cpp-precomp" conftest.out >/dev/null; then : ;
>      else
> @@ -1328,7 +1328,7 @@ _main:
>  	xorl	%eax, %eax
>  	ret
>  EOF
> -  gmp_compile="$1 conftest.s -o conftest >&AC_FD_CC"
> +  gmp_compile="$1 $LDFLAGS conftest.s -o conftest >&AC_FD_CC"
>    if AC_TRY_EVAL(gmp_compile); then
>      if AC_TRY_COMMAND([./a.out || ./b.out || ./a.exe || ./a_out.exe || ./conftest]); then
>        gmp_cv_os_x86_xmm=yes
> @@ -1495,7 +1495,7 @@ AC_DEFUN([GMP_PROG_CXX_WORKS_PART],
>  int main (void) { return 0; }
>  EOF
>    echo "Test compile: [$2]" >&AC_FD_CC
> -  gmp_cxxcompile="$1 conftest.cc >&AC_FD_CC"
> +  gmp_cxxcompile="$1 $LDFLAGS conftest.cc >&AC_FD_CC"
>    if AC_TRY_EVAL(gmp_cxxcompile); then
>      if test "$cross_compiling" = no; then
>        if AC_TRY_COMMAND([./a.out || ./b.out || ./a.exe || ./a_out.exe || ./conftest]); then :;
> @@ -2382,7 +2382,7 @@ for tmp_underscore in "" "_"; do
>  ${tmp_gsym_prefix}main$gmp_cv_asm_label_suffix
>  	addl	$ ${tmp_underscore}_GLOBAL_OFFSET_TABLE_, %ebx
>  EOF
> -  gmp_compile="$CCAS $CFLAGS $CPPFLAGS $lt_prog_compiler_pic conftest.s >&AC_FD_CC && $CC $CFLAGS $CPPFLAGS $lt_prog_compiler_pic conftest.$OBJEXT >&AC_FD_CC"
> +  gmp_compile="$CCAS $CFLAGS $CPPFLAGS $lt_prog_compiler_pic conftest.s >&AC_FD_CC && $CC $CFLAGS $CPPFLAGS $LDFLAGS $lt_prog_compiler_pic conftest.$OBJEXT >&AC_FD_CC"
>    if AC_TRY_EVAL(gmp_compile); then
>      if test "$tmp_underscore" = "_"; then
>        gmp_cv_asm_x86_got_underscore=yes
> @@ -3856,7 +3856,7 @@ main ()
>    return 0;
>  }
>  EOF
> -gmp_compile="$1 conftest.c"
> +gmp_compile="$1 $LDFLAGS conftest.c"
>  cc_for_build_works=no
>  if AC_TRY_EVAL(gmp_compile); then
>    if (./a.out || ./b.out || ./a.exe || ./a_out.exe || ./conftest) >&AC_FD_CC 2>&1; then
> @@ -3931,7 +3931,7 @@ main ()
>  }
>  EOF
>  for i in .exe ,ff8 ""; do
> -  gmp_compile="$CC_FOR_BUILD conftest.c -o conftest$i"
> +  gmp_compile="$CC_FOR_BUILD $LDFLAGS conftest.c -o conftest$i"
>    if AC_TRY_EVAL(gmp_compile); then
>      if (./conftest) 2>&AC_FD_CC; then
>        gmp_cv_prog_exeext_for_build=$i
> @@ -3966,7 +3966,7 @@ main (int argc, char **argv)
>    return 0;
>  }
>  EOF
> -gmp_compile="$CC_FOR_BUILD conftest.c"
> +gmp_compile="$CC_FOR_BUILD $LDFLAGS conftest.c"
>  if AC_TRY_EVAL(gmp_compile); then
>    gmp_cv_c_for_build_ansi=yes
>  else
> @@ -4007,7 +4007,7 @@ foo ()
>    return log (d);
>  }
>  EOF
> -gmp_compile="$CC_FOR_BUILD conftest.c -lm"
> +gmp_compile="$CC_FOR_BUILD $LDFLAGS conftest.c -lm"
>  if AC_TRY_EVAL(gmp_compile); then
>    gmp_cv_check_libm_for_build=-lm
>  else

Regards,
/Niels

-- 
Niels Möller. PGP-encrypted email is preferred. Keyid 368C6677.
Internet email is subject to wholesale government surveillance.


More information about the gmp-bugs mailing list