XRPLF / rippled

Decentralized cryptocurrency blockchain daemon implementing the XRP Ledger protocol in C++
https://xrpl.org
ISC License
4.51k stars 1.46k forks source link

Conan Boost issues with Apple Silicon (Arm64) #4480

Closed donovanhide closed 1 year ago

donovanhide commented 1 year ago

Seems like b2 is downloaded as an Intel binary and does not run on an Apple M1 Max Macbook which does not have Rosetta installed. Could install Rosetta, but would be better to fix the issue.

conan profile show default
Configuration for profile default:

[settings]
os=Macos
os_build=Macos
arch=armv8
arch_build=armv8
compiler=apple-clang
compiler.version=14
compiler.libcxx=libc++
build_type=Release
[options]
[conf]
[build_requires]
[env]
boost/1.77.0: Applying build-requirement: b2/4.9.3
boost/1.77.0: Building your package in /Users/donovanhide/.conan/data/boost/1.77.0/_/_/build/cf0de6e2d4229b960307988f5fcb0cb1bc6238fe
boost/1.77.0: Generator txt created conanbuildinfo.txt
boost/1.77.0: Calling generate()
boost/1.77.0: Aggregating env generators
boost/1.77.0: Calling build()
boost/1.77.0: WARN: replace_in_file didn't find pattern 'local generic-os = [ set.difference $(all-os) : aix darwin vxworks solaris osf hpux ] ;' in '/Users/donovanhide/.conan/data/boost/1.77.0/_/_/source/src/tools/build/src/tools/gcc.jam' file.
boost/1.77.0: WARN: replace_in_file didn't find pattern 'local no-threading = android beos haiku sgi darwin vxworks ;' in '/Users/donovanhide/.conan/data/boost/1.77.0/_/_/source/src/tools/build/src/tools/gcc.jam' file.
boost/1.77.0: WARN: replace_in_file didn't find pattern '    <conditional>@numa' in '/Users/donovanhide/.conan/data/boost/1.77.0/_/_/source/src/libs/fiber/build/Jamfile.v2' file.
boost/1.77.0: WARN: Patching user-config.jam
boost/1.77.0: WARN: Using the new toolchains and generators without specifying a build profile (e.g: -pr:b=default) is discouraged and might cause failures and unexpected behavior
boost/1.77.0: WARN:
using zlib : 1.2.12 : <include>"/Users/donovanhide/.conan/data/zlib/1.2.12/_/_/package/240c2182163325b213ca6886a7614c8ed2bf1738/include" <search>"/Users/donovanhide/.conan/data/zlib/1.2.12/_/_/package/240c2182163325b213ca6886a7614c8ed2bf1738/lib" <name>z ;
using bzip2 : 1.0.8 : <include>"/Users/donovanhide/.conan/data/bzip2/1.0.8/_/_/package/238a93dc813ca1550968399f1f8925565feeff8e/include" <search>"/Users/donovanhide/.conan/data/bzip2/1.0.8/_/_/package/238a93dc813ca1550968399f1f8925565feeff8e/lib" <name>bz2 ;
using "clang-darwin" :  :  "/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang++" -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX13.1.sdk -arch arm64 :
<archiver>"/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/ar" <ranlib>"/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/ranlib" <compileflags>"-I/Users/donovanhide/.conan/data/libbacktrace/cci.20210118/_/_/package/240c2182163325b213ca6886a7614c8ed2bf1738/include" <linkflags>"-L/Users/donovanhide/.conan/data/libbacktrace/cci.20210118/_/_/package/240c2182163325b213ca6886a7614c8ed2bf1738/lib"  ;
boost/1.77.0: WARN: Using the new toolchains and generators without specifying a build profile (e.g: -pr:b=default) is discouraged and might cause failures and unexpected behavior
boost/1.77.0: WARN: b2 -q target-os=darwin architecture=arm address-model=64 binary-format=mach-o abi=aapcs --layout=system --user-config=/Users/donovanhide/.conan/data/boost/1.77.0/_/_/source/src/tools/build/user-config.jam -sNO_ZLIB=0 -sNO_BZIP2=0 -sNO_LZMA=1 -sNO_ZSTD=1 boost.locale.icu=off --disable-icu boost.locale.iconv=on boost.locale.iconv.lib=libiconv threading=multi visibility=global link=static variant=release --with-atomic --with-chrono --with-container --with-context --with-contract --with-coroutine --with-date_time --with-exception --with-filesystem --with-iostreams --with-locale --with-log --with-program_options --with-random --with-regex --with-serialization --with-stacktrace --with-system --with-test --with-thread --with-timer --with-type_erasure --with-wave toolset=clang-darwin pch=on -sLIBBACKTRACE_PATH=/Users/donovanhide/.conan/data/libbacktrace/cci.20210118/_/_/package/240c2182163325b213ca6886a7614c8ed2bf1738 -sICONV_PATH=/Users/donovanhide/.conan/data/libiconv/1.17/_/_/package/240c2182163325b213ca6886a7614c8ed2bf1738 linkflags="-stdlib=libc++" cxxflags="-fPIC -stdlib=libc++ -DBOOST_STACKTRACE_ADDR2LINE_LOCATION=/usr/bin/addr2line" install --prefix=/Users/donovanhide/.conan/data/boost/1.77.0/_/_/package/cf0de6e2d4229b960307988f5fcb0cb1bc6238fe -j10 --abbreviate-paths -d0 --debug-configuration --build-dir="/Users/donovanhide/.conan/data/boost/1.77.0/_/_/build/cf0de6e2d4229b960307988f5fcb0cb1bc6238fe/build-release"
/bin/sh: /Users/donovanhide/.conan/data/b2/4.9.3/_/_/package/a5ad5696abf650a25eea8f377806b3d5fe234e6e/bin/b2: Bad CPU type in executable
boost/1.77.0:
boost/1.77.0: ERROR: Package 'cf0de6e2d4229b960307988f5fcb0cb1bc6238fe' build failed
boost/1.77.0: WARN: Build folder /Users/donovanhide/.conan/data/boost/1.77.0/_/_/build/cf0de6e2d4229b960307988f5fcb0cb1bc6238fe/build-release
ERROR: boost/1.77.0: Error in build() method, line 880
        self.run(full_command)
        ConanException: Error 126 while executing b2 -q target-os=darwin architecture=arm address-model=64 binary-format=mach-o abi=aapcs --layout=system --user-config=/Users/donovanhide/.conan/data/boost/1.77.0/_/_/source/src/tools/build/user-config.jam -sNO_ZLIB=0 -sNO_BZIP2=0 -sNO_LZMA=1 -sNO_ZSTD=1 boost.locale.icu=off --disable-icu boost.locale.iconv=on boost.locale.iconv.lib=libiconv threading=multi visibility=global link=static variant=release --with-atomic --with-chrono --with-container --with-context --with-contract --with-coroutine --with-date_time --with-exception --with-filesystem --with-iostreams --with-locale --with-log --with-program_options --with-random --with-regex --with-serialization --with-stacktrace --with-system --with-test --with-thread --with-timer --with-type_erasure --with-wave toolset=clang-darwin pch=on -sLIBBACKTRACE_PATH=/Users/donovanhide/.conan/data/libbacktrace/cci.20210118/_/_/package/240c2182163325b213ca6886a7614c8ed2bf1738 -sICONV_PATH=/Users/donovanhide/.conan/data/libiconv/1.17/_/_/package/240c2182163325b213ca6886a7614c8ed2bf1738 linkflags="-stdlib=libc++" cxxflags="-fPIC -stdlib=libc++ -DBOOST_STACKTRACE_ADDR2LINE_LOCATION=/usr/bin/addr2line" install --prefix=/Users/donovanhide/.conan/data/boost/1.77.0/_/_/package/cf0de6e2d4229b960307988f5fcb0cb1bc6238fe -j10 --abbreviate-paths -d0 --debug-configuration --build-dir="/Users/donovanhide/.conan/data/boost/1.77.0/_/_/build/cf0de6e2d4229b960307988f5fcb0cb1bc6238fe/build-release"
