I came across a "gotcha" whilst trying to test the static implementation of libgfortran on PPC64-apple-darwin8.
Thanks to Tobias B for pointing me at 99% of the solution.

Probably the number of affected systems is small ;) - but, FWIW, here's HOWTO and a fix.

-----
If you host on {powerpc, i686}-apple-darwin8 and you want to static link (or check libgfortran) -m64 for PPC64 then this applies to you.

There is an incompatibility [presumably in ld64] between the default debug symbol generation (stabs) and what's required for linking/checking PPC64 on darwin8 ... this incompatibility "is not going to be fixed".

The specific crunch is that every -O3  torture test is compiled with -g
=> in gfortran this causes every -O3 torture test to fail when checking -m64.

----

The solution is to build the required code with -gdwarf-2, unfortunately the "-g" flag is hard-coded in a couple of relevant places:

(a) in "fortran-torture.exp" and in "gcc-dg.exp" (which is included in gfortran-dg.exp)
[ the change to gcc-dg.exp makes this non-local to gfortran ]

(b) in the top level configure (as a default C/CXX/FLAGS_FOR_TARGET).

The minimum change work-around is this:

1/ configure/make gcc with CFLAGS_FOR_TARGET = "-02 -gdwarf-2 - pipe" (and CXXFLAGS_FOR_TARGET the same)

2/ apply the following :

Index: gcc/testsuite/lib/gcc-dg.exp
===================================================================
--- gcc/testsuite/lib/gcc-dg.exp        (revision 136861)
+++ gcc/testsuite/lib/gcc-dg.exp        (working copy)
@@ -48,9 +48,15 @@
        { -O2 } \
        { -O3 -fomit-frame-pointer } \
        { -O3 -fomit-frame-pointer -funroll-loops } \
- { -O3 -fomit-frame-pointer -funroll-all-loops -finline- functions } \
-       { -O3 -g } \
-       { -Os } ]
+ { -O3 -fomit-frame-pointer -funroll-all-loops -finline- functions } ]
+
+       if { [istarget "*-*-darwin8"] } {
+       lappend DG_TORTURE_OPTIONS  { -O3 -gdwarf-2 }
+       } else {
+       lappend DG_TORTURE_OPTIONS  { -O3 -g }
+       }
+
+       lappend DG_TORTURE_OPTIONS { -Os }
 }

 global GCC_UNDER_TEST
Index: gcc/testsuite/lib/fortran-torture.exp
===================================================================
--- gcc/testsuite/lib/fortran-torture.exp       (revision 136861)
+++ gcc/testsuite/lib/fortran-torture.exp       (working copy)
@@ -73,9 +73,16 @@
        { -O2 } \
        { -O2 -fomit-frame-pointer -finline-functions } \
{ -O2 -fomit-frame-pointer -finline-functions -funroll- loops } \
-       { -O2 -fbounds-check } \
-       { -O3 -g } \
-       { -Os }
+       { -O2 -fbounds-check }
+
+       if { [istarget "*-*-darwin8"] } {
+       lappend options  { -O3 -gdwarf-2 }
+       } else {
+       lappend options  { -O3 -g }
+       }
+
+       lappend options { -Os }
+
     if { $test_tree_vectorize } {
        lappend options $vectorizer_options
     }


*************************************
COMPARISONs of make check-host with and without the changes

This is on darwin 8.11.0

*************************************
make check-host   (default, m32)
one extra pass, no regressions
*************************************

g++
-----
        no change

gcc
-----
one extra pass from using dwarf-2
FAIL: gcc.dg/pch/save-temps-1.c  -O3 -g  assembly comparison
PASS: gcc.dg/pch/save-temps-1.c  -O3 -gdwarf-2  assembly comparison

gfortran
----------
        no change

obj-c++
----------
        no change

obj-c
------
        no change


*************************************
make check-host   (m64) RUNTESTFLAGS="--target_board=unix/-m64"
69 extra passes, no regressions
*************************************

g++
------
one extra pass from using dwarf-2
FAIL: g++.old-deja/g++.eh/badalloc1.C execution test (-g)
PASS: g++.old-deja/g++.eh/badalloc1.C execution test (-gdwarf-2)

gcc
-----
one extra pass from using dwarf-2
FAIL: gcc.dg/pch/save-temps-1.c  -O3 -g  assembly comparison
PASS: gcc.dg/pch/save-temps-1.c  -O3 -gdwarf-2  assembly comparison

gfortran (every test with -O3 -g fails )
----------
67 extra passes using -gdwarf-2

                === gfortran Summary  (-g) ===

# of expected passes            26196
# of unexpected failures        85
# of expected failures          46
# of unsupported tests          59
/Volumes/SwapScratch/OS-source/gcc-44-build/n2n/gcc/testsuite/ gfortran/../../gfortran version 4.4.0 20080612 (experimental) (GCC)

                === gfortran Summary (-gdwarf-2)  ===

# of expected passes            26263
# of unexpected failures        18
# of expected failures          46
# of unsupported tests          59
/Volumes/SwapScratch/OS-source/gcc-44-build/n2n/gcc/testsuite/ gfortran/../../gfortran version 4.4.0 20080612 (experimental) (GCC)

obj-c++
----------
        no change

obj-c
------
        no change

----
I guess, there's one residual puzzle to me; from the doc. I'd understand that the -O3 optimizations are in the back end and therefore common to all the tools. However, this problem only really shows up to any significant extent with gfortran.

ttfn,
Iain

Reply via email to