On May 20, 2009, at 4:32 , Seija Sirkiä wrote:
Hello again,
thank you for the comments, especially this one:
Prof Brian Ripley wrote:
> My concern would be that there are different cases that fail under
> Fortran compiler X and you are just sweeping the problem under the
> carpet.
It inspired us to go back to search the cause, and we've made some
progress: it's not the compiler, it's the compiler options. Simple,
but it took a while to figure that out since my experience in these
things is limited. When I build the package with default options
using INSTALL --build the dll is built with option -O3 as per R's
Makeconfig file. If I build the dll by hand, using gfortran with no
additional options and dyn.load it, everything works, and also with -
O and -Os. (No, I don't fully understand what the differences
between all these are, but that's another question).
I'm looking at chapter 5.5 in Writing R Extensions and also 6.3.3 in
R Installation and Administration but I can't figure out how to tell
"inside" my package that it is not to be built -O3 but with, say, -
O. I can see how to add flags in the package (and as far as I can
tell, if there are several optimization level flags the last in line
is used and that's the wrong one from my point of view), and also
how to override flags but only on my computer. Am I blind or am I
again attempting something I shouldn't?
This is not trivial, and how you do it is compiler dependent. A quick
fix was provided by Simon Urbanek a while back and it is _not_
portable, it assumes you are using GCC. It would be nice to have a
configure file that detects the compiler and optimization setting and
then re-sets the optimization level. I have thought about writing one,
but have never got around to do it.
Anyway, the fix is in the Makevars file from affxparser from
Bioconductor. Essentially, you use a Makevars file placed in the src
directory, containing
MYCXXFLAGS=-O0 -Wall
%.o: %.cpp
$(CXX) $(ALL_CPPFLAGS) $(ALL_CXXFLAGS) $(MYCXXFLAGS) -c $< -o
$@
Essentially this makes sure that -O0 (indicating no optimization) is
placed at the _end_ of the call to the compiler (this is for C++ files
btw), using the fact that if you have two -O* settings, the last one
overrides the first.
This ought to be easily adaptable to FORTRAN.
Kasper
______________________________________________
R-devel@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel