conan-io / conan-center-index

Recipes for the ConanCenter repository
https://conan.io/center
MIT License
950 stars 1.73k forks source link

[package] proposal/7.4.2: boost installation fails on M1 #14869

Closed Jean1995 closed 1 year ago

Jean1995 commented 1 year ago

Description

I am working on a new Apple M1 with Ventura. If I try to install the proposal package, It tries to build boost, but fails with the error

/bin/sh: /Users/jean/.conan/data/b2/4.9.2/_/_/package/a5ad5696abf650a25eea8f377806b3d5fe234e6e/bin/b2: Bad CPU type in executable

So something seems to be wrong with building boost.

Package and Environment Details

Conan profile

[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]

Steps to reproduce

conan install -r conancenter proposal/7.4.2@ --build=missing

Logs

Click to expand log ``` Configuration: [settings] arch=armv8 arch_build=armv8 build_type=Release compiler=apple-clang compiler.libcxx=libc++ compiler.version=14 os=Macos os_build=Macos [options] [build_requires] [env] Installing package: proposal/7.4.2 Requirements boost/1.75.0 from 'conancenter' - Cache bzip2/1.0.8 from 'conancenter' - Cache cubicinterpolation/0.1.4 from 'conancenter' - Cache eigen/3.3.9 from 'conancenter' - Cache fmt/8.0.1 from 'conancenter' - Cache libbacktrace/cci.20210118 from 'conancenter' - Cache libiconv/1.17 from 'conancenter' - Cache nlohmann_json/3.10.5 from 'conancenter' - Cache proposal/7.4.2 from 'conancenter' - Cache spdlog/1.9.2 from 'conancenter' - Cache zlib/1.2.13 from 'conancenter' - Cache Packages boost/1.75.0:565bafe4bc7369a9ab2aeeca685911f3e667af11 - Build bzip2/1.0.8:238a93dc813ca1550968399f1f8925565feeff8e - Cache cubicinterpolation/0.1.4:daa7b63aae03f094a03951a7592776a91d416e2e - Build eigen/3.3.9:5ab84d6acfe1f23c4fae0ab88f26e3a396351ac9 - Cache fmt/8.0.1:070f9bf1d15cf4b2a694de71f450816c2d2f2f25 - Cache libbacktrace/cci.20210118:240c2182163325b213ca6886a7614c8ed2bf1738 - Cache libiconv/1.17:240c2182163325b213ca6886a7614c8ed2bf1738 - Cache nlohmann_json/3.10.5:5ab84d6acfe1f23c4fae0ab88f26e3a396351ac9 - Cache proposal/7.4.2:0590cfc41aad0c6060bd42d71fe10635f663bf57 - Build spdlog/1.9.2:0659667fbfe29fe82b26a7bad5ba2576d6ce0197 - Build zlib/1.2.13:240c2182163325b213ca6886a7614c8ed2bf1738 - Cache Build requirements b2/4.9.2 from 'conancenter' - Cache Build requirements packages b2/4.9.2:a5ad5696abf650a25eea8f377806b3d5fe234e6e - Cache Installing (downloading, building) binaries... b2/4.9.2: Already installed! bzip2/1.0.8: Already installed! eigen/3.3.9: Already installed! fmt/8.0.1: Already installed! libbacktrace/cci.20210118: Already installed! libiconv/1.17: Already installed! nlohmann_json/3.10.5: Already installed! zlib/1.2.13: Already installed! boost/1.75.0: Applying build-requirement: b2/4.9.2 boost/1.75.0: WARN: Build folder is dirty, removing it: /Users/jean/.conan/data/boost/1.75.0/_/_/build/565bafe4bc7369a9ab2aeeca685911f3e667af11 boost/1.75.0: Building your package in /Users/jean/.conan/data/boost/1.75.0/_/_/build/565bafe4bc7369a9ab2aeeca685911f3e667af11 boost/1.75.0: Generator txt created conanbuildinfo.txt boost/1.75.0: Calling generate() boost/1.75.0: Aggregating env generators boost/1.75.0: Calling build() boost/1.75.0: WARN: replace_in_file didn't find pattern 'local generic-os = [ set.difference $(all-os) : aix darwin vxworks solaris osf hpux ] ;' in '/Users/jean/.conan/data/boost/1.75.0/_/_/source/src/tools/build/src/tools/gcc.jam' file. boost/1.75.0: WARN: replace_in_file didn't find pattern 'local no-threading = android beos haiku sgi darwin vxworks ;' in '/Users/jean/.conan/data/boost/1.75.0/_/_/source/src/tools/build/src/tools/gcc.jam' file. boost/1.75.0: WARN: replace_in_file didn't find pattern ' @numa' in '/Users/jean/.conan/data/boost/1.75.0/_/_/source/src/libs/fiber/build/Jamfile.v2' file. boost/1.75.0: WARN: Patching user-config.jam boost/1.75.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.75.0: WARN: using zlib : 1.2.13 : "/Users/jean/.conan/data/zlib/1.2.13/_/_/package/240c2182163325b213ca6886a7614c8ed2bf1738/include" "/Users/jean/.conan/data/zlib/1.2.13/_/_/package/240c2182163325b213ca6886a7614c8ed2bf1738/lib" z ; using bzip2 : 1.0.8 : "/Users/jean/.conan/data/bzip2/1.0.8/_/_/package/238a93dc813ca1550968399f1f8925565feeff8e/include" "/Users/jean/.conan/data/bzip2/1.0.8/_/_/package/238a93dc813ca1550968399f1f8925565feeff8e/lib" bz2 ; using "clang-darwin" : : /Library/Developer/CommandLineTools/usr/bin/clang++ -isysroot /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk -arch arm64 : "/Library/Developer/CommandLineTools/usr/bin/ar" "/Library/Developer/CommandLineTools/usr/bin/ranlib" "-I/Users/jean/.conan/data/libbacktrace/cci.20210118/_/_/package/240c2182163325b213ca6886a7614c8ed2bf1738/include" "-L/Users/jean/.conan/data/libbacktrace/cci.20210118/_/_/package/240c2182163325b213ca6886a7614c8ed2bf1738/lib" ; boost/1.75.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.75.0: WARN: b2 -q target-os=darwin architecture=arm address-model=64 binary-format=mach-o abi=aapcs --layout=system --user-config=/Users/jean/.conan/data/boost/1.75.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=hidden link=static variant=release --with-atomic --with-chrono --with-container --with-context --with-contract --with-coroutine --with-date_time --with-exception --with-filesystem --with-graph --with-iostreams --with-locale --with-log --with-math --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 -sICONV_PATH=/Users/jean/.conan/data/libiconv/1.17/_/_/package/240c2182163325b213ca6886a7614c8ed2bf1738 linkflags="-stdlib=libc++" cxxflags="-fPIC -stdlib=libc++ -DBOOST_STACKTRACE_ADDR2LINE_LOCATION=/usr/bin/addr2line" install --prefix=/Users/jean/.conan/data/boost/1.75.0/_/_/package/565bafe4bc7369a9ab2aeeca685911f3e667af11 -j8 --abbreviate-paths -d0 --debug-configuration --build-dir="/Users/jean/.conan/data/boost/1.75.0/_/_/build/565bafe4bc7369a9ab2aeeca685911f3e667af11/build-release" /bin/sh: /Users/jean/.conan/data/b2/4.9.2/_/_/package/a5ad5696abf650a25eea8f377806b3d5fe234e6e/bin/b2: Bad CPU type in executable boost/1.75.0: boost/1.75.0: ERROR: Package '565bafe4bc7369a9ab2aeeca685911f3e667af11' build failed boost/1.75.0: WARN: Build folder /Users/jean/.conan/data/boost/1.75.0/_/_/build/565bafe4bc7369a9ab2aeeca685911f3e667af11/build-release ERROR: boost/1.75.0: Error in build() method, line 850 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/jean/.conan/data/boost/1.75.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=hidden link=static variant=release --with-atomic --with-chrono --with-container --with-context --with-contract --with-coroutine --with-date_time --with-exception --with-filesystem --with-graph --with-iostreams --with-locale --with-log --with-math --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 -sICONV_PATH=/Users/jean/.conan/data/libiconv/1.17/_/_/package/240c2182163325b213ca6886a7614c8ed2bf1738 linkflags="-stdlib=libc++" cxxflags="-fPIC -stdlib=libc++ -DBOOST_STACKTRACE_ADDR2LINE_LOCATION=/usr/bin/addr2line" install --prefix=/Users/jean/.conan/data/boost/1.75.0/_/_/package/565bafe4bc7369a9ab2aeeca685911f3e667af11 -j8 --abbreviate-paths -d0 --debug-configuration --build-dir="/Users/jean/.conan/data/boost/1.75.0/_/_/build/565bafe4bc7369a9ab2aeeca685911f3e667af11/build-release"```
SpaceIm commented 1 year ago

