Skip to content

[R-pkg-devel] How to R CMD build / check using LTO

4 messages · Paul Schmidt-Walter, Ivan Krylov, Gábor Csárdi +1 more

#
Dear Team,

My package 'LWFBrook90R' (https://github.com/pschmidtwalter/LWFBrook90R) 
was recently released on CRAN, but there are additional LTO Issues 
(https://www.stats.ox.ac.uk/pub/bdr/LTO/LWFBrook90R.out) with the 
compiled code, that need to be fixed soon.

I would like to reproduce the LTO warnings locally to see if possible 
solutions fix them, but dont know how to build and check with LTO. I am 
a newbie on Ubuntu 18.04 and hope to get help in this case.

There is information provided on how to configure R to reproduce the 
test (https://www.stats.ox.ac.uk/pub/bdr/LTO/README.txt), but I simply 
don't know how to "build with configure --enable-lto" and I also can't 
find the "config.site" file on my system to enable the respective 
compiler flags (see below).

Any help is appreciated!

Paul

---

LTO-Readme.txt:

Compilation logs for CRAN packages using x86_64 Fedora 32 Linux
(currently using GCC 10.1)built with configure --enable-lto and 
config.site:

CFLAGS="-g -O2 -Wall -pedantic -mtune=native"
FFLAGS="-g -O2 -mtune=native -Wall -pedantic"
CXXFLAGS="-g -O2 -Wall -pedantic -mtune=native -Wno-ignored-attributes 
-Wno-deprecated-declarations -Wno-parentheses"
AR=gcc-ar
RANLIB=gcc-ranlib

Look for [-Wlto-type-mismatch] warnings.? In some cases these involve
Fortran CHARACTER arguments where the length is passed as a 'hidden'
argument at the end, giving mismatches such as

sblas.f:3951:14: note: type ?long int? should match type ?void?

To work around these, define USE_FC_LEN_T and include Rconfig.h
(perhaps via R.h) before including BLAS.h or Lapack.h or your own
C proptypes for Fortran functions.? Then amend the actual calls to include
character length arguments: see the example of 
src/library/stats/src/rWishart.c

in the R sources.

---
#
On Wed, 17 Feb 2021 20:04:34 +0100
Paul Schmidt-Walter <paul.schmidt-walter at posteo.de> wrote:

            
"R Installation and Administration"
<https://cran.r-project.org/doc/manuals/r-release/R-admin.html>
contains a detailed set of instructions on how to compile R, including
section 2.7.4 about the use of LTO. Start with Appendix A, which lists
the packages you would need to install on your Ubuntu (basically,
build-essential, gfortran and the libraries mentioned there). Good luck!
#
You can use this Docker container:
https://hub.docker.com/repository/docker/rhub/debian-gcc-devel-lto

It is somewhat old, but chances are that it will reproduce the LTO
issues. I'll update it in a minute, anyway.

Gabor
On Wed, Feb 17, 2021 at 9:33 PM Ivan Krylov <krylov.r00t at gmail.com> wrote:
#
I suspect your problem is that, at least with the recent gnu
compilers, the Fortran 'c_logical' maps to the C _Bool, not the C int.

-Bill

On Wed, Feb 17, 2021 at 11:38 AM Paul Schmidt-Walter
<paul.schmidt-walter at posteo.de> wrote: