Dear autoconf developer, The macro _AC_PROG_FC_V in lib/autoconf/fortran.m4 should first try -### instead of -v to detect linker options. The attached patch fixes this.
The problem is that gfortran -v runs the compiler/linker which might print warnings. Those warnings are harmless but can confuse the _AC_PROG_FC_V script. The GCC manual also suggests that -### should be used in shell scripts instead of -v. This problem was observed when compiling the R statistics package (http://www.r-project.org/) as 32-bit powerpc-unknown-linux-gnu application with 64-bit powerpc64-unknown-linux-gnu kernel. The userspace is a multilib installation. It has 32-bit libraries in /usr/lib and 64-bit libraries in /usr/lib64. I am using a pure 32-bit version of GCC which produces 32-bit code. See https://bugs.r-project.org/bugzilla3/show_bug.cgi?id=14865 and http://trac.sagemath.org/sage_trac/ticket/12787 ***** ./configure fails with: ***** checking build system type... powerpc-unknown-linux-gnu checking host system type... powerpc-unknown-linux-gnu [...] checking how to get verbose linking output from gfortran... -v checking for Fortran 77 libraries of gfortran... -L/home/jdemeyer/silius/sage-5.0.beta12-gcc-32/local/lib -L/home/jdemeyer/silius/sage-5.0.beta12-gcc-32/local/lib/gcc/powerpc-unknown-linux-gnu/4.6.3 -L/home/jdemeyer/silius/sage-5.0.beta12-gcc-32/local/lib/gcc/powerpc-unknown-linux-gnu/4.6.3/../../.. -lgfortran -lm /usr/lib64/libm.a /usr/lib64/libc.a checking how to get verbose linking output from gcc -std=gnu99... -v checking for C libraries of gcc -std=gnu99... -L/home/jdemeyer/silius/sage-5.0.beta12-gcc-32/local/lib -L/home/jdemeyer/silius/sage-5.0.beta12-gcc-32/local/lib/gcc/powerpc-unknown-linux-gnu/4.6.3 -L/home/jdemeyer/silius/sage-5.0.beta12-gcc-32/local/lib/gcc/powerpc-unknown-linux-gnu/4.6.3/../../.. -lgcc_s /usr/lib64/libc.a checking for dummy main to link with Fortran 77 libraries... unknown configure: error: in `/home/jdemeyer/silius/sage-5.0.beta12-gcc-32/R-rc': configure: error: linking to Fortran libraries from C fails See `config.log' for more details ***** config.log fragment: ***** configure:22749: checking for Fortran 77 libraries of gfortran configure:22772: gfortran -o conftest -g -O2 -v conftest.f Using built-in specs. Target: powerpc-unknown-linux-gnu Thread model: posix gcc version 4.6.3 (GCC) /home/jdemeyer/silius/sage-5.0.beta12-gcc-32/local/libexec/gcc/powerpc-unknown-linux-gnu/4.6.3/f951 conftest.f -ffixed-form -quiet -dumpb ase conftest.f -auxbase conftest -g -O2 -version -fintrinsic-modules-path /home/jdemeyer/silius/sage-5.0.beta12-gcc-32/local/lib/gcc/power pc-unknown-linux-gnu/4.6.3/finclude -o /tmp/ccoU4hEB.s GNU Fortran (GCC) version 4.6.3 (powerpc-unknown-linux-gnu) compiled by GNU C version 4.6.3, GMP version 5.0.1, MPFR version 3.1.0, MPC version 1.0.0dev GGC heuristics: --param ggc-min-expand=100 --param ggc-min-heapsize=131072 GNU Fortran (GCC) version 4.6.3 (powerpc-unknown-linux-gnu) compiled by GNU C version 4.6.3, GMP version 5.0.1, MPFR version 3.1.0, MPC version 1.0.0dev GGC heuristics: --param ggc-min-expand=100 --param ggc-min-heapsize=131072 as -mppc -many -o /tmp/cc0sbQr1.o /tmp/ccoU4hEB.s Reading specs from /home/jdemeyer/silius/sage-5.0.beta12-gcc-32/local/lib/libgfortran.spec rename spec lib to liborig /home/jdemeyer/silius/sage-5.0.beta12-gcc-32/local/libexec/gcc/powerpc-unknown-linux-gnu/4.6.3/collect2 --eh-frame-hdr -V -m elf32ppclinu x -dynamic-linker /lib/ld.so.1 -o conftest /usr/lib/crt1.o /usr/lib/crti.o /home/jdemeyer/silius/sage-5.0.beta12-gcc-32/local/lib/gcc/powe rpc-unknown-linux-gnu/4.6.3/crtbegin.o -L/home/jdemeyer/silius/sage-5.0.beta12-gcc-32/local/lib -L/home/jdemeyer/silius/sage-5.0.beta12-gc c-32/local/lib/gcc/powerpc-unknown-linux-gnu/4.6.3 -L/home/jdemeyer/silius/sage-5.0.beta12-gcc-32/local/lib/gcc/powerpc-unknown-linux-gnu/ 4.6.3/../../.. /tmp/cc0sbQr1.o -lgfortran -lm -lgcc_s -lgcc -lm -lgcc_s -lgcc -lc -lgcc_s -lgcc /home/jdemeyer/silius/sage-5.0.beta12-gcc- 32/local/lib/gcc/powerpc-unknown-linux-gnu/4.6.3/crtend.o /usr/lib/crtn.o GNU ld (GNU Binutils; SUSE Linux Enterprise 11) 2.20.0.20100122-0.7.9 Supported emulations: elf64ppc elf32ppclinux elf32ppc elf32ppcsim elf32_spu/usr/bin/ld: skipping incompatible /usr/lib64/libm.so when searching for -lm /usr/bin/ld: skipping incompatible /usr/lib64/libm.a when searching for -lm /usr/bin/ld: skipping incompatible /usr/lib64/libm.so when searching for -lm /usr/bin/ld: skipping incompatible /usr/lib64/libm.a when searching for -lm /usr/bin/ld: skipping incompatible /usr/lib64/libc.so when searching for -lc /usr/bin/ld: skipping incompatible /usr/lib64/libc.a when searching for -lc configure:22947: result: -L/home/jdemeyer/silius/sage-5.0.beta12-gcc-32/local/lib -L/home/jdemeyer/silius/sage-5.0.beta12-gcc-32/local/li b/gcc/powerpc-unknown-linux-gnu/4.6.3 -L/home/jdemeyer/silius/sage-5.0.beta12-gcc-32/local/lib/gcc/powerpc-unknown-linux-gnu/4.6.3/../../. . -lgfortran -lm /usr/lib64/libm.a /usr/lib64/libc.a ***** Notes ***** The "lib64" stuff should not be there, since there is nothing 64-bit about this build. It is caused by ld warnings. With -###, ld is not actually run and the problem disappears. Best wishes, Jeroen Demeyer
commit 5961f67b1eff70d80659aba5797297c8328788c5 Author: Jeroen Demeyer <jdeme...@cage.ugent.be> Date: Fri Jun 15 11:40:23 2012 +0200 _AC_PROG_FC_V: use -### instead of -v to detect linker options diff --git a/lib/autoconf/fortran.m4 b/lib/autoconf/fortran.m4 index 3803595..bd3c58e 100644 --- a/lib/autoconf/fortran.m4 +++ b/lib/autoconf/fortran.m4 @@ -574,10 +574,16 @@ esac # _AC_PROG_FC_V # ------------- # -# Determine the flag that causes the Fortran compiler to print -# information of library and object files (normally -v) +# Determine the flag that causes the Fortran compiler to print what +# it is doing: which library / object files are linked in. # Needed for _AC_FC_LIBRARY_FLAGS -# Some compilers don't accept -v (Lahey: (-)-verbose, xlf: -V, Fujitsu: -###) +# +# gfortran prefers -### for this. With -###, the compiler/linker is not +# actually run, it is printed to stderr what would happen. This is +# better than -v because running the compiler/linker might print +# warnings which confuse this script. +# +# Many other compilers use -v; Lahey uses (-)-verbose; xlf uses -V AC_DEFUN([_AC_PROG_FC_V], [_AC_FORTRAN_ASSERT()dnl AC_CACHE_CHECK([how to get verbose linking output from $[]_AC_FC[]], @@ -585,7 +591,7 @@ AC_CACHE_CHECK([how to get verbose linking output from $[]_AC_FC[]], [AC_COMPILE_IFELSE([AC_LANG_PROGRAM()], [ac_cv_prog_[]_AC_LANG_ABBREV[]_v= # Try some options frequently used verbose output -for ac_verb in -v -verbose --verbose -V -\#\#\#; do +for ac_verb in -\#\#\# -v -verbose --verbose -V; do _AC_PROG_FC_V_OUTPUT($ac_verb) # look for -l* and *.a constructs in the output for ac_arg in $ac_[]_AC_LANG_ABBREV[]_v_output; do