From edcb6fb747a79674d5b4accbebf4cc1b6a2c2ad3 Mon Sep 17 00:00:00 2001 From: Dirk Eddelbuettel Date: Thu, 13 Nov 2025 15:41:00 -0600 Subject: [PATCH 1/5] Plugin uses "$(SHLIB_OPENMP_CFLAGS)" on macOS too, simplifies opnemp --- ChangeLog | 5 +++++ R/inline.R | 5 ++--- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/ChangeLog b/ChangeLog index 91bf5907..dc963f9d 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +2025-11-13 Dirk Eddelbuettel + + * R/inline.R (inlineCxxPlugin): No longer special-case macOS for + OpenMP but rely on "$(SHLIB_OPENMP_CFLAGS)" as everywhere else + 2025-11-04 Dirk Eddelbuettel * README.md: Minor edits diff --git a/R/inline.R b/R/inline.R index 02a6ee1c..547ea4a1 100644 --- a/R/inline.R +++ b/R/inline.R @@ -1,4 +1,4 @@ -## Copyright (C) 2010 - 2024 Dirk Eddelbuettel, Romain Francois and Douglas Bates +## Copyright (C) 2010 - 2025 Dirk Eddelbuettel, Romain Francois and Douglas Bates ## ## This file is part of RcppArmadillo. ## @@ -16,8 +16,7 @@ ## along with RcppArmadillo. If not, see . inlineCxxPlugin <- function(...) { - ismacos <- Sys.info()[["sysname"]] == "Darwin" - openmpflag <- if (ismacos) "" else "$(SHLIB_OPENMP_CFLAGS)" + openmpflag <- "$(SHLIB_OPENMP_CFLAGS)" plugin <- Rcpp::Rcpp.plugin.maker(include.before = "#include ", libs = paste(openmpflag, "$(LAPACK_LIBS) $(BLAS_LIBS) $(FLIBS)"), package = "RcppArmadillo") From 99e405d33e408868157b84200fac66eeb2bf342f Mon Sep 17 00:00:00 2001 From: Dirk Eddelbuettel Date: Thu, 13 Nov 2025 15:57:59 -0600 Subject: [PATCH 2/5] Silence whining on windows and limit it to legacy --- .../RcppArmadillo/config/RcppArmadilloConfig.h | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/inst/include/RcppArmadillo/config/RcppArmadilloConfig.h b/inst/include/RcppArmadillo/config/RcppArmadilloConfig.h index eecb7e7e..e5184fd4 100644 --- a/inst/include/RcppArmadillo/config/RcppArmadilloConfig.h +++ b/inst/include/RcppArmadillo/config/RcppArmadilloConfig.h @@ -1,9 +1,9 @@ // RcppArmadilloConfig.h: Rcpp/Armadillo glue // -// Copyright (C) 2010 - 2022 Dirk Eddelbuettel, Romain Francois and Douglas Bates -// Copyright (C) 2016 - 2022 George G. Vega Yon -// Copyright (C) 2017 - 2022 Serguei Sokol +// Copyright (C) 2010 - 2025 Dirk Eddelbuettel, Romain Francois and Douglas Bates +// Copyright (C) 2016 - 2025 George G. Vega Yon +// Copyright (C) 2017 - 2025 Serguei Sokol // // This file is part of RcppArmadillo. // @@ -99,7 +99,12 @@ // R can be built with its own Rlapack library, or use an external // one. Only the latter has zgesdd, a complex-valued SVD using divide-and-conquer // on Windows we do not assume ZGESDD - #define ARMA_CRIPPLED_LAPACK 1 + // + // Update 2025-Nov: R now generally has good enough LAPACK/BLAS, and newer Arma + // versions whine so protecting this now for use with Armadillo older than 15.* + #if defined(ARMA_SELECTED_LEGACY_VERSION) + #define ARMA_CRIPPLED_LAPACK 1 + #endif // on Windows we can now assume OpenMP with Rtools / gcc 4.9.3 // note that performance is said to still be poor // cf https://cran.r-project.org/doc/manuals/r-devel/R-admin.html#The-MinGW_002dw64-toolchain From 4c85a921959f2055f1a8967f7f9419e6d2a97b95 Mon Sep 17 00:00:00 2001 From: Dirk Eddelbuettel Date: Thu, 13 Nov 2025 15:58:34 -0600 Subject: [PATCH 3/5] Generalize OpenMP setup under macos as suggested by @coatless --- .../config/RcppArmadilloConfigGenerated.h.in | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) diff --git a/inst/include/RcppArmadillo/config/RcppArmadilloConfigGenerated.h.in b/inst/include/RcppArmadillo/config/RcppArmadilloConfigGenerated.h.in index c67db9bd..104feb25 100644 --- a/inst/include/RcppArmadillo/config/RcppArmadilloConfigGenerated.h.in +++ b/inst/include/RcppArmadillo/config/RcppArmadilloConfigGenerated.h.in @@ -1,7 +1,8 @@ // RcppArmadilloGenerated.h: Autoconf-updated file for LAPACK and OpenMP choices // -// Copyright (C) 2013 - 2021 Dirk Eddelbuettel +// Copyright (C) 2013 - 2025 Dirk Eddelbuettel +// 2025 James J. Balamuta // // This file is part of RcppArmadillo. // @@ -21,9 +22,19 @@ #ifndef RcppArmadillo__RcppArmadilloConfigGenerated__h #define RcppArmadillo__RcppArmadilloConfigGenerated__h -#ifndef ARMA_USE_OPENMP -// from configure test for OpenMP based on how R is configured, and whether g++ new enough -@ARMA_HAVE_OPENMP@ +// macOS special case as discussed in https://github.com/RcppCore/RcppArmadillo/issues/493 +#if !defined(ARMA_USE_OPENMP) + #if defined(__APPLE__) && defined(_OPENMP) + // User has OpenMP available, but check if they want it disabled + #ifndef RCPPARMA_MACOS_DISABLE_OPENMP + #define ARMA_USE_OPENMP 1 + #else + #define ARMA_DONT_USE_OPENMP 1 + #endif + #else + // from configure test for OpenMP based on how R is configured + @ARMA_HAVE_OPENMP@ + #endif #endif #endif From e113120a8d6ea7232beeda75321f46e356d89d17 Mon Sep 17 00:00:00 2001 From: Dirk Eddelbuettel Date: Thu, 13 Nov 2025 16:27:28 -0600 Subject: [PATCH 4/5] Refinements from code review --- ChangeLog | 6 ++++++ .../RcppArmadillo/config/RcppArmadilloConfigGenerated.h.in | 2 +- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/ChangeLog b/ChangeLog index dc963f9d..16c16f83 100644 --- a/ChangeLog +++ b/ChangeLog @@ -3,6 +3,12 @@ * R/inline.R (inlineCxxPlugin): No longer special-case macOS for OpenMP but rely on "$(SHLIB_OPENMP_CFLAGS)" as everywhere else + * inst/include/RcppArmadillo/config/RcppArmadilloConfigGenerated.h.in: + Refine macOS OpenMP detection, respect RCPPARMA_MACOS_DISABLE_OPENMP + + * inst/include/RcppArmadillo/config/RcppArmadilloConfig.h: + ARMA_CRIPPLED_LAPACK is only defined if 'LEGACY' Armadillo selected + 2025-11-04 Dirk Eddelbuettel * README.md: Minor edits diff --git a/inst/include/RcppArmadillo/config/RcppArmadilloConfigGenerated.h.in b/inst/include/RcppArmadillo/config/RcppArmadilloConfigGenerated.h.in index 104feb25..6a58437e 100644 --- a/inst/include/RcppArmadillo/config/RcppArmadilloConfigGenerated.h.in +++ b/inst/include/RcppArmadillo/config/RcppArmadilloConfigGenerated.h.in @@ -1,5 +1,5 @@ -// RcppArmadilloGenerated.h: Autoconf-updated file for LAPACK and OpenMP choices +// RcppArmadilloConfigGenerated.h: Autoconf-updated file for LAPACK and OpenMP choices // // Copyright (C) 2013 - 2025 Dirk Eddelbuettel // 2025 James J. Balamuta From 87508e83191b78b0ca0cf2cda8264023aa730e84 Mon Sep 17 00:00:00 2001 From: Dirk Eddelbuettel Date: Sat, 15 Nov 2025 06:36:04 -0600 Subject: [PATCH 5/5] Reword one DEFINE as discussed --- ChangeLog | 2 +- .../RcppArmadillo/config/RcppArmadilloConfigGenerated.h.in | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/ChangeLog b/ChangeLog index 16c16f83..b3886294 100644 --- a/ChangeLog +++ b/ChangeLog @@ -4,7 +4,7 @@ OpenMP but rely on "$(SHLIB_OPENMP_CFLAGS)" as everywhere else * inst/include/RcppArmadillo/config/RcppArmadilloConfigGenerated.h.in: - Refine macOS OpenMP detection, respect RCPPARMA_MACOS_DISABLE_OPENMP + Refine macOS OpenMP detection, respect RCPPARMADILLO_MACOS_DISABLE_OPENMP * inst/include/RcppArmadillo/config/RcppArmadilloConfig.h: ARMA_CRIPPLED_LAPACK is only defined if 'LEGACY' Armadillo selected diff --git a/inst/include/RcppArmadillo/config/RcppArmadilloConfigGenerated.h.in b/inst/include/RcppArmadillo/config/RcppArmadilloConfigGenerated.h.in index 6a58437e..9a05d376 100644 --- a/inst/include/RcppArmadillo/config/RcppArmadilloConfigGenerated.h.in +++ b/inst/include/RcppArmadillo/config/RcppArmadilloConfigGenerated.h.in @@ -26,7 +26,7 @@ #if !defined(ARMA_USE_OPENMP) #if defined(__APPLE__) && defined(_OPENMP) // User has OpenMP available, but check if they want it disabled - #ifndef RCPPARMA_MACOS_DISABLE_OPENMP + #ifndef RCPPARMADILLO_MACOS_DISABLE_OPENMP #define ARMA_USE_OPENMP 1 #else #define ARMA_DONT_USE_OPENMP 1