[R] Lazy-loading db setup in the R build process

Brian D Ripley ripley at stats.ox.ac.uk
Thu Dec 16 14:31:58 CET 2004


On 16 Dec 2004, Peter Dalgaard wrote:

> Simon Pickering <S.G.Pickering at bath.ac.uk> writes:
>
> > Hi All,
> >
> > I have read the article on lazy-loading in the September R news letter, and
> > think I have at least a vague grasp on what is happening.
> >
> > Am I right in thinking that, assuming I were using the same packages, I
> > could copy the .rdb & .rdx files from one installation of R (2.0.0) to
> > another?
> >
> > I ask this as I'm trying to cross-compile R (for ARM), and need to use R
> > itself to perform the lazy-loading db setup (and probably other things) as
> > part of the build process. Therefore I build a native version of R (x86) and
> > pass the path of the native R binary as R_EXE in the arm cross-build
> > Makefiles (in src/library and its sub-directories).
> >
> > This fails with the following error:
> >
> > | make[3]: Entering directory
> > `/home/simon/dev/bk/build/tmp/work/r-2.0.0-r0/R-2.0.0/src/library/base'
> > | building package 'base'
> > | mkdir -p -- ../../../library/base/demo mkdir -p --
> > | ../../../library/base/man Error in eval(expr, envir, enclos) : may
> > | already be using lazy loading on base Execution halted
> > | make[3]: *** [all] Error 1
> > | make[3]: Leaving directory
> > `/home/simon/dev/bk/build/tmp/work/r-2.0.0-r0/R-2.0.0/src/library/base'
> > | make[2]: *** [R] Error 1
> > | make[2]: Leaving directory
> > `/home/simon/dev/bk/build/tmp/work/r-2.0.0-r0/R-2.0.0/src/library'
> > | make[1]: *** [R] Error 1
> > | make[1]: Leaving directory
> > `/home/simon/dev/bk/build/tmp/work/r-2.0.0-r0/R-2.0.0/src'
> > | make: *** [R] Error 1
> >
> > My guess is that as the native version has already been built (and enabled
> > lazy-loading, etc.), it's not happy that I'm trying to enable it again.
> > Might this be the case?
> >
> > If so I can see a couple of possible options and I wonder if someone could
> > comment on what may or may not be possible to remedy the problem:
> >
> > * Run the native binary without loading its various database files (is this
> > is possible)

No.

> > * Delete the native database files so they can't be used and will be rebuilt
> > for the arm version without complaint

No.

> > * Simply copy the database files from the native build to the appropriate
> > locations in the cross-build (after patching the Makefiles to remove the
> > references to R_EXE), assuming that they should be portable across
> > architectures?
>
> The last one might work (try it and see). A little experiment,
> replacing Opteron base.rdb/rdx files with i386 counterparts indicated
> no immediate (!) ill effects.

That should certainly work: I would expect them to be identical for most
packages.

> The (first) thing that seems to bite your cross compile is in
> src/library/base/makebasedb.R:
>
>     baseFileBase <- file.path(.Library,"base","R","base")
>
>     if (file.info(baseFileBase)["size"] < 20000) # crude heuristic
>         stop("may already be using lazy loading on base");
>
> in which .Library refers to the running R process, and you probably
> want the cross-build library instead. I'm not sure that is the only
> place that needs changing though. (It *looks* like the tools for
> non-base packages take an argument that would allow the build library
> to be distinct from the the one used by the running R).

Take a look at cross-compiling (Windows under Linux).  We have failed to
make lazy loading of base work under cross-compilation, but do this for
all other packages.

I thought about endian differences (which I gather you have here), but I
don't think they matter as we use XDR format for the databases.

-- 
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




More information about the R-help mailing list