From pauljohn32 at gmail.com  Wed Jan 20 20:31:07 2010
From: pauljohn32 at gmail.com (Paul Johnson)
Date: Wed, 20 Jan 2010 13:31:07 -0600
Subject: [Rd] R CMD INSTALL configure.args and CC customization
Message-ID: <13e802631001201131k43a66f2evf210214b59360deb@mail.gmail.com>

Hi, everybody.

I hope the new year is treating you well.

In a Rocks Cluster Linux system (that's Centos 5.2 based), I have
built R-2.10 and it runs well.

While fiddling with MPI libraries and R packages, I've noticed a few
little wrinkles.

This comes as no surprise to the veteran R programmers, but let me
share to the new guys the following gem:

There is a difference between . and -

Simple, and yet so vital!

install.packages inside R takes a period between "configure" and
"args", as in "configure.args=", while in the shell, the same option
specified to R CMD INSTALL wants a dash, as in "--configure-args=".
The "period" versus the "hyphen" was  killing me all morning!

When building Rmpi, I had to specify configure options to let R know
which MPI library to use. I *tried* to avoid that by forcing the
compiler to be "mpicc", not "gcc".   I believe that if one uses mpicc,
then the compiler really is gcc, but it is initiated with the INC and
LIB dirs set so that the configure  can find what it needs. But gcc
seems to be deeply glued to R installation of packages.

I find various posts in the r-help list in which people claim this should work:

CC=mpicc R CMD INSTALL ...

but it doesn't make a difference for me. The compiler that gets used
is gcc, no matter how many different ways I try to say it should be
mpicc:


$ CC=mpicc R CMD INSTALL
--configure-args=--with-mpi=/usr/lib64/openmpi/1.2.7-gcc
--configure-vars=CC=mpicc Rmpi_0.5-8.tar.gz
Password:
* installing to library '/share/apps/lib/R/site-library'
* installing *source* package 'Rmpi' ...
checking for gcc... gcc -m64 -std=gnu99
checking for C compiler default output file name... a.out
checking whether the C compiler works... yes
checking whether we are cross compiling... no
checking for suffix of executables...
checking for suffix of object files... o
checking whether we are using the GNU C compiler... yes
checking whether gcc -m64 -std=gnu99 accepts -g... yes
checking for gcc -m64 -std=gnu99 option to accept ISO C89... none needed
Trying to find mpi.h ...
Found in /usr/lib64/openmpi/1.2.7-gcc/include
Trying to find libmpi.so or libmpich.a ...
Found libmpi in /usr/lib64/openmpi/1.2.7-gcc/lib
checking for openpty in -lutil... yes
checking for main in -lpthread... yes
configure: creating ./config.status
config.status: creating src/Makevars
** libs
gcc -m64 -std=gnu99 -I/usr/include/R -DPACKAGE_NAME=\"\"
-DPACKAGE_TARNAME=\"\" -DPACKAGE_VERSION=\"\" -DPACKAGE_STRING=\"\"
-DPACKAGE_BUGREPORT=\"\" -I/usr/lib64/openmpi/1.2.7-gcc/include
-DMPI2 -DOPENMPI -I/usr/local/include    -fpic  -O2 -g -pipe -Wall
-Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector
--param=ssp-buffer-size=4 -m64 -mtune=generic -c RegQuery.c -o
RegQuery.o
gcc -m64 -std=gnu99 -I/usr/include/R -DPACKAGE_NAME=\"\"
-DPACKAGE_TARNAME=\"\" -DPACKAGE_VERSION=\"\" -DPACKAGE_STRING=\"\"
-DPACKAGE_BUGREPORT=\"\" -I/usr/lib64/openmpi/1.2.7-gcc/include
-DMPI2 -DOPENMPI -I/usr/local/include    -fpic  -O2 -g -pipe -Wall
-Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector
--param=ssp-buffer-size=4 -m64 -mtune=generic -c Rmpi.c -o Rmpi.o
gcc -m64 -std=gnu99 -I/usr/include/R -DPACKAGE_NAME=\"\"
-DPACKAGE_TARNAME=\"\" -DPACKAGE_VERSION=\"\" -DPACKAGE_STRING=\"\"
-DPACKAGE_BUGREPORT=\"\" -I/usr/lib64/openmpi/1.2.7-gcc/include
-DMPI2 -DOPENMPI -I/usr/local/include    -fpic  -O2 -g -pipe -Wall
-Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector
--param=ssp-buffer-size=4 -m64 -mtune=generic -c conversion.c -o
conversion.o
gcc -m64 -std=gnu99 -I/usr/include/R -DPACKAGE_NAME=\"\"
-DPACKAGE_TARNAME=\"\" -DPACKAGE_VERSION=\"\" -DPACKAGE_STRING=\"\"
-DPACKAGE_BUGREPORT=\"\" -I/usr/lib64/openmpi/1.2.7-gcc/include
-DMPI2 -DOPENMPI -I/usr/local/include    -fpic  -O2 -g -pipe -Wall
-Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector
--param=ssp-buffer-size=4 -m64 -mtune=generic -c internal.c -o
internal.o
gcc -m64 -std=gnu99 -shared -L/usr/local/lib64 -o Rmpi.so RegQuery.o
Rmpi.o conversion.o internal.o -L/usr/lib64/openmpi/1.2.7-gcc/lib
-lmpi -lutil -lpthread -L/usr/lib64/R/lib -lR
** R
** demo
** inst
** preparing package for lazy loading
** help
*** installing help indices
** building package indices ...
* DONE (Rmpi)
======================

The same effect (or lack thereof) can be had with configure.vars in
install.packages:

> install.packages("Rmpi", configure.args="--with-mpi=/usr/lib64/openmpi/1.2.7-gcc", configure.vars="CC=mpicc")
Warning in install.packages("Rmpi", configure.args =
"--with-mpi=/usr/lib64/openmpi/1.2.7-gcc",  :
  argument 'lib' is missing: using '/share/apps/lib/R/site-library'
--- Please select a CRAN mirror for use in this session ---
Loading Tcl/Tk interface ... done
trying URL 'http://cran.mirrors.hoobly.com/src/contrib/Rmpi_0.5-8.tar.gz'
Content type 'application/x-gzip' length 87528 bytes (85 Kb)
opened URL
==================================================
downloaded 85 Kb

* installing *source* package 'Rmpi' ...
checking for gcc... gcc -m64 -std=gnu99
checking for C compiler default output file name... a.out
checking whether the C compiler works... yes
checking whether we are cross compiling... no
checking for suffix of executables...
checking for suffix of object files... o
checking whether we are using the GNU C compiler... yes
checking whether gcc -m64 -std=gnu99 accepts -g... yes
checking for gcc -m64 -std=gnu99 option to accept ISO C89... none needed
Trying to find mpi.h ...
Found in /usr/lib64/openmpi/1.2.7-gcc/include
Trying to find libmpi.so or libmpich.a ...
Found libmpi in /usr/lib64/openmpi/1.2.7-gcc/lib
checking for openpty in -lutil... yes
checking for main in -lpthread... yes
configure: creating ./config.status
config.status: creating src/Makevars
** libs
gcc -m64 -std=gnu99 -I/usr/include/R -DPACKAGE_NAME=\"\"
-DPACKAGE_TARNAME=\"\" -DPACKAGE_VERSION=\"\" -DPACKAGE_STRING=\"\"
-DPACKAGE_BUGREPORT=\"\" -I/usr/lib64/openmpi/1.2.7-gcc/include
-DMPI2 -DOPENMPI -I/usr/local/include    -fpic  -O2 -g -pipe -Wall
-Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector
--param=ssp-buffer-size=4 -m64 -mtune=generic -c RegQuery.c -o
RegQuery.o
gcc -m64 -std=gnu99 -I/usr/include/R -DPACKAGE_NAME=\"\"
-DPACKAGE_TARNAME=\"\" -DPACKAGE_VERSION=\"\" -DPACKAGE_STRING=\"\"
-DPACKAGE_BUGREPORT=\"\" -I/usr/lib64/openmpi/1.2.7-gcc/include
-DMPI2 -DOPENMPI -I/usr/local/include    -fpic  -O2 -g -pipe -Wall
-Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector
--param=ssp-buffer-size=4 -m64 -mtune=generic -c Rmpi.c -o Rmpi.o
gcc -m64 -std=gnu99 -I/usr/include/R -DPACKAGE_NAME=\"\"
-DPACKAGE_TARNAME=\"\" -DPACKAGE_VERSION=\"\" -DPACKAGE_STRING=\"\"
-DPACKAGE_BUGREPORT=\"\" -I/usr/lib64/openmpi/1.2.7-gcc/include
-DMPI2 -DOPENMPI -I/usr/local/include    -fpic  -O2 -g -pipe -Wall
-Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector
--param=ssp-buffer-size=4 -m64 -mtune=generic -c conversion.c -o
conversion.o
gcc -m64 -std=gnu99 -I/usr/include/R -DPACKAGE_NAME=\"\"
-DPACKAGE_TARNAME=\"\" -DPACKAGE_VERSION=\"\" -DPACKAGE_STRING=\"\"
-DPACKAGE_BUGREPORT=\"\" -I/usr/lib64/openmpi/1.2.7-gcc/include
-DMPI2 -DOPENMPI -I/usr/local/include    -fpic  -O2 -g -pipe -Wall
-Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector
--param=ssp-buffer-size=4 -m64 -mtune=generic -c internal.c -o
internal.o
gcc -m64 -std=gnu99 -shared -L/usr/local/lib64 -o Rmpi.so RegQuery.o
Rmpi.o conversion.o internal.o -L/usr/lib64/openmpi/1.2.7-gcc/lib
-lmpi -lutil -lpthread -L/usr/lib64/R/lib -lR
** R
** demo
** inst
** preparing package for lazy loading
** help
*** installing help indices
** building package indices ...
* DONE (Rmpi)


-- 
Paul E. Johnson
Professor, Political Science
1541 Lilac Lane, Room 504
University of Kansas



[Rd] R CMD INSTALL configure.args and CC customization
Paul Johnson