intelliot commented 1 year ago

@gregtatcam I know you build on arm64 - would you be able to have a look at this?

gregtatcam commented 1 year ago

I can take a look. Though I went to @thejohnfreeman with any conan related questions so it might take a while for me to figure it out.

gregtatcam commented 1 year ago

But @HowardHinnant had the same problem a few days ago. This is what worked for him:

conan remove boost -f conan install boost/1.77.0@ --build

And then change conan install command from --build missing to just --build.

donovanhide commented 1 year ago

Hi, Thanks for that. The suggested changes do make the conan install process complete, but I'm now getting linker errors associated with boost in the cmake --build . process:

[ 69%] Building CXX object CMakeFiles/rippled.dir/src/test/shamap/SHAMapSync_test.cpp.o
[ 69%] Building CXX object CMakeFiles/rippled.dir/src/test/shamap/SHAMap_test.cpp.o
[ 70%] Building CXX object CMakeFiles/rippled.dir/src/test/unit_test/multi_runner.cpp.o
[ 70%] Linking CXX executable rippled
Undefined symbols for architecture arm64:
  "boost::json::value::value(boost::json::value&&)", referenced from:
      ripple::test::Expected_test::run()::'lambda9'()::operator()() const in Expected_test.cpp.o
  "boost::json::value::~value()", referenced from:
      ripple::test::Expected_test::run() in Expected_test.cpp.o
      ripple::test::Expected_test::run()::'lambda9'()::operator()() const in Expected_test.cpp.o
  "boost::json::object::object(boost::json::object&&)", referenced from:
      ripple::test::Expected_test::run()::'lambda9'()::operator()() const in Expected_test.cpp.o
  "boost::json::object::object(std::initializer_list<std::__1::pair<boost::basic_string_view<char, std::__1::char_traits<char> >, boost::json::value_ref> >, unsigned long, boost::json::storage_ptr)", referenced from:
      ripple::test::Expected_test::run()::'lambda9'()::operator()() const in Expected_test.cpp.o
  "boost::json::object::~object()", referenced from:
      ripple::test::Expected_test::run()::'lambda9'()::operator()() const in Expected_test.cpp.o
ld: symbol(s) not found for architecture arm64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
make[2]: *** [rippled] Error 1
make[1]: *** [CMakeFiles/rippled.dir/all] Error 2
make: *** [all] Error 2
sublimator commented 1 year ago

Donch-ya know ?

thejohnfreeman commented 1 year ago

@donovanhide I'm assuming you hit this error on a fresh build, but can you please confirm? Remove ~/.conan/data, remove the build directory, start over, pass --build with no argument to conan install, and still miss a symbol in boost::json?

thejohnfreeman commented 1 year ago

Did you remember to set compiler.cppstd=20 on the command line for conan install? It is missing from your profile.

donovanhide commented 1 year ago

I had previously removed the ~/.conan/data directory, but not the actual build directory. Having done this and omitting the missing argument, and also adding the compiler.cppstd=20 to the profile, it all builds! It's a bit of a mystery which change solved the problem. It's a shame Github Actions doesn't have a MacOS Arm64 runner.

Anyway, thanks for the help. Can actually do what I need to do now!