Reputation: 11
I've encountered an error with Rcpp on Mac OS X (14.3.1, with the latest version of Xcode tools installed as of this post). I have used Rcpp extensively in the past but not in approximately one year, so I'm unsure when this compilation problem appeared.
Here is a reproducible example:
R version 4.3.3 (2024-02-29) -- "Angel Food Cake"
Copyright (C) 2024 The R Foundation for Statistical Computing
Platform: aarch64-apple-darwin20 (64-bit)
R is free software and comes with ABSOLUTELY NO WARRANTY.
You are welcome to redistribute it under certain conditions.
Type 'license()' or 'licence()' for distribution details.
Natural language support but running in an English locale
R is a collaborative project with many contributors.
Type 'contributors()' for more information and
'citation()' on how to cite R or R packages in publications.
Type 'demo()' for some demos, 'help()' for on-line help, or
'help.start()' for an HTML browser interface to help.
Type 'q()' to quit R.
> setwd('/Users/rbradley')
> library (Rcpp)
library (Rcpp)
> sourceCpp ("bug.cpp")
sourceCpp ("bug.cpp")
using C++ compiler: 'Apple clang version 15.0.0 (clang-1500.3.9.4)'
using SDK: 'MacOSX14.4.sdk'
clang++ -arch arm64 -std=gnu++17 -I"/Library/Frameworks/R.framework/Resources/include" -DNDEBUG -I"/Library/Frameworks/R.framework/Versions/4.3-arm64/Resources/library/Rcpp/include" -I"/Users/rbradley" -I/opt/R/arm64/include -fPIC -mtune=core2 -O0 -g -c bug.cpp -o bug.o
clang: error: unsupported argument 'core2' to option '-mtune='
make: *** [bug.o] Error 1
Error in sourceCpp("bug.cpp") : Error 1 occurred building shared library.
> sessionInfo()
sessionInfo()
R version 4.3.3 (2024-02-29)
Platform: aarch64-apple-darwin20 (64-bit)
Running under: macOS Sonoma 14.3.1
Matrix products: default
BLAS: /Library/Frameworks/R.framework/Versions/4.3-arm64/Resources/lib/libRblas.0.dylib
LAPACK: /Library/Frameworks/R.framework/Versions/4.3-arm64/Resources/lib/libRlapack.dylib; LAPACK version 3.11.0
locale:
[1] en_US.UTF-8/en_US.UTF-8/en_US.UTF-8/C/en_US.UTF-8/en_US.UTF-8
time zone: America/Los_Angeles
tzcode source: internal
attached base packages:
[1] grDevices utils datasets stats graphics methods base
other attached packages:
[1] Rcpp_1.0.12 dplyr_1.1.4 tidyr_1.3.1 readr_2.1.5 tibble_3.2.1 magrittr_2.0.3
loaded via a namespace (and not attached):
[1] utf8_1.2.4 R6_2.5.1 tidyselect_1.2.0 tzdb_0.4.0 glue_1.7.0 pkgconfig_2.0.3 generics_0.1.3 lifecycle_1.0.4 cli_3.6.2 fansi_1.0.6
[11] vctrs_0.6.5 compiler_4.3.3 tools_4.3.3 purrr_1.0.2 hms_1.1.3 pillar_1.9.0 rlang_1.1.3
The contents of the example file bug.cpp are:
#include <Rcpp.h>
using namespace Rcpp;
1;
I would be grateful for any help!
Upvotes: 1
Views: 226
Reputation: 1265
This is most likely a misconfiguration of your R installation. Try for example these commands (which I am doing in a container for R)
# R CMD config CC
gcc
# R CMD config CXX
g++ -std=gnu++17
# R CMD config CXXFLAGS
-g -O2 -ffile-prefix-map=/build/reproducible-path/r-base-4.3.3=. -fstack-protector-strong -fstack-clash-protection -Wformat -Werror=format-security -fcf-protection -Wdate-time -D_FORTIFY_SOURCE=2
#
I strongly suspect the options you are seeing come from either your R installation (so on Unix system do less $(R RHOME)/etc/Makeconf
to what it has) and/or some local configuration (such as ~/.R/Makevars
).
Rcpp does not have those options as you can quickly check at the repo:
core2
: https://github.com/search?q=repo%3ARcppCore%2FRcpp+core2&type=codemtune
: https://github.com/search?q=repo%3ARcppCore%2FRcpp+mtune&type=codeUpvotes: 1