RcppCore / RcppParallel

High-level functions for parallel programming with Rcpp
http://rcppcore.github.io/RcppParallel/
171 stars 58 forks source link

Mac ARM installation failed #227

Open BenjaminDEMAILLE opened 1 month ago

BenjaminDEMAILLE commented 1 month ago

HI I have trouble to install qs2 from @traversc in https://github.com/qsbase/qs2/issues/3

He suggested me to ask you help.

When I install RcppParallel I got :

> remotes::install_github("RcppCore/RcppParallel",force = T)
Downloading GitHub repo RcppCore/RcppParallel@HEAD
── R CMD build ─────────────────────────────────────────────────────────────────────────────────────────────
✔  checking for file ‘/private/var/folders/k7/pk9ppb456l7c_qx99rf0sqhh0000gn/T/RtmpYjP1YW/remotes1af72d54dc10/RcppCore-RcppParallel-b478b62/DESCRIPTION’ ...
─  preparing ‘RcppParallel’:
✔  checking DESCRIPTION meta-information
─  cleaning src
─  running ‘cleanup’
─  checking for LF line-endings in source and make files and shell scripts (432ms)
─  checking for empty or unneeded directories
─  building ‘RcppParallel_5.1.9.9000.tar.gz’

* installing *source* package ‘RcppParallel’ ...
** using staged installation
** preparing to configure package 'RcppParallel' ...
*** configured file: 'R/tbb-autodetected.R.in' => 'R/tbb-autodetected.R'
*** configured file: 'src/Makevars.in' => 'src/Makevars'
*** configured file: 'src/install.libs.R.in' => 'src/install.libs.R'
** finished configure for package 'RcppParallel'
** libs
using C++ compiler: ‘Apple clang version 16.0.0 (clang-1600.0.26.3)’
using SDK: ‘MacOSX15.0.sdk’
(tbb) Building TBB using bundled sources ...
OS: macos
arch=arm64
compiler=clang
runtime=cc16.0.0_os15.0.1
tbb_build_prefix=macos_arm64_clang_cc16.0.0_os15.0.1
work_dir=/private/var/folders/k7/pk9ppb456l7c_qx99rf0sqhh0000gn/T/RtmpAcWiLW/R.INSTALL38ac364dd4fa/RcppParallel/src/build/macos_arm64_clang_cc16.0.0_os15.0.1_release
Created ../build/lib_release directory
make -C "../build/lib_release"  -r -f ../../build/Makefile.tbb cfg=release
../../build/Makefile.tbb:28: CONFIG: cfg=release arch=arm64 compiler=clang target=macos runtime=cc16.0.0_os15.0.1
clang++ -arch arm64 -I../inst/include -I/opt/homebrew/include -I/opt/R/arm64/include -o concurrent_hash_map.o -c -MMD -O2 -DUSE_PTHREAD  -stdlib=libc++ -arch arm64 -mmacosx-version-min=10.11  -fPIC  -D__TBB_BUILD=1 -Wall  -falign-functions=64 -Wall -g -O2 -DTBB_NO_LEGACY=1   -I../../src -I../../src/rml/include -I../../include ../../src/tbb/concurrent_hash_map.cpp
In file included from ../../src/tbb/concurrent_hash_map.cpp:17:
In file included from /opt/homebrew/include/tbb/concurrent_hash_map.h:17:
In file included from /opt/homebrew/include/tbb/../oneapi/tbb/concurrent_hash_map.h:21:
In file included from /opt/homebrew/include/tbb/../oneapi/tbb/detail/_utils.h:25:
/opt/homebrew/include/tbb/../oneapi/tbb/detail/_config.h:440:13: warning: TBB Warning: Support for C++98/03 is deprecated. Please use the compiler that supports C++11 features at least. [-W#pragma-messages]
  440 |     #pragma message("TBB Warning: Support for C++98/03 is deprecated. Please use the compiler that supports C++11 features at least.")
      |             ^
In file included from ../../src/tbb/concurrent_hash_map.cpp:17:
In file included from /opt/homebrew/include/tbb/concurrent_hash_map.h:17:
In file included from /opt/homebrew/include/tbb/../oneapi/tbb/concurrent_hash_map.h:21:
In file included from /opt/homebrew/include/tbb/../oneapi/tbb/detail/_utils.h:27:
/opt/homebrew/include/tbb/../oneapi/tbb/detail/_machine.h:58:1: warning: inline namespaces are a C++11 feature [-Wc++11-inline-namespace]
   58 | inline namespace d0 {
      | ^
/opt/homebrew/include/tbb/../oneapi/tbb/detail/_machine.h:129:1: error: unknown type name 'constexpr'
  129 | constexpr std::uintptr_t number_of_bits() {
      | ^
/opt/homebrew/include/tbb/../oneapi/tbb/detail/_machine.h:129:16: error: cannot define or redeclare 'uintptr_t' here because namespace 'd0' does not enclose namespace 'std'
  129 | constexpr std::uintptr_t number_of_bits() {
      |           ~~~~~^
/opt/homebrew/include/tbb/../oneapi/tbb/detail/_machine.h:129:16: warning: variable templates are a C++14 extension [-Wc++14-extensions]
/opt/homebrew/include/tbb/../oneapi/tbb/detail/_machine.h:129:25: error: expected ';' at end of declaration
  129 | constexpr std::uintptr_t number_of_bits() {
      |                         ^
      |                         ;
/opt/homebrew/include/tbb/../oneapi/tbb/detail/_machine.h:129:26: error: a type specifier is required for all declarations
  129 | constexpr std::uintptr_t number_of_bits() {
      |                          ^
/opt/homebrew/include/tbb/../oneapi/tbb/detail/_machine.h:130:19: error: use of undeclared identifier 'T'
  130 |     return sizeof(T) * CHAR_BIT;
      |                   ^
/opt/homebrew/include/tbb/../oneapi/tbb/detail/_machine.h:137:39: error: expected '(' for function-style cast or type construction
  137 |     return (number_of_bits<decltype(x)>() - 1) ^ gnu_builtins::clz(x);
      |                            ~~~~~~~~~~~^
/opt/homebrew/include/tbb/../oneapi/tbb/detail/_machine.h:137:41: error: expected expression
  137 |     return (number_of_bits<decltype(x)>() - 1) ^ gnu_builtins::clz(x);
      |                                         ^
In file included from ../../src/tbb/concurrent_hash_map.cpp:17:
In file included from /opt/homebrew/include/tbb/concurrent_hash_map.h:17:
In file included from /opt/homebrew/include/tbb/../oneapi/tbb/concurrent_hash_map.h:21:
/opt/homebrew/include/tbb/../oneapi/tbb/detail/_utils.h:31:1: warning: inline namespaces are a C++11 feature [-Wc++11-inline-namespace]
   31 | inline namespace d0 {
      | ^
/opt/homebrew/include/tbb/../oneapi/tbb/detail/_utils.h:34:18: warning: variadic templates are a C++11 extension [-Wc++11-extensions]
   34 | template<typename... T> void suppress_unused_warning(T&&...) {}
      |                  ^
/opt/homebrew/include/tbb/../oneapi/tbb/detail/_utils.h:34:55: warning: rvalue references are a C++11 extension [-Wc++11-extensions]
   34 | template<typename... T> void suppress_unused_warning(T&&...) {}
      |                                                       ^
/opt/homebrew/include/tbb/../oneapi/tbb/detail/_utils.h:40:1: error: unknown type name 'constexpr'
   40 | constexpr size_t max_nfs_size = 128;
      | ^
/opt/homebrew/include/tbb/../oneapi/tbb/detail/_utils.h:40:17: error: expected ';' after top level declarator
   40 | constexpr size_t max_nfs_size = 128;
      |                 ^
      |                 ;
/opt/homebrew/include/tbb/../oneapi/tbb/detail/_utils.h:41:1: error: unknown type name 'constexpr'
   41 | constexpr std::size_t max_nfs_size_exp = 7;
      | ^
/opt/homebrew/include/tbb/../oneapi/tbb/detail/_utils.h:41:16: error: cannot define or redeclare 'size_t' here because namespace 'd0' does not enclose namespace 'std'
   41 | constexpr std::size_t max_nfs_size_exp = 7;
      |           ~~~~~^
/opt/homebrew/include/tbb/../oneapi/tbb/detail/_utils.h:41:22: error: expected ';' after top level declarator
   41 | constexpr std::size_t max_nfs_size_exp = 7;
      |                      ^
      |                      ;
/opt/homebrew/include/tbb/../oneapi/tbb/detail/_utils.h:42:20: error: use of undeclared identifier 'max_nfs_size_exp'
   42 | static_assert(1 << max_nfs_size_exp == max_nfs_size, "max_nfs_size_exp must be a log2(max_nfs_size)");
      |                    ^
/opt/homebrew/include/tbb/../oneapi/tbb/detail/_utils.h:42:40: error: use of undeclared identifier 'max_nfs_size'
   42 | static_assert(1 << max_nfs_size_exp == max_nfs_size, "max_nfs_size_exp must be a log2(max_nfs_size)");
      |                                        ^
/opt/homebrew/include/tbb/../oneapi/tbb/detail/_utils.h:49:12: error: unknown type name 'constexpr'
   49 |     static constexpr std::int32_t LOOPS_BEFORE_YIELD = 16;
      |            ^
/opt/homebrew/include/tbb/../oneapi/tbb/detail/_utils.h:49:27: error: non-friend class member 'int32_t' cannot have a qualified name
   49 |     static constexpr std::int32_t LOOPS_BEFORE_YIELD = 16;
      |                      ~~~~~^
/opt/homebrew/include/tbb/../oneapi/tbb/detail/_utils.h:49:34: error: expected ';' at end of declaration list
   49 |     static constexpr std::int32_t LOOPS_BEFORE_YIELD = 16;
      |                                  ^
      |                                  ;
/opt/homebrew/include/tbb/../oneapi/tbb/detail/_utils.h:61:45: warning: deleted function definitions are a C++11 extension [-Wc++11-extensions]
   61 |     atomic_backoff(const atomic_backoff&) = delete;
      |                                             ^
/opt/homebrew/include/tbb/../oneapi/tbb/detail/_utils.h:62:56: warning: deleted function definitions are a C++11 extension [-Wc++11-extensions]
   62 |     atomic_backoff& operator=(const atomic_backoff&) = delete;
      |                                                        ^
/opt/homebrew/include/tbb/../oneapi/tbb/detail/_utils.h:66:22: error: use of undeclared identifier 'LOOPS_BEFORE_YIELD'
   66 |         if (count <= LOOPS_BEFORE_YIELD) {
      |                      ^
/opt/homebrew/include/tbb/../oneapi/tbb/detail/_utils.h:79:21: error: use of undeclared identifier 'LOOPS_BEFORE_YIELD'
   79 |         if (count < LOOPS_BEFORE_YIELD) {
      |                     ^
fatal error: too many errors emitted, stopping now [-ferror-limit=]
8 warnings and 20 errors generated.
make[2]: *** [concurrent_hash_map.o] Error 1
make[1]: *** [tbb_release] Error 2
clang++ -arch arm64 -std=gnu++17 -I"/Library/Frameworks/R.framework/Resources/include" -DNDEBUG -I../inst/include -I/opt/homebrew/include  -I/opt/R/arm64/include   -std=gnu++11 -DRCPP_PARALLEL_USE_TBB=1 -DTBB_SUPPRESS_DEPRECATED_MESSAGES=1 -fPIC  -falign-functions=64 -Wall -g -O2   -c init.cpp -o init.o
clang++ -arch arm64 -std=gnu++17 -I"/Library/Frameworks/R.framework/Resources/include" -DNDEBUG -I../inst/include -I/opt/homebrew/include  -I/opt/R/arm64/include   -std=gnu++11 -DRCPP_PARALLEL_USE_TBB=1 -DTBB_SUPPRESS_DEPRECATED_MESSAGES=1 -fPIC  -falign-functions=64 -Wall -g -O2   -c options.cpp -o options.o
clang++ -arch arm64 -std=gnu++17 -dynamiclib -Wl,-headerpad_max_install_names -undefined dynamic_lookup -L/Library/Frameworks/R.framework/Resources/lib -L/opt/R/arm64/lib -o RcppParallel.so init.o options.o -Ltbb/build/lib_release -ltbb -Wl,-rpath,@loader_path/../lib -L/opt/homebrew/lib -lgsl -lgslcblas -lm -F/Library/Frameworks/R.framework/.. -framework R -Wl,-framework -Wl,CoreFoundation
installing via 'install.libs.R' to /Library/Frameworks/R.framework/Versions/4.4-arm64/Resources/library/00LOCK-RcppParallel/00new/RcppParallel
** R
** inst
** byte-compile and prepare package for lazy loading
** help
*** installing help indices
** building package indices
** testing if installed package can be loaded from temporary location
Error: package or namespace load failed for ‘RcppParallel’:
 .onLoad failed in loadNamespace() for 'RcppParallel', details:
  call: dyn.load(file, DLLpath = DLLpath, ...)
  error: unable to load shared object '/Library/Frameworks/R.framework/Versions/4.4-arm64/Resources/library/00LOCK-RcppParallel/00new/RcppParallel/libs/RcppParallel.so':
  dlopen(/Library/Frameworks/R.framework/Versions/4.4-arm64/Resources/library/00LOCK-RcppParallel/00new/RcppParallel/libs/RcppParallel.so, 0x0006): symbol not found in flat namespace '__ZN3tbb10interface78internal15task_arena_base24internal_max_concurrencyEPKNS0_10task_arenaE'
Error: loading failed
Execution halted
ERROR: loading failed
* removing ‘/Library/Frameworks/R.framework/Versions/4.4-arm64/Resources/library/RcppParallel’
* restoring previous ‘/Library/Frameworks/R.framework/Versions/4.4-arm64/Resources/library/RcppParallel’
Warning messages:
1: In readLines(old_path) :
  incomplete final line found on '/Users/benjamin/.R/Makevars'
2: In i.p(...) :
  installation of package ‘/var/folders/k7/pk9ppb456l7c_qx99rf0sqhh0000gn/T//RtmpYjP1YW/file1af71e3bb5b0/RcppParallel_5.1.9.9000.tar.gz’ had non-zero exit status

How can I do ? thanks in advance

kevinushey commented 1 month ago

Works fine on my machine with the same version of Apple Clang.

$ clang --version
Apple clang version 16.0.0 (clang-1600.0.26.3)
Target: arm64-apple-darwin24.0.0
Thread model: posix
InstalledDir: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin
1: In readLines(old_path) :
  incomplete final line found on '/Users/benjamin/.R/Makevars'

There's probably something in their ~/.R/Makevars that's causing trouble here.

BenjaminDEMAILLE commented 1 month ago

Works fine on my machine with the same version of Apple Clang.

$ clang --version
Apple clang version 16.0.0 (clang-1600.0.26.3)
Target: arm64-apple-darwin24.0.0
Thread model: posix
InstalledDir: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin
1: In readLines(old_path) :
  incomplete final line found on '/Users/benjamin/.R/Makevars'

There's probably something in their ~/.R/Makevars that's causing trouble here.

Hi ! Can you show your Makevars ?

kevinushey commented 1 month ago

It's empty.

kevinushey commented 1 month ago

https://github.com/RcppCore/RcppParallel/commit/69d50f65fa6cfc8163cccf09c6a500e55f1e24a7 may fix this for you.

BenjaminDEMAILLE commented 1 month ago

69d50f6 may fix this for you.

It's for me or the developper ?