Bug 47493 - FAIL: gfortran.fortran-torture/execute/csqrt_1.f90 compilation
FAIL: gfortran.fortran-torture/execute/csqrt_1.f90 compilation
Status: RESOLVED INVALID
Product: gcc
Classification: Unclassified
Component: libfortran
4.6.0
: P3 normal
: ---
Assigned To: Not yet assigned to anyone
:
Depends on:
Blocks:
  Show dependency treegraph
 
Reported: 2011-01-27 15:17 UTC by John David Anglin
Modified: 2011-02-07 01:20 UTC (History)
1 user (show)

See Also:
Host: hppa-unknown-linux-gnu
Target: hppa-unknown-linux-gnu
Build: hppa-unknown-linux-gnu
Known to work:
Known to fail:
Last reconfirmed:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description John David Anglin 2011-01-27 15:17:46 UTC
Executing on host: /home/dave/gnu/gcc/objdir/gcc/testsuite/gfortran/../../gfortr
an -B/home/dave/gnu/gcc/objdir/gcc/testsuite/gfortran/../../ -B/home/dave/gnu/gc
c/objdir/hppa-linux-gnu/./libgfortran/ /home/dave/gnu/gcc/gcc/gcc/testsuite/gfor
tran.fortran-torture/execute/csqrt_1.f90  -w  -O0   -B/home/dave/gnu/gcc/objdir/
hppa-linux-gnu/./libgfortran/.libs -L/home/dave/gnu/gcc/objdir/hppa-linux-gnu/./
libgfortran/.libs -L/home/dave/gnu/gcc/objdir/hppa-linux-gnu/./libgfortran/.libs
 -L/home/dave/gnu/gcc/objdir/hppa-linux-gnu/./libiberty  -lm   -o /home/dave/gnu
/gcc/objdir/gcc/testsuite/gfortran/csqrt_1.x    (timeout = 300)
/tmp/ccY8Zsb4.o: In function `.LC9':
(.rodata+0x68): undefined reference to `_gfortran_specific__sqrt_r8'
collect2: ld returned 1 exit status
compiler exited with status 1
output is:
/tmp/ccY8Zsb4.o: In function `.LC9':
(.rodata+0x68): undefined reference to `_gfortran_specific__sqrt_r8'
collect2: ld returned 1 exit status

FAIL: gfortran.fortran-torture/execute/csqrt_1.f90 compilation,  -O0

dave@mx3210:~/gnu/gcc/objdir/gcc$ ./xgcc -B./ -v
Reading specs from ./specs
COLLECT_GCC=./xgcc
COLLECT_LTO_WRAPPER=./lto-wrapper
Target: hppa-linux-gnu
Configured with: ../gcc/configure --with-gnu-as --with-gnu-ld --enable-shared --prefix=/home/dave/opt/gnu/gcc/gcc-4.6.0 --with-local-prefix=/home/dave/opt/gnu --enable-threads=posix --enable-__cxa_atexit --build=hppa-linux-gnu --enable-clocale=gnu --enable-java-gc=boehm --without-cloog --without-ppl --enable-languages=c,c++,objc,fortran,obj-c++,java,ada
Thread model: posix
gcc version 4.6.0 20110125 (experimental) [trunk revision 169250] (GCC)
Comment 1 Tobias Burnus 2011-01-27 17:04:51 UTC
> (.rodata+0x68): undefined reference to `_gfortran_specific__sqrt_r8'

Can you run:
 nm libgfortran.a |grep _gfortran_specific__sqrt_
on my system that gives:

0000000000000000 T _gfortran_specific__sqrt_r4
0000000000000000 T _gfortran_specific__sqrt_r8
0000000000000000 T _gfortran_specific__sqrt_r10
0000000000000000 T _gfortran_specific__sqrt_r16
0000000000000000 T _gfortran_specific__sqrt_c4
0000000000000000 T _gfortran_specific__sqrt_c8
0000000000000000 T _gfortran_specific__sqrt_c10
0000000000000000 T _gfortran_specific__sqrt_c16

and I somehow expect that also HPPA has a double-precision sqrt ...

 * * *

The other question is: Why is that wrapper called and not directly __builtin_sqrt? In C that also works:


#include <stdio.h>
#include <math.h>

static void
myproc(double(*f)(double), double x)
{
  printf("%e: %e %e\n", x, f(x),sqrt(x));
}

main()
{
  myproc(__builtin_sqrt, 4.0);
  return 0;
}

Result:
  printf (&"%e: %e %e\n"[0], 4.0e+0, 2.0e+0, 2.0e+0);
  return 0;

While the Fortran equivalent produces:
  myproc (_gfortran_specific__sqrt_r8, &C.1537);
and
  D.1545_3 = f_2(D) (x_1(D));
  D.1547_5 = __builtin_sqrt (D.1546_4);

for

program main
  intrinsic dsqrt
  call myproc(dsqrt, 4.0d0)
contains
  subroutine myproc(f, x)
    procedure(dsqrt) f
    real(8), value :: x
    print *, x, f(x), dsqrt(x)
  end subroutine myproc
end program main

The big other question is: why is "myproc" is not inlined? (For -O3 (-fwhole-program, (-flto)).)
Comment 2 dave 2011-01-27 17:27:40 UTC
> http://gcc.gnu.org/bugzilla/show_bug.cgi?id=47493
> 
> Tobias Burnus <burnus at gcc dot gnu.org> changed:
> 
>            What    |Removed                     |Added
> ----------------------------------------------------------------------------
>                  CC|                            |burnus at gcc dot gnu.org
> 
> --- Comment #1 from Tobias Burnus <burnus at gcc dot gnu.org> 2011-01-27 17:04:51 UTC ---
> > (.rodata+0x68): undefined reference to `_gfortran_specific__sqrt_r8'
> 
> Can you run:
>  nm libgfortran.a |grep _gfortran_specific__sqrt_
> on my system that gives:

dave@mx3210:~/gnu/gcc/objdir/hppa-linux-gnu/libgfortran/.libs$ nm libgfortran.a |grep _gfortran_specific__sqrt_
00000000 T _gfortran_specific__sqrt_r4
00000000 T _gfortran_specific__sqrt_c4
00000000 T _gfortran_specific__sqrt_c8

I don't fully trust the kernel on this system.  I see in config.h:

/* libm includes sqrt */
/* #undef HAVE_SQRT */

I think the configure test probably failed due to a cache management problem,
although I didn't see anything the the system log.

Dave
Comment 3 Tobias Burnus 2011-01-27 19:01:07 UTC
(In reply to comment #2)
> > http://gcc.gnu.org/bugzilla/show_bug.cgi?id=47493
> I don't fully trust the kernel on this system.  I see in config.h:
> 
> /* libm includes sqrt */
> /* #undef HAVE_SQRT */
> 
> I think the configure test probably failed due to a cache management problem,
> although I didn't see anything the the system log.

Well, I then regard comment 0 as not a bug as I think configure is usually reliable...

Still, the question is why the _gfortran__sqrt_c8 -> __buildin_sqrt wrapper is needed at all and why no inlining is happening. (missed-optimization) The latter is probably a post-4.6 item ...
Comment 4 John David Anglin 2011-02-07 01:20:10 UTC
Cache issue.