Well, it may be an issue in b2 recipe. Looks like b2 executable is not properly cross-built from macOS x86_64 to M1. Did you try to build b2 from source?

Jean1995 commented 1 year ago

conan install -r conancenter b2/4.9.3@ worked without a problem.

I was also able to just download and build b2 from source, without conan.

EDIT: conan install -r conancenter proposal/7.4.2@ --build=b2 --build=missing however is working

SpaceIm commented 1 year ago

conan install -r conancenter proposal/7.4.2@ --build=b2 --build=missing however is working

It was my question yes.

I believe that pre built b2 binary in conan-center for macOS M1 is illformed, maybe due to a cross-build issue in b2 recipe (pre-built binaries for macOS M1 in conan-center are generated by a cross-build from macOS Intel to macOS M1). @grafikrobot any idea?

grafikrobot commented 1 year ago

@SpaceIm it sounds likely, almost certain. Given that cross-building the b2 engine is not tested nor supported. It's not impossible to do it though. But it would require setting the compiler and flags used to completely override the built-in compiler detection. Doing that would mean using both the use_cxx_env and toolset=cxx, additionally setting the CXX and CXXFLAGS env vars fully.

jcar87 commented 1 year ago

From what I can see, it looks like the b2 executable for macos+armv8 it's actually an x86_64 binary for multiple versions - don't think this was caused by any recent change.

I'd imagine the reason this has not surfaced before has to do with the overwhelming likelihood of 'Rosetta' being installed for M1 users - which will run the executable just fine. If the package contained a library, that would have been a different story.

Will investigate a way to prevent this from happening in the future.

As for cross-building b2 on macOS - thankfully Apple has made this easy. I have tested that passing--cxxflags="-arch arm64" to build.sh is enough to build the right thing - However, invoking b2 install immediately after is going to be a challenge, as the arm64 executable will not run on the intel agents. Is there a way around this? (unless we're okay with building b2 twice!)

grafikrobot commented 1 year ago

@jcar87 you might be able to pass --cxxflags="-arch arm64 -arch x86_64" to do a universal build. That way you can still run it on the CI host.