bincrafters / community

Central repository for issues and recipes
http://bincrafters.readthedocs.io/en/latest/
MIT License
217 stars 36 forks source link

building boost libraries should respect the compiler.libcxx setting #336

Closed mbeach closed 5 years ago

mbeach commented 6 years ago

Description of Problem, Request, or Question

Currently, when conan package for a non-header only boost library is built, the build is always done using the compiler's default ABI. This means that even when we attempt to build for libstdc++, if the compiler defaults to libstdc++11 (say gcc 5.4 on Ubuntu 16.04) we build libraries that purport to be using the pre-C++11 ABI but are in fact using the C++11 ABI. Builds that attempt to use these libraries will fail.

This can be confirmed by looking at boost_program_options from bintray...

michaelb@pythagoras ~ $ conan download boost_program_options/1.66.0@bincrafters/stable -p d890f7719c7a81ee45b0384b126107aee6426e1c -r bincrafters
Downloading conanmanifest.txt
[==================================================] 103B/103B        
Downloading conanfile.py
[==================================================] 2.9KB/2.9KB      
Downloading conan_export.tgz
[==================================================] 758B/758B        
boost_program_options/1.66.0@bincrafters/stable: Downloading boost_program_options/1.66.0@bincrafters/stable:d890f7719c7a81ee45b0384b126107aee6426e1c
boost_program_options/1.66.0@bincrafters/stable: Retrieving package d890f7719c7a81ee45b0384b126107aee6426e1c from remote 'bincrafters' 
Downloading conanmanifest.txt
[==================================================] 2.1KB/2.1KB      
Downloading conaninfo.txt
[==================================================] 1.9KB/1.9KB      
Downloading conan_package.tgz
[==================================================] 313.0KB/313.0KB  
boost_program_options/1.66.0@bincrafters/stable: Package installed d890f7719c7a81ee45b0384b126107aee6426e1c
michaelb@pythagoras ~ $ cat ~/.conan/data/boost_program_options/1.66.0/bincrafters/stable/package/d890f7719c7a81ee45b0384b126107aee6426e1c/conaninfo.txt 
[settings]
    arch=x86_64
    build_type=Release
    compiler=gcc
    compiler.libcxx=libstdc++
    compiler.version=5
    os=Linux

[requires]
    boost_any/1.66.0
    boost_config/1.66.0
    boost_core/1.66.0
    boost_detail/1.66.0
    boost_function/1.66.0
    boost_iterator/1.66.0
    boost_lexical_cast/1.66.0
    boost_package_tools/1.66.0
    boost_smart_ptr/1.66.0
    boost_static_assert/1.66.0
    boost_throw_exception/1.66.0
    boost_tokenizer/1.66.0
    boost_type_traits/1.66.0

[options]
    shared=False

[full_settings]
    arch=x86_64
    build_type=Release
    compiler=gcc
    compiler.libcxx=libstdc++
    compiler.version=5
    os=Linux

[full_requires]
    boost_any/1.66.0@bincrafters/stable:5ab84d6acfe1f23c4fae0ab88f26e3a396351ac9
    boost_config/1.66.0@bincrafters/stable:5ab84d6acfe1f23c4fae0ab88f26e3a396351ac9
    boost_core/1.66.0@bincrafters/stable:5ab84d6acfe1f23c4fae0ab88f26e3a396351ac9
    boost_detail/1.66.0@bincrafters/stable:5ab84d6acfe1f23c4fae0ab88f26e3a396351ac9
    boost_function/1.66.0@bincrafters/stable:5ab84d6acfe1f23c4fae0ab88f26e3a396351ac9
    boost_iterator/1.66.0@bincrafters/stable:5ab84d6acfe1f23c4fae0ab88f26e3a396351ac9
    boost_lexical_cast/1.66.0@bincrafters/stable:5ab84d6acfe1f23c4fae0ab88f26e3a396351ac9
    boost_package_tools/1.66.0@bincrafters/stable:5ab84d6acfe1f23c4fae0ab88f26e3a396351ac9
    boost_smart_ptr/1.66.0@bincrafters/stable:5ab84d6acfe1f23c4fae0ab88f26e3a396351ac9
    boost_static_assert/1.66.0@bincrafters/stable:5ab84d6acfe1f23c4fae0ab88f26e3a396351ac9
    boost_throw_exception/1.66.0@bincrafters/stable:5ab84d6acfe1f23c4fae0ab88f26e3a396351ac9
    boost_tokenizer/1.66.0@bincrafters/stable:5ab84d6acfe1f23c4fae0ab88f26e3a396351ac9
    boost_type_traits/1.66.0@bincrafters/stable:5ab84d6acfe1f23c4fae0ab88f26e3a396351ac9

[full_options]
    shared=False

[recipe_hash]
    da5d34935c3fc103aa65b6c5e66fb9d5

[env]

michaelb@pythagoras ~ $ nm ~/.conan/data/boost_program_options/1.66.0/bincrafters/stable/package/d890f7719c7a81ee45b0384b126107aee6426e1c/program_options/lib/libboost_program_options.a | fgrep string | head
0000000000000000 W _ZN5boost15program_options14invalid_syntaxC1ENS1_6kind_tERKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEESA_i
0000000000000000 W _ZN5boost15program_options14invalid_syntaxC2ENS1_6kind_tERKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEESA_i
0000000000000000 n _ZN5boost15program_options14invalid_syntaxC5ENS1_6kind_tERKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEESA_i
0000000000000000 W _ZN5boost15program_options14unknown_optionC1ERKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEE
0000000000000000 W _ZN5boost15program_options14unknown_optionC2ERKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEE
0000000000000000 n _ZN5boost15program_options14unknown_optionC5ERKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEE
0000000000000000 W _ZN5boost15program_options22error_with_option_name15set_option_nameERKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEE
0000000000000000 W _ZN5boost15program_options22error_with_option_name18set_original_tokenERKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEE
                 U _ZN5boost15program_options22error_with_option_nameC2ERKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEES9_S9_i
0000000000000000 W _ZN5boost15program_options25error_with_no_option_name15set_option_nameERKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEE

The package clearly claims to be the pre-C++11 ABI, but the tell-tale __cxx11 namespace is present when we look at the symbols with nm.

To fix this I think we need to fix up the b2_libcxx() function in https://github.com/bincrafters/conan-boost_generator/blob/stable/1.66.0/conanfile.py so that the correct flags are set.

Please see pull request bincrafters/conan-boost_generator#5 for my suggested fix.

I believe this is the root cause for issue #298, and I think pull request bincrafters/conan-boost_generator#1 also attempts to address the same underlying issue.

For examples of the boost libraries built using this fix, please see the CI builds of https://github.com/mbeach/conan-boost_program_options and https://github.com/mbeach/conan-boost_regex.

Package Details (Include if Applicable)

SSE4 commented 6 years ago

seems like the same issue as #298

SSE4 commented 6 years ago

@mbeach changes applied to boost generator, could you possibly give an another try?

mbeach commented 6 years ago

Thanks @SSE4 I'll give it a try.

mbeach commented 6 years ago

@SSE4 the changes look fine to me, as I now seem to be able to build folly for libstdc++.

datalogics-kam commented 6 years ago

Thanks for this fix. I was just about to report it myself.

This is fixing a problem for us when using devtoolset-7 on CentOS 6.10 as well. The binaries in Bintray for boost 1.66.0 still look like they're compiled for libstdc++11, but forcing a build with --build boost_test --build boost_filesystem is working for us.

Are there plans to rebuild the binaries?

[settings]
os=Linux
os_build=Linux
arch=x86_64
arch_build=x86_64
compiler=gcc
compiler.version=7
compiler.libcxx=libstdc++
build_type=Release
SSE4 commented 6 years ago

@datalogics-kam we're currently building boost 1.67, which occupies CI heavily. it will definitely take several days. after that, we may rebuild required 1.66 binaries as well.

SSE4 commented 5 years ago

I am closing this one, as fix was applied. if certain boost libraries weren't rebuilt, please open new issue(s).