conan-io / conan-center-index

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

[b2] b2/4.10.1: Cannot use b2 binary from the conan repo using the gcc7 (RHEL7) #23062

Closed ujos closed 8 months ago

ujos commented 8 months ago

Description

When I try to build boost 1.81.0 with the gcc 7.3 on RHEL7, I get the following error:

b2: relocation error: b2: symbol _ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEE10_M_replaceEmmPKcm, version GLIBCXX_3.4.21 not defined in file libstdc++.so.6 with link time reference

It seems you use more recent version of the compiler to build the binary for the Conan repo. Would be great if you could use the lowest possible version of the gcc so b2 can be used on more Linux distributions.

Package and Environment Details

Conan profile

[settings] os=Linux os_build=Linux arch=x86_64 arch_build=x86_64 compiler=gcc compiler.version=7.3 compiler.libcxx=libstdc++

[options]

[build_requires]

[buildenv] CC=/home/dev/bin/GCC-7.3-noabi/bin/gcc CXX=/home/dev//bin/GCC-7.3-noabi/bin/g++

Steps to reproduce

Download and compile GCC 7.3:

yum update
yum install texinfo gcc gcc-c++ wget bzip2 make

wget https://ftp.gnu.org/gnu/gcc/gcc-7.3.0/gcc-7.3.0.tar.gz
tar xvf gcc-7.3.0.tar.gz
cd gcc-7.3.0
./contrib/download_prerequisites
cd ..
mkdir obj
../gcc-7.3.0/configure --prefix=$HOME/bin/GCC-7.3 --disable-multilib --enable-languages=c,c++ --disable-libsanitizer --disable-libstdcxx-dual-abi
make -j 8

Run conan

GCC_ROOT=~/bin/GCC-7.3-noabi

export PATH=$PATH:$GCC_ROOT/bin
export CC=$GCC_ROOT/bin/gcc
export CXX=$GCC_ROOT/bin/g++
export LD_LIBRARY_PATH=$GCC_ROOT/lib64:$LD_LIBRARY_PATH

conan install \
   --build=missing \
   --profile:host=dev \
   --profile:build=dev \
   --settings build_type=Release \
   conanfile.txt

Logs

Click to expand log ``` Configuration (profile_host): [settings] arch=x86_64 arch_build=x86_64 build_type=Release compiler=gcc compiler.libcxx=libstdc++ compiler.version=7.3 os=Linux os_build=Linux [options] [build_requires] [env] [buildenv] CC=/home/dev/bin/GCC-7.3-noabi/bin/gcc CXX=/home/dev/bin/GCC-7.3-noabi/bin/g++ Configuration (profile_build): [settings] arch=x86_64 arch_build=x86_64 compiler=gcc compiler.libcxx=libstdc++ compiler.version=7.3 os=Linux os_build=Linux [options] [build_requires] [env] [buildenv] CC=/home/dev/bin/GCC-7.3-noabi/bin/gcc CXX=/home/dev/bin/GCC-7.3-noabi/bin/g++ boost/1.81.0: WARN: Package binary is corrupted, removing: 8438a4aad5972a9b6a587e21db6b066a43751a4b Version ranges solved Version range '>=1.2.11 <2' required by 'boost/1.81.0' resolved to 'zlib/1.3.1' in local cache conanfile.txt: Installing package Requirements boost/1.81.0 from 'conancenter' - Cache bzip2/1.0.8 from 'conancenter' - Cache libbacktrace/cci.20210118 from 'conancenter' - Cache zlib/1.3.1 from 'conancenter' - Cache Packages boost/1.81.0:8438a4aad5972a9b6a587e21db6b066a43751a4b - Build bzip2/1.0.8:5c39baad2a4c92b4e96092a25e4899075a701d92 - Cache libbacktrace/cci.20210118:b09bec465fef58dc59f15f359cb57c2007336987 - Cache zlib/1.3.1:b09bec465fef58dc59f15f359cb57c2007336987 - Cache Build requirements b2/4.10.1 from 'conancenter' - Cache Build requirements packages b2/4.10.1:4db1be536558d833e52e862fd84d64d75c2b3656 - Cache Installing (downloading, building) binaries... b2/4.10.1: Already installed! bzip2/1.0.8: Already installed! libbacktrace/cci.20210118: Already installed! zlib/1.3.1: Already installed! boost/1.81.0: Applying build-requirement: b2/4.10.1 boost/1.81.0: WARN: Build folder is dirty, removing it: /home/dev/.conan/data/boost/1.81.0/_/_/build/8438a4aad5972a9b6a587e21db6b066a43751a4b boost/1.81.0: Building your package in /home/dev/.conan/data/boost/1.81.0/_/_/build/8438a4aad5972a9b6a587e21db6b066a43751a4b boost/1.81.0: Generator txt created conanbuildinfo.txt boost/1.81.0: Calling generate() boost/1.81.0: Aggregating env generators boost/1.81.0: Calling build() boost/1.81.0: WARN: replace_in_file didn't find pattern '/* thread_local */' in '/home/dev/.conan/data/boost/1.81.0/_/_/source/src/boost/stacktrace/detail/libbacktrace_impls.hpp' file. boost/1.81.0: WARN: replace_in_file didn't find pattern '/* static __thread */' in '/home/dev/.conan/data/boost/1.81.0/_/_/source/src/boost/stacktrace/detail/libbacktrace_impls.hpp' file. boost/1.81.0: WARN: replace_in_file didn't find pattern 'local generic-os = [ set.difference $(all-os) : aix darwin vxworks solaris osf hpux ] ;' in '/home/dev/.conan/data/boost/1.81.0/_/_/source/src/tools/build/src/tools/gcc.jam' file. boost/1.81.0: WARN: replace_in_file didn't find pattern 'local no-threading = android beos haiku sgi darwin vxworks ;' in '/home/dev/.conan/data/boost/1.81.0/_/_/source/src/tools/build/src/tools/gcc.jam' file. boost/1.81.0: WARN: replace_in_file didn't find pattern ' @numa' in '/home/dev/.conan/data/boost/1.81.0/_/_/source/src/libs/fiber/build/Jamfile.v2' file. boost/1.81.0: WARN: Patching user-config.jam boost/1.81.0: WARN: using zlib : 1.3.1 : "/home/dev/.conan/data/zlib/1.3.1/_/_/package/b09bec465fef58dc59f15f359cb57c2007336987/include" "/home/dev/.conan/data/zlib/1.3.1/_/_/package/b09bec465fef58dc59f15f359cb57c2007336987/lib" z ; using bzip2 : 1.0.8 : "/home/dev/.conan/data/bzip2/1.0.8/_/_/package/5c39baad2a4c92b4e96092a25e4899075a701d92/include" "/home/dev/.conan/data/bzip2/1.0.8/_/_/package/5c39baad2a4c92b4e96092a25e4899075a701d92/lib" bz2 ; using "gcc" : : "/home/dev/bin/GCC-7.3-noabi/bin/g++" : "-I/home/dev/.conan/data/libbacktrace/cci.20210118/_/_/package/b09bec465fef58dc59f15f359cb57c2007336987/include" "-L/home/dev/.conan/data/libbacktrace/cci.20210118/_/_/package/b09bec465fef58dc59f15f359cb57c2007336987/lib" ; boost/1.81.0: WARN: b2 -q numa=on target-os=linux architecture=x86 address-model=64 binary-format=elf abi=sysv --layout=system --user-config=/home/dev/.conan/data/boost/1.81.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=libc 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-fiber --with-filesystem --with-graph --with-iostreams --with-json --with-locale --with-log --with-math --with-nowide --with-program_options --with-random --with-regex --with-serialization --with-stacktrace --with-system --with-test --with-thread --with-timer --with-type_erasure --with-url --with-wave toolset=gcc cxxstd=11 define=_GLIBCXX_USE_CXX11_ABI=0 pch=on -sLIBBACKTRACE_PATH=/home/dev/.conan/data/libbacktrace/cci.20210118/_/_/package/b09bec465fef58dc59f15f359cb57c2007336987 linkflags="" cxxflags="-fPIC -DBOOST_STACKTRACE_ADDR2LINE_LOCATION=/usr/bin/addr2line" install --prefix=/home/dev/.conan/data/boost/1.81.0/_/_/package/8438a4aad5972a9b6a587e21db6b066a43751a4b -j16 --abbreviate-paths -d0 --debug-configuration --build-dir="/home/dev/.conan/data/boost/1.81.0/_/_/build/8438a4aad5972a9b6a587e21db6b066a43751a4b/build-release" b2: relocation error: b2: symbol _ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEE10_M_replaceEmmPKcm, version GLIBCXX_3.4.21 not defined in file libstdc++.so.6 with link time reference boost/1.81.0: boost/1.81.0: ERROR: Package '8438a4aad5972a9b6a587e21db6b066a43751a4b' build failed boost/1.81.0: WARN: Build folder /home/dev/.conan/data/boost/1.81.0/_/_/build/8438a4aad5972a9b6a587e21db6b066a43751a4b/build-release ERROR: boost/1.81.0: Error in build() method, line 1003 self.run(full_command) ConanException: Error 127 while executing b2 -q numa=on target-os=linux architecture=x86 address-model=64 binary-format=elf abi=sysv --layout=system --user-config=/home/dev/.conan/data/boost/1.81.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=libc 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-fiber --with-filesystem --with-graph --with-iostreams --with-json --with-locale --with-log --with-math --with-nowide --with-program_options --with-random --with-regex --with-serialization --with-stacktrace --with-system --with-test --with-thread --with-timer --with-type_erasure --with-url --with-wave toolset=gcc cxxstd=11 define=_GLIBCXX_USE_CXX11_ABI=0 pch=on -sLIBBACKTRACE_PATH=/home/dev/.conan/data/libbacktrace/cci.20210118/_/_/package/b09bec465fef58dc59f15f359cb57c2007336987 linkflags="" cxxflags="-fPIC -DBOOST_STACKTRACE_ADDR2LINE_LOCATION=/usr/bin/addr2line" install --prefix=/home/dev/.conan/data/boost/1.81.0/_/_/package/8438a4aad5972a9b6a587e21db6b066a43751a4b -j16 --abbreviate-paths -d0 --debug-configuration --build-dir="/home/dev/.conan/data/boost/1.81.0/_/_/build/8438a4aad5972a9b6a587e21db6b066a43751a4b/build-release" ```
uilianries commented 8 months ago

@ujos Hello and thank you for your detailed report! I can reproduce your error in fact.

What happens here is an incompatibility between the linux distribution used to build b2 package and distribute over Conan Center, and your environment.

The GCC7 used by ConanCenterIndex CI is based on Ubuntu 18.04, which uses glibc 2.27:

docker run --rm --platform=linux/amd64 ubuntu:18.04 ldd --version                                                                                                                                                           09:33:22
ldd (Ubuntu GLIBC 2.27-3ubuntu1.6) 2.27
Copyright (C) 2018 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
Written by Roland McGrath and Ulrich Drepper.

However, CentOS 7 uses an older version:

docker run --rm --platform=linux/amd64 centos:centos7.9.2009 ldd --version                                                                                                                                                  09:33:10
ldd (GNU libc) 2.17
Copyright (C) 2012 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
Written by Roland McGrath and Ulrich Drepper.

This mismatch is causing your error, your system can not provide a glibc with those new symbols.

To solve your error, you should build b2 and all other packages from source:

conan install --build --profile:host=dev --profile:build=dev ../conanfile.txt

To store and distribute your packages in your company (for instance), you can use an instance of Artifactory, there is a free standalone edition available to download here: https://conan.io/downloads

Still, if you are afraid about mixing packages from Conan Center with those built in your company, you could customize your settings.yml and add distro entry, so any package installed should have it identified:

https://docs.conan.io/2/reference/config_files/settings.html#adding-new-settings

Regards!

ujos commented 8 months ago

@uilianries It seems the problem actually is not a glibc version, but how C++ runtime for g++7 is built. In my case it is built without C++11 ABI support. Please see above, I used the --disable-libstdcxx-dual-abi key to build the g++. By default C++ runtime contains both ABIs. Once I've recompiled the g++ without that key, I was able to run the original b2 binary downloaded from the Conan Centre.

So the ticket may be closed.

Meanwhile, usually on RHEL developers use devtools. They do not build GCC from sources. I'm not quite sure the C++ runtime shipped with devtools contains both ABIs. Theoretically in case if you rebuild b2 with the disabled C++11 ABI (-D_GLIBCXX_USE_CXX11_ABI=0), then it may run on RHEL7 out of the box.

uilianries commented 8 months ago

@ujos Thank you for sharing it! Your feedback your help the community in the future! Regards!

ujos commented 8 months ago

@uilianries Actually based on Conan profile, the b2 binary has to be provided without C++11 ABI.

 compiler.libcxx=libstdc++