Skip to content
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

Rcpp broken by Mac OS Big Sur and Xcode 12.5 #1160

Closed
gevro opened this issue May 7, 2021 · 8 comments
Closed

Rcpp broken by Mac OS Big Sur and Xcode 12.5 #1160

gevro opened this issue May 7, 2021 · 8 comments

Comments

@gevro
Copy link

gevro commented May 7, 2021

Rcpp gives many compilation errors on new MacOS Big Sur 11.3.1 and Xcode 12.5.

#~/Desktop/hello.cpp
#include <Rcpp.h>
// [[Rcpp::export]]
void hello()
{
  Rprintf("Hello, world!\n");
}
> library(Rcpp)
> sourceCpp("~/Desktop/hello.cpp")
In file included from hello.cpp:1:
In file included from /Library/Frameworks/R.framework/Versions/4.0/Resources/library/Rcpp/include/Rcpp.h:27:
In file included from /Library/Frameworks/R.framework/Versions/4.0/Resources/library/Rcpp/include/RcppCommon.h:29:
In file included from /Library/Frameworks/R.framework/Versions/4.0/Resources/library/Rcpp/include/Rcpp/r/headers.h:67:
In file included from /Library/Frameworks/R.framework/Versions/4.0/Resources/library/Rcpp/include/Rcpp/platform/compiler.h:100:
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/c++/v1/cmath:321:9: error: no member named 'signbit' in the global namespace
using ::signbit;
      ~~^
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/c++/v1/cmath:322:9: error: no member named 'fpclassify' in the global namespace
using ::fpclassify;
      ~~^
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/c++/v1/cmath:323:9: error: no member named 'isfinite' in the global namespace; did you mean 'finite'?
using ::isfinite;
      ~~^
/usr/local/include/math.h:752:12: note: 'finite' declared here
extern int finite(double)
           ^
In file included from hello.cpp:1:
In file included from /Library/Frameworks/R.framework/Versions/4.0/Resources/library/Rcpp/include/Rcpp.h:27:
In file included from /Library/Frameworks/R.framework/Versions/4.0/Resources/library/Rcpp/include/RcppCommon.h:29:
In file included from /Library/Frameworks/R.framework/Versions/4.0/Resources/library/Rcpp/include/Rcpp/r/headers.h:67:
In file included from /Library/Frameworks/R.framework/Versions/4.0/Resources/library/Rcpp/include/Rcpp/platform/compiler.h:100:
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/c++/v1/cmath:324:9: error: no member named 'isinf' in the global namespace
using ::isinf;
      ~~^
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/c++/v1/cmath:325:9: error: no member named 'isnan' in the global namespace
using ::isnan;
      ~~^
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/c++/v1/cmath:326:9: error: no member named 'isnormal' in the global namespace
using ::isnormal;
      ~~^
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/c++/v1/cmath:327:9: error: no member named 'isgreater' in the global namespace
using ::isgreater;
      ~~^
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/c++/v1/cmath:328:9: error: no member named 'isgreaterequal' in the global namespace
using ::isgreaterequal;
      ~~^
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/c++/v1/cmath:329:9: error: no member named 'isless' in the global namespace
using ::isless;
      ~~^
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/c++/v1/cmath:330:9: error: no member named 'islessequal' in the global namespace
using ::islessequal;
      ~~^
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/c++/v1/cmath:331:9: error: no member named 'islessgreater' in the global namespace
using ::islessgreater;
      ~~^
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/c++/v1/cmath:332:9: error: no member named 'isunordered' in the global namespace
using ::isunordered;
      ~~^
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/c++/v1/cmath:333:9: error: no member named 'isunordered' in the global namespace
using ::isunordered;
      ~~^
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/c++/v1/cmath:339:9: error: no member named 'abs' in the global namespace; did you mean 'fabs'?
using ::abs;
      ~~^
/usr/local/include/math.h:417:15: note: 'fabs' declared here
extern double fabs(double);
              ^
In file included from hello.cpp:1:
In file included from /Library/Frameworks/R.framework/Versions/4.0/Resources/library/Rcpp/include/Rcpp.h:27:
In file included from /Library/Frameworks/R.framework/Versions/4.0/Resources/library/Rcpp/include/RcppCommon.h:29:
In file included from /Library/Frameworks/R.framework/Versions/4.0/Resources/library/Rcpp/include/Rcpp/r/headers.h:67:
In file included from /Library/Frameworks/R.framework/Versions/4.0/Resources/library/Rcpp/include/Rcpp/platform/compiler.h:100:
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/c++/v1/cmath:644:26: error: no template named 'numeric_limits'
    bool _FloatBigger = (numeric_limits<_FloatT>::digits > numeric_limits<_IntT>::digits),
                         ^
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/c++/v1/cmath:644:60: error: no template named 'numeric_limits'
    bool _FloatBigger = (numeric_limits<_FloatT>::digits > numeric_limits<_IntT>::digits),
                                                           ^
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/c++/v1/cmath:645:18: error: no template named 'numeric_limits'
    int _Bits = (numeric_limits<_IntT>::digits - numeric_limits<_FloatT>::digits)>
                 ^
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/c++/v1/cmath:645:50: error: no template named 'numeric_limits'
    int _Bits = (numeric_limits<_IntT>::digits - numeric_limits<_FloatT>::digits)>
                                                 ^
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/c++/v1/cmath:650:17: error: no template named 'numeric_limits'
  static_assert(numeric_limits<_FloatT>::radix == 2, "FloatT has incorrect radix");
                ^
fatal error: too many errors emitted, stopping now [-ferror-limit=]
20 errors generated.
make: *** [hello.o] Error 1
clang++ -I"/Library/Frameworks/R.framework/Resources/include" -DNDEBUG   -I"/Library/Frameworks/R.framework/Versions/4.0/Resources/library/Rcpp/include" -I"/Users/evrong01/Desktop" -I/usr/local/include   -fPIC  -Wall -g -O2  -c hello.cpp -o hello.o
Error in sourceCpp("~/Desktop/hello.cpp") : 
  Error 1 occurred building shared library.

Uninstalling and re-installing Xcode does not fix the problem. Every other possible way of installing and reinstalling xcode command line tools does not help.

@eddelbuettel
Copy link
Member

eddelbuettel commented May 7, 2021

@coatless @kevinushey and/or other macOS users: can you chime in?

We do have the pinned RcppArmadillo issue #268 at RcppCore/RcppArmadillo#268 but nothing for Rcpp. Maybe we need something to guide users in need who mistakenly think our code was a fault (and who cannot seem to even look at CRAN status results for Rcpp which beg to differ too...

@gevro
Copy link
Author

gevro commented May 7, 2021

Hi, Following the instructions on that post (though they're a little out of date) does not fix the problem. This issue occurred right after upgrading to Big Sur and Xcode 12.5. I suspect some issue in the automatic way these and/or xcode-command line tools are configured. I agree with your comment that it's not a bug in Rcpp, but I assume this issue is still relevant to Rcpp users who will likely experience this once they upgrade their OS.

@coatless
Copy link
Contributor

coatless commented May 7, 2021

Traveling at the moment. But, I can say that the macOS build is a okay with Rcpp. This is a local build issue.

@coatless
Copy link
Contributor

coatless commented May 7, 2021

You are using Xcode instead of the Xcode CLI based on the compilation statements. Are you sure you setup the CLI tools?

The path should be

'''sh

/Library/Developer/CommandLineTools
'''

not

/Applications/Xcode.app

Check path with

xcode-select --print-path

@gevro
Copy link
Author

gevro commented May 7, 2021

Hi, Yes I installed Xcode CLI:

$ xcode-select --install
xcode-select: error: command line tools are already installed, use "Software Update" to install updates

$ xcode-select -p
/Applications/Xcode.app/Contents/Developer

Is that not the correct configuration? That is the default configuration after uninstalling and re-installing Xcode 12.5 on Big Sur.

But I think I found the problem. Brew installed various files and symlinks in /usr/local/include. The /usr/local/include path was searched first during compilation and conflicted with other headers in the Xcode library paths. Deleting /usr/local/include and reinstalling Xcode and basic brew packages (but not brew packages for gcc and other compilers) seems to have fixed the problem.

So the problem was a conflict between brew and Xcode.

@eddelbuettel
Copy link
Member

Closing this as it was a local setup issue. Thanks all.

@coatless
Copy link
Contributor

coatless commented May 8, 2021

For the future googler, it is ill-advised to use the homebrew (brew) build of R, e.g. brew install r, with binary versions of CRAN packages. Moreover, the compiler instructions are written for the official R build released by the CRAN team; not the brew build.

If using homebrew is a requirement, then a much better idea is to use the cask version of R, e.g. brew cask install r. The cask version "wraps" the official installer from CRAN's build machines instead of compiling R from the source.


First, note that you are using brew, not the official R binary. So, this is a "you break it; you own it" moment.

Secondly, regarding the problem on compilation tools used, the path issue would likely get picked up.
if you run:

brew doctor

Let's say homebrew isn't installed, but you were using Xcode.app for heavy macOS development instead of CommandLineTools. This can be picked programmatically up by typing in Terminal:

xcode-select --print-path

If the path is:

/Applications/Xcode.app

This indicates that the build toolchain is using Xcode-related suite of compilers. This needs to be switched to using the Xcode CLT. The switch is done in Terminal by typing:

sudo xcode-select -s /Library/Developer/CommandLineTools

@gevro
Copy link
Author

gevro commented May 10, 2021

Note also that in my case it was not a brew R installation that was the problem. I was using standard R. It was brew installation of other packages that put files in /usr/local/include that conflicted with Xcode. I don't know exactly which brew package it was, but it wasn't R, because I didn't have a brew R installation. It may have been gcc, or something like that.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants