From ripley at stats.ox.ac.uk  Thu Nov 20 22:34:50 2008
From: ripley at stats.ox.ac.uk (Prof Brian Ripley)
Date: Thu, 20 Nov 2008 21:34:50 +0000 (GMT)
Subject: [Rd] Turning off compiler optimization
In-Reply-To: <8EB66ACA-70E3-4F4C-9F1E-695C44882179@mit.edu>
References: <8EB66ACA-70E3-4F4C-9F1E-695C44882179@mit.edu>
Message-ID: <alpine.LFD.2.00.0811202132190.12686@gannet.stats.ox.ac.uk>

Use .R/Makeconf: see 'R Installation and Administration' section 6.3.3.


On Thu, 20 Nov 2008, Michael Braun wrote:

> Hi.  I am writing some code in C that I would like to link into R.
>
> My Makevars file is:
>
> PKG_CPPFLAGS=-I/usr/local/include
> PKG_LIBS=-L/usr/local/lib -lgsl
> PKG_CFLAGS = -Wall -O0 -g -p -pg
>
> The source file is core.c,. and I am compiling using R CMD SHLIB core.c  The 
> output is
>
> gcc -arch x86_64 -O3 -g -p -std=gnu99 
> -I/Library/Frameworks/R.framework/Resources/include 
> -I/Library/Frameworks/R.framework/Resources/include/x86_64 
> -I/usr/local/include -I/usr/local/include   -Wall -O0 -g -p -pg -fPIC  -g -O2 
> -c core.c -o core.o
>
> gcc -arch x86_64 -O3 -g -p -std=gnu99 -dynamiclib 
> -Wl,-headerpad_max_install_names  -undefined dynamic_lookup -single_module 
> -multiply_defined suppress -L/usr/local/lib -o core.so core.o 
> -L/usr/local/lib -lgsl  -F/Library/Frameworks/R.framework/.. -framework R 
> -Wl,-framework -Wl,CoreFoundation
>
> I am running R 2.7.1 on a Mac Pro (Intel-based) with OS X 10.5.5.
>
> My problem is that, for debugging purposes, I would like to turn off compiler 
> optimization (so gdb stops telling me that values are temporarily unavailable 
> due to optimizations).  I thought I was doing that by putting the -O0 flag in 
> PKG_CFLAGS in the Makevars file.  But from the output, it looks like there is 
> still some optimization going on.  I would also like to avoid writing a Make 
> file from scratch, if at all possible.
>
> I looked through the documentation and archives, and was unable to find a 
> solution to this.  Can someone offer some assistance?
>
> Thanks,
>
> Michael
>
>
>
> -------------------------------------------
> Michael Braun
> Homer A. Burnell Career Development Professor, and
> 	Assistant Professor of Management Science (Marketing Group)
> MIT Sloan School of Management
> One Amherst St., E40-169
> Cambridge, MA 02142
> braunm at mit.edu
> 617-253-3436
>
> ______________________________________________
> R-devel at r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-devel

-- 
Brian D. Ripley,                  ripley at stats.ox.ac.uk
Professor of Applied Statistics,  http://www.stats.ox.ac.uk/~ripley/
University of Oxford,             Tel:  +44 1865 272861 (self)
1 South Parks Road,                     +44 1865 272866 (PA)
Oxford OX1 3TG, UK                Fax:  +44 1865 272595



[Rd] Turning off compiler optimization
Prof Brian Ripley