[R-pkg-devel] Compile issues on r-devel-linux-x86_64-debian-clang with OpenMP

Ivan Krylov |kry|ov @end|ng |rom d|@root@org
Mon May 27 09:23:01 CEST 2024


On Sun, 26 May 2024 17:57:17 -0500
Dirk Eddelbuettel <edd using debian.org> wrote:

> and we'd need something like this (untested)
> 
>    .plugins[["openmp"]] <- function() {
>        list(env =
> list(PKG_CXXFLAGS=Sys.getenv("SHLIB_OPENMP_CXXFLAGS, ""),
> PKG_LIBS=Sys.getenv("SHLIB_OPENMP_CXXFLAGS, ""))) }

From the documentation, it sounds like a good use for

# variables will be pre-loaded from Makeconf
Rcpp.plugin.maker(Makevars = '
 PKG_CXXFLAGS = $(SHLIB_OPENMP_CXXFLAGS)
 PKG_LIBS = $(SHLIB_OPENMP_CXXFLAGS)
')

...but I can't figure out where out$Makevars is used in Rcpp.

This could also be a use for R CMD config, but SHLIB_OPENMP_CXXFLAGS is
not currently on the list of variables to query:

# Makes use of implementation details, ignores user settings
make \
 R_HOME=/usr/lib/R R_SHARE_DIR=/usr/share/R/share \
 -f /usr/lib/R/etc/Makeconf -f /usr/share/R/share/make/config.mk \
 print VAR=SHLIB_OPENMP_CXXFLAGS
# => -fopenmp

R CMD config SHLIB_OPENMP_CXXFLAGS
# => ERROR: no information for variable 'SHLIB_OPENMP_CXXFLAGS'

Looking at RcppArmadillo:::inlineCxxPlugin itself, it seems that
there's no escaping, so Make expressions can be used directly inside
the environment variables:

registerPlugin('openmp', function() list(env = list(
 PKG_LIBS = '$(SHLIB_OPENMP_CXXFLAGS)',
 PKG_CPPFLAGS = '$(SHLIB_OPENMP_CXXFLAGS)'
)))

This is mandated by POSIX ("All other environment variables, including
those with null values, shall be used as macros") and seems to work in
OpenBSD make too.

-- 
Best regards,
Ivan



More information about the R-package-devel mailing list