RcppCore/RcppParallel

5.1.1 Fails to install on M1

Closed this issue · 12 comments

I get:

* installing *source* package ‘RcppParallel’ ...
** package ‘RcppParallel’ successfully unpacked and MD5 sums checked
** using staged installation
** preparing to configure package 'RcppParallel' ...
*** configured file: 'src/Makevars.in' => 'src/Makevars'
** finished configure for package 'RcppParallel'
** libs
Using bundled TBB library ...
cp: tbb/build/lib_release/libtbb*.*: No such file or directory
make: *** [tbb] Error 1
ERROR: compilation failed for package ‘RcppParallel’

5.1.1-9000 from github gives me:

In file included from ../../src/tbb/tools_api/ittnotify_static.c:17:
../../src/tbb/tools_api/ittnotify_config.h:334:12: error: use of undeclared identifier '__TBB_machine_fetchadd4'
    return __TBB_machine_fetchadd4(ptr, 1) + 1L;
           ^
1 error generated.
make[2]: *** [itt_notify.o] Error 1
make[1]: *** [tbb_release] Error 2
clang++ -arch arm64 -std=gnu++14 -I"/Library/Frameworks/R.framework/Resources/include" -DNDEBUG -I../inst/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++14 -I"/Library/Frameworks/R.framework/Resources/include" -DNDEBUG -I../inst/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++14 -dynamiclib -Wl,-headerpad_max_install_names -undefined dynamic_lookup -single_module -multiply_defined suppress -L/Library/Frameworks/R.framework/Resources/lib -L/opt/R/arm64/lib -o RcppParallel.so init.o options.o -F/Library/Frameworks/R.framework/.. -framework R -Wl,-framework -Wl,CoreFoundation
installing via 'install.libs.R' to /Users/x/Library/R/arm64/4.1/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 '/Users/amos.elberg/Library/R/arm64/4.1/library/00LOCK-RcppParallel/00new/RcppParallel/libs/RcppParallel.so':
  dlopen(/Users/x/Library/R/arm64/4.1/library/00LOCK-RcppParallel/00new/RcppParallel/libs/RcppParallel.so, 6): Symbol not found: __ZN3tbb10interface78internal15task_arena_base24internal_max_concurrencyEPKNS0_10task_arenaE
  Referenced from: /Users/x/Library/R/arm64/4.1/library/00LOCK-RcppParallel/00new/RcppParallel/libs/RcppParallel.so
  Expected in: flat namespace
 in /Users/x/Library/R/arm64/4.1/library/00LOCK-RcppParallel/00new/RcppParallel/libs/RcppParallel.so
Error: loading failed
Execution halted
ERROR: loading failed

Works for me. How did you install R? Are you using an x86_64 or arm64 R binary?

You also truncated the output. What is the full output from the TBB compilation?

I'm using the arm64 binary installed from mac.r-project.org.

The full output from the github version is as below:

> devtools::install_github("RcppCore/RcppParallel")
Downloading GitHub repo RcppCore/RcppParallel@HEAD
✓  checking for file ‘/private/var/folders/3y/l30nscjn5k79v562nw43qkg40000gq/T/RtmpV27mEi/remotes6a785b5905d0/RcppCore-RcppParallel-ae9fc22/DESCRIPTION’ ...
─  preparing ‘RcppParallel’:
✓  checking DESCRIPTION meta-information ...
─  cleaning src
─  running ‘cleanup’
─  checking for LF line-endings in source and make files and shell scripts (375ms)
─  checking for empty or unneeded directories
─  building ‘RcppParallel_5.1.1-9000.tar.gz’
   
Installing package into ‘/Users/x/Library/R/arm64/4.1/library’
(as ‘lib’ is unspecified)
* installing *source* package ‘RcppParallel’ ...
** using staged installation
** preparing to configure package 'RcppParallel' ...
*** configured file: 'src/Makevars.in' => 'src/Makevars'
** finished configure for package 'RcppParallel'
** libs
(tbb) Using bundled TBB library ...
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=intel64 compiler=clang target=macos runtime=cc12.0.0_os11.2.3
clang++ -arch arm64 -I../inst/include -I/opt/R/arm64/include -o concurrent_hash_map.o -c -MMD -O2 -DUSE_PTHREAD -DDO_ITT_NOTIFY -stdlib=libc++ -m64 -mrtm -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
clang: warning: argument unused during compilation: '-mrtm' [-Wunused-command-line-argument]
clang++ -arch arm64 -I../inst/include -I/opt/R/arm64/include -o concurrent_queue.o -c -MMD -O2 -DUSE_PTHREAD -DDO_ITT_NOTIFY -stdlib=libc++ -m64 -mrtm -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_queue.cpp
clang: warning: argument unused during compilation: '-mrtm' [-Wunused-command-line-argument]
clang++ -arch arm64 -I../inst/include -I/opt/R/arm64/include -o concurrent_vector.o -c -MMD -O2 -DUSE_PTHREAD -DDO_ITT_NOTIFY -stdlib=libc++ -m64 -mrtm -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_vector.cpp
clang: warning: argument unused during compilation: '-mrtm' [-Wunused-command-line-argument]
clang++ -arch arm64 -I../inst/include -I/opt/R/arm64/include -o dynamic_link.o -c -MMD -O2 -DUSE_PTHREAD -DDO_ITT_NOTIFY -stdlib=libc++ -m64 -mrtm -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/dynamic_link.cpp
clang: warning: argument unused during compilation: '-mrtm' [-Wunused-command-line-argument]
clang++ -arch arm64 -I../inst/include -I/opt/R/arm64/include -o itt_notify.o -c -MMD -O2 -DUSE_PTHREAD -DDO_ITT_NOTIFY -stdlib=libc++ -m64 -mrtm -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/itt_notify.cpp
clang: warning: argument unused during compilation: '-mrtm' [-Wunused-command-line-argument]
In file included from ../../src/tbb/itt_notify.cpp:43:
In file included from ../../src/tbb/tools_api/ittnotify_static.c:17:
../../src/tbb/tools_api/ittnotify_config.h:334:12: error: use of undeclared identifier '__TBB_machine_fetchadd4'
    return __TBB_machine_fetchadd4(ptr, 1) + 1L;
           ^
1 error generated.
make[2]: *** [itt_notify.o] Error 1
make[1]: *** [tbb_release] Error 2
clang++ -arch arm64 -std=gnu++14 -I"/Library/Frameworks/R.framework/Resources/include" -DNDEBUG -I../inst/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++14 -I"/Library/Frameworks/R.framework/Resources/include" -DNDEBUG -I../inst/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++14 -dynamiclib -Wl,-headerpad_max_install_names -undefined dynamic_lookup -single_module -multiply_defined suppress -L/Library/Frameworks/R.framework/Resources/lib -L/opt/R/arm64/lib -o RcppParallel.so init.o options.o -F/Library/Frameworks/R.framework/.. -framework R -Wl,-framework -Wl,CoreFoundation
installing via 'install.libs.R' to /Users/x/Library/R/arm64/4.1/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 '/Users/x/Library/R/arm64/4.1/library/00LOCK-RcppParallel/00new/RcppParallel/libs/RcppParallel.so':
  dlopen(/Users/x/Library/R/arm64/4.1/library/00LOCK-RcppParallel/00new/RcppParallel/libs/RcppParallel.so, 6): Symbol not found: __ZN3tbb10interface78internal15task_arena_base24internal_max_concurrencyEPKNS0_10task_arenaE
  Referenced from: /Users/x/Library/R/arm64/4.1/library/00LOCK-RcppParallel/00new/RcppParallel/libs/RcppParallel.so
  Expected in: flat namespace
 in /Users/x/Library/R/arm64/4.1/library/00LOCK-RcppParallel/00new/RcppParallel/libs/RcppParallel.so
Error: loading failed
Execution halted
ERROR: loading failed
* removing ‘/Users/x/Library/R/arm64/4.1/library/RcppParallel’
* restoring previous ‘/Users/x/Library/R/arm64/4.1/library/RcppParallel’
Warning message:
In i.p(...) :
  installation of package ‘/var/folders/3y/l30nscjn5k79v562nw43qkg40000gq/T//RtmpV27mEi/file6a7812039c70/RcppParallel_5.1.1-9000.tar.gz’ had non-zero exit status

../../build/Makefile.tbb:28: CONFIG: cfg=release arch=intel64 compiler=clang target=macos runtime=cc12.0.0_os11.2.3

Looks like there's some confusion -- TBB thinks it's being compiled for intel64 even though it should be arm64. I'll see if I can figure out why...

What is the output of:

arch
uname -a

from the command line of your shell? My suspicion is that R was launched from something running under Rosetta translation, so you might also see something like the following in R:

> Sys.info()[["machine"]]
[1] "arm64"
> system("uname -p")
i386
uname -a
Darwin x-air.lan 20.3.0 Darwin Kernel Version 20.3.0: Thu Jan 21 00:06:51 PST 2021; root:xnu-7195.81.3~1/RELEASE_ARM64_T8101 arm64
14:35:40 ⏚ [x:/opt/homebrew/opt/tbb] [pytorch] master ± arch
arm64
> Sys.info()[["machine"]]
[1] "arm64"
> system("uname -p")
i386

R in this case is launched from rstudio, running the nightly build with arm64 rsession support.

To test your theory, I tried installing from R run from the command line, and both 5.1.1 from CRAN and the latest from github do install properly.

I would suggest we report this to the rstudio folks, but aren't you the guy who put together rsession-arm64?

I would suggest we report this to the rstudio folks, but aren't you the guy who put together rsession-arm64?

I am, but ironically right now I do not have access to an M1 machine to test. 😞

I suspect we're running into an issue because RStudio is still compiled for x86_64, and it's responsible for launching the rsession-arm64 binary. I'll file an issue.

I have some free time to help track this down if there's anything you'd like me to check. Thanks much!

Resolved by the update to rstudio-daily.

Is this solved? I still have the same error when installing via R command line using devtools for R4.1.2

Jianshu

@jianshu93, can you please open a new issue with the exact error output you're seeing?