-
Notifications
You must be signed in to change notification settings - Fork 55
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
error Rlog1p #330
error Rlog1p #330
Conversation
On ``` R version 4.0.3 (2020-10-10) Platform: aarch64-apple-darwin20.0.0 (64-bit) Apple clang version 12.0.0 (clang-1200.0.32.29) Target: arm64-apple-darwin20.3.0 ``` The original source code fails with the message: ``` ../inst/include/armadillo_bits/eop_aux.hpp:98:115: error: no member named 'Rlog1p' in namespace 'std'; did you mean simply 'Rlog1p'? ``` which show a conflict of `std::log1p` with `#define log1p Rlog1p` in `Rmath.h`
Can you provide a short code example that triggers it? Can you state which RcppArmadillo version you used? Can you maybe try the one in the Rcpp drat repo too (which is based on Armadill 10.3-rc*)? Also, we may want to try to deal with this (if it all) at the |
@@ -22,6 +22,8 @@ | |||
//! use of the SFINAE approach to work around compiler limitations | |||
//! http://en.wikipedia.org/wiki/SFINAE | |||
|
|||
#undef log1p | |||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We almost surely do not want to unconditionally undefine something in the upstream sources.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This one is a workaround. I will make another PR if I succeed in changing the configure file instead of modifying the upstream armadillo code.
Here is my environment information:
> sessionInfo()
R version 4.0.3 (2020-10-10)
Platform: aarch64-apple-darwin20.0.0 (64-bit)
Running under: macOS 11.2
Matrix products: default
BLAS: /Users/xxx/miniforge3/envs/py38/lib/R/lib/libRblas.dylib
LAPACK: /Users/xxx/miniforge3/envs/py38/lib/R/lib/libRlapack.dylib
locale:
[1] C/UTF-8/C/C/C/C
attached base packages:
[1] stats graphics grDevices utils datasets methods base
loaded via a namespace (and not attached):
[1] compiler_4.0.3 tools_4.0.3
with (on Mac M1):
Configured with: --prefix=/Applications/Xcode.app/Contents/Developer/usr --with-gxx-include-dir=/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/c++/4.2.1
Apple clang version 12.0.0 (clang-1200.0.32.29)
Target: arm64-apple-darwin20.3.0
Thread model: posix
InstalledDir: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin
and
> packageVersion("Rcpp")
[1] ‘1.0.6’
I use the the latest CRAN/Github master version to install RcppArmadillo
, then it reports an error
arm64-apple-darwin20.0.0-clang++ -std=gnu++11 -I"/Users/yifanyang/miniforge3/envs/py38/lib/R/include" -DNDEBUG -I'/Users/yifanyang/miniforge3/envs/py38/lib/R/library/Rcpp/include' -D_FORTIFY_SOURCE=2 -isystem /Users/yifanyang/miniforge3/envs/py38/include -mmacosx-version-min=11.0 -I/Users/yifanyang/miniforge3/envs/py38/include -I../inst/include -fPIC -ftree-vectorize -fPIC -fPIE -fstack-protector-strong -O2 -pipe -stdlib=libc++ -fvisibility-inlines-hidden -fmessage-length=0 -isystem /Users/yifanyang/miniforge3/envs/py38/include -fdebug-prefix-map=/Users/runner/miniforge3/conda-bld/r-base-split_1615277992527/work=/usr/local/src/conda/r-base-4.0.3 -fdebug-prefix-map=/Users/yifanyang/miniforge3/envs/py38=/usr/local/src/conda-prefix -c RcppArmadillo.cpp -o RcppArmadillo.o
In file included from RcppArmadillo.cpp:21:
In file included from ../inst/include/RcppArmadillo.h:31:
In file included from ../inst/include/RcppArmadilloForward.h:49:
In file included from ../inst/include/armadillo:374:
../inst/include/armadillo_bits/eop_aux.hpp:97:124: error: no member named 'Rlog1p' in namespace 'std'; did you mean 'log1p'?
template<typename eT> arma_inline static typename arma_integral_only<eT>::result log1p (const eT x) { return eT( std::log1p(double(x)) ); }
~~~~~^~~~~
log1p
/Users/yifanyang/miniforge3/envs/py38/lib/R/include/Rmath.h:75:15: note: expanded from macro 'log1p'
#define log1p Rlog1p
^
/Users/yifanyang/miniforge3/envs/py38/bin/../include/c++/v1/cmath:435:9: note: 'log1p' declared here
using ::log1p;
^
In file included from RcppArmadillo.cpp:21:
In file included from ../inst/include/RcppArmadillo.h:31:
In file included from ../inst/include/RcppArmadilloForward.h:49:
In file included from ../inst/include/armadillo:374:
../inst/include/armadillo_bits/eop_aux.hpp:98:115: error: no member named 'Rlog1p' in namespace 'std'; did you mean simply 'Rlog1p'?
template<typename eT> arma_inline static typename arma_real_only<eT>::result log1p (const eT x) { return std::log1p(x); }
^~~~~~~~~~
Rlog1p
../inst/include/armadillo_bits/eop_aux.hpp:99:86: note: 'Rlog1p' declared here
template<typename eT> arma_inline static typename arma_cx_only<eT>::result log1p (const eT& x) { arma_ignore(x); return eT(0); }
^
/Users/yifanyang/miniforge3/envs/py38/lib/R/include/Rmath.h:75:15: note: expanded from macro 'log1p'
#define log1p Rlog1p
^
In file included from RcppArmadillo.cpp:21:
In file included from ../inst/include/RcppArmadillo.h:31:
In file included from ../inst/include/RcppArmadilloForward.h:49:
In file included from ../inst/include/armadillo:433:
../inst/include/armadillo_bits/fn_misc.hpp:170:21: error: no member named 'Rlog1p' in namespace 'std'; did you mean simply 'Rlog1p'?
return (log_a + std::log1p(std::exp(negdelta)));
^~~~~~~~~~
Rlog1p
/Users/yifanyang/miniforge3/envs/py38/lib/R/include/Rmath.h:74:9: note: 'Rlog1p' declared here
double Rlog1p(double);
^
3 errors generated.
make: *** [/Users/yifanyang/miniforge3/envs/py38/lib/R/etc/Makeconf:181: RcppArmadillo.o] Error 1
ERROR: compilation failed for package ‘RcppArmadillo’
You can also try to define |
I am sure we can sort this out. Don't run off modifying Can you please provide a short file with either (And that is precisely why we say here over at Rcpp to first file an issue to discuss matters before going off on pull requests which may just get rejected.) |
Here is an working example, with > code = ' void simple_test(){std::cout << "log1p(0) = " << std::log1p(0) << std::endl;}'
> cppFunction(plugins=c("cpp11"), code)
file8a824422791b.cpp:7:51: error: no member named 'Rlog1p' in namespace 'std'; did you mean simply 'Rlog1p'?
void simple_test(){std::cout << "log1p(0) = " << std::log1p(0) << std::endl;}
^~~~~~~~~~
Rlog1p
/Users/yifanyang/miniforge3/envs/py38/lib/R/include/Rmath.h:74:9: note: 'Rlog1p' declared here
double Rlog1p(double);
^
1 error generated. Update: I delete the misleading |
Sorry, don't see it: > Rcpp::cppFunction("double issue330(double x) { return std::log1p(x); }")
> issue330(1.234)
[1] 0.803794
> Ubuntu 20.10, g++ 10.2. Also passes with To me, you have not yet provided a reproducible example. |
I see |
I can also merrily call > Rcpp::cppFunction("double issue330r(double x) { return ::log1p(x); }")
> issue330r(1.234)
[1] 0.803794
> So maybe for your Conda use you need to |
May that's the reason. I tried on other platforms and got no error. I will try to make a clean install (of R) tomorrow and figure out why. I think it might be the way the compiler expands the macro causes the issue. Hence maybe this one is only an issue on Mac M1 miniforge3's R version (the tool chain on new Mac is a disaster for developers). I will close this one and report in other thread if there is anything interesting there. |
We should still try to get to it (not here but maybe as a Conda bug report) as it seems that a define gets in the way. |
The relevant part of Rmath.h: That is,
So the issue is most likely that your installed copy of R believes (correctly or incorrectly?) that your platform doesn't have Does compilation succeed if you set |
I also traced Manually change the
could compile the package successfully. That's why
R-4.0 is installed through a standard native ARM64 conda. For anyone with the same issue, I record the conda environment here:
|
You probably want to add it to |
This is an issue with conda-forge's R package. Please open an issue in https://github.com/conda-forge/r-base-feedstock and we'll get it fixed ASAP. |
Update Here on conda-forge. I recompiled R from the source, and this issue is solved. |
Good to know you're set; would probably still be good to help the conda folks get the package right. |
Binary packages are available. |
This is the only solution that works for me, thank you! |
On
The original source code fails with the message:
which shows a conflict of
std::log1p
with#define log1p Rlog1p
inRmath.h