Closed mattocci27 closed 2 years ago
Hmm I don't recognize his warning, never seen that before, it may be something new in the latest xcode.
ld: warning: -undefined dynamic_lookup may not work with chained fixups
Is there any reason you are compiling the source package, instead of using the pre-compiled binary? Can you try
install.packages("V8", type = 'mac.binary')
Thanks. Yes, it used to work until I upgraded xcode. I tried install.packages("V8", type = 'mac.binary')
but it downloaded the x86_64 version.
[ins] r$> library(V8)
Error: package or namespace load failed for ‘V8’ in dyn.load(file, DLLpath = DLLpath, ...):
unable to load shared object '/opt/homebrew/lib/R/4.2/site-library/V8/libs/V8.so':
dlopen(/opt/homebrew/lib/R/4.2/site-library/V8/libs/V8.so, 0x0006): tried: '/opt/homebrew/lib/R/4.2/site-library/V8/libs/V8.so' (mach-o file, but is an incompatible architecture (have (x86_64), need (arm64e)))
Next, I downloaded a macOS binary (arm64) from CRAN and tried remotes::install_local("V8_4.2.1.tgz")
. Now I have a different error.
[ins] r$> library(V8)
Error: package or namespace load failed for ‘V8’ in dyn.load(file, DLLpath = DLLpath, ...):
unable to load shared object '/opt/homebrew/lib/R/4.2/site-library/V8/libs/V8.so':
dlopen(/opt/homebrew/lib/R/4.2/site-library/V8/libs/V8.so, 0x0006): Library not loaded: '/Library/Frameworks/R.framework/Versions/4.2-arm64/Resources/lib/libR.dylib'
Referenced from: '/opt/homebrew/lib/R/4.2/site-library/V8/libs/V8.so'
Reason: tried: '/Library/Frameworks/R.framework/Versions/4.2-arm64/Resources/lib/libR.dylib' (no such file), '/usr/local/lib/libR.dylib' (no such file), '/usr/lib/libR.dylib' (no such file)
Ah ok I guess the binary only works if you use the official R from CRAN and not the homebrew version of R. You can probably simplify your life with
brew remove r
brew install --cask r
Wow, now install.packages("V8")
is woking. I will never use brew install r
👍
I was able to reproduce the error after installing v8
from Homebrew; e.g.
brew install v8
Here's some more verbose output...
Running feature test for pointer compression...
Apple clang version 14.0.0 (clang-1400.0.29.102)
Target: arm64-apple-darwin21.6.0
Thread model: posix
InstalledDir: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin
"/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang" -cc1 -triple arm64-apple-macosx12.0.0 -Wundef-prefix=TARGET_OS_ -Wdeprecated-objc-isa-usage -Werror=deprecated-objc-isa-usage -Werror=implicit-function-declaration -emit-obj --mrelax-relocations -disable-free -clear-ast-before-backend -disable-llvm-verifier -discard-value-names -main-file-name test.cpp -mrelocation-model pic -pic-level 2 -mframe-pointer=non-leaf -fno-strict-return -fno-rounding-math -funwind-tables=2 -fobjc-msgsend-selector-stubs -target-sdk-version=12.3 -fvisibility-inlines-hidden-static-local-var -target-cpu apple-m1 -target-feature +v8.5a -target-feature +fp-armv8 -target-feature +neon -target-feature +crc -target-feature +crypto -target-feature +dotprod -target-feature +fp16fml -target-feature +ras -target-feature +lse -target-feature +rdm -target-feature +rcpc -target-feature +zcm -target-feature +zcz -target-feature +fullfp16 -target-feature +sm4 -target-feature +sha3 -target-feature +sha2 -target-feature +aes -target-abi darwinpcs -fallow-half-arguments-and-returns -debug-info-kind=standalone -dwarf-version=4 -debugger-tuning=lldb -target-linker-version 819.6 -v -resource-dir /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/clang/14.0.0 -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk -I /opt/homebrew/opt/gettext/include -I /opt/homebrew/opt/readline/include -I /opt/homebrew/opt/xz/include -I /opt/homebrew/include -I /Users/kevin/r/pkg/V8/.deps/include -D V8_ENABLE_CHECKS -I/usr/local/include -stdlib=libc++ -internal-isystem /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/c++/v1 -internal-isystem /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/local/include -internal-isystem /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/clang/14.0.0/include -internal-externc-isystem /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include -internal-externc-isystem /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include -O2 -Wno-reorder-init-list -Wno-implicit-int-float-conversion -Wno-c99-designator -Wno-final-dtor-non-final-class -Wno-extra-semi-stmt -Wno-misleading-indentation -Wno-quoted-include-in-framework-header -Wno-implicit-fallthrough -Wno-enum-enum-conversion -Wno-enum-float-conversion -Wno-elaborated-enum-base -Wno-reserved-identifier -Wno-gnu-folding-constant -Wno-cast-function-type -Wno-bitwise-instead-of-logical -std=gnu++17 -fdeprecated-macro -fdebug-compilation-dir=/Users/kevin/r/pkg/V8 -ferror-limit 19 -pthread -stack-protector 1 -fstack-check -mdarwin-stkchk-strong-link -fblocks -fencode-extended-block-signature -fregister-global-dtors-with-atexit -fgnuc-version=4.2.1 -fno-cxx-modules -fcxx-exceptions -fexceptions -fmax-type-align=16 -fcommon -fcolor-diagnostics -vectorize-loops -vectorize-slp -clang-vendor-feature=+messageToSelfInClassMethodIdReturnType -clang-vendor-feature=+disableInferNewAvailabilityFromInit -clang-vendor-feature=+disableNonDependentMemberExprInCurrentInstantiation -fno-odr-hash-protocols -clang-vendor-feature=+enableAggressiveVLAFolding -clang-vendor-feature=+revert09abecef7bbf -clang-vendor-feature=+thisNoAlignAttr -clang-vendor-feature=+thisNoNullAttr -mllvm -disable-aligned-alloc-awareness=1 -D__GCC_HAVE_DWARF2_CFI_ASM=1 -o /var/folders/9n/3nxsgkrj0rlfx196kzdttpww0000gn/T/test-6bec6d.o -x c++ tools/test.cpp
clang -cc1 version 14.0.0 (clang-1400.0.29.102) default target arm64-apple-darwin21.6.0
ignoring nonexistent directory "/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/local/include"
ignoring nonexistent directory "/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/Library/Frameworks"
#include "..." search starts here:
#include <...> search starts here:
/opt/homebrew/opt/gettext/include
/opt/homebrew/opt/readline/include
/opt/homebrew/opt/xz/include
/opt/homebrew/include
/Users/kevin/r/pkg/V8/.deps/include
/usr/local/include
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/c++/v1
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/clang/14.0.0/include
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/System/Library/Frameworks (framework directory)
End of search list.
"/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/ld" -demangle -lto_library /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/libLTO.dylib -dynamic -arch arm64 -platform_version macos 12.0.0 12.3 -syslibroot /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk -o pctest -L/opt/homebrew/opt/gettext/lib -L/opt/homebrew/opt/readline/lib -L/opt/homebrew/opt/xz/lib -L/opt/homebrew/lib -L/Users/kevin/r/pkg/V8/.deps/lib -L/usr/local/lib /var/folders/9n/3nxsgkrj0rlfx196kzdttpww0000gn/T/test-6bec6d.o -lv8 -ldl -lc++ -lSystem /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/clang/14.0.0/lib/darwin/libclang_rt.osx.a
Undefined symbols for architecture arm64:
"v8::platform::NewDefaultPlatform(int, v8::platform::IdleTaskSupport, v8::platform::InProcessStackDumping, std::__1::unique_ptr<v8::TracingController, std::__1::default_delete<v8::TracingController> >)", referenced from:
_main in test-6bec6d.o
ld: symbol(s) not found for architecture arm64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
I think there's two issues. First, the pointer compression test code needs to make sure the bundled libv8 compiler flags come first, before anything set by R:
https://github.com/jeroen/V8/blob/196359bb38a4eaccbbbfafa820c8d5b6c5213cf3/configure#L123-L134
That is, the PKG_*
flags should come first, so that those locations are preferred to anything R was compiled with.
Second, V8 needs a way to tell Homebrew R to link with the version of libv8 that it's providing. Unfortunately, PKG_LIBS
is not enough as the library flags get set after the R linker flags:
clang++ -std=gnu++17 -dynamiclib -Wl,-headerpad_max_install_names -undefined dynamic_lookup -single_module -multiply_defined suppress -L/opt/homebrew/Cellar/r/4.2.1_4/lib/R/lib -L/opt/homebrew/opt/gettext/lib -L/opt/homebrew/opt/readline/lib -L/opt/homebrew/opt/xz/lib -L/opt/homebrew/lib -o V8.so RcppExports.o bindings.o -L/Users/kevin/r/pkg/V8/.deps/lib -lv8 -L/opt/homebrew/Cellar/r/4.2.1_4/lib/R/lib -lR -lintl -Wl,-framework -Wl,CoreFoundation
I don't see a clean way of doing this except perhaps with a src/Makefile
rather than a src/Makevars
, since AFAICS there isn't a clean place for packages to provide linker flags that come before the ones set by R.
Here is the R session information and the error code.