Boost logo

Boost :

Subject: [boost] [visibility][test][osx] visibility warnings with 1.70beta
From: Raffi Enficiaud (raffi.enficiaud_at_[hidden])
Date: 2019-03-27 19:16:00


Hi,

I have a side project that requires boost.test and I thought it is the
right time to use the beta build of 1.70. At link time for my project
(in this case a simple boost.test module), I have tons of warnings like
the following:

ld: warning: direct access in function
'boost::unit_test::decorator::depends_on::apply(boost::unit_test::test_unit&)'
from file
'/Users/raffi/from-big-laptop/code/software_workshop/sw_thirdparties/osx/boost_1_70_0_b1/lib/libboost_unit_test_framework-xgcc42-mt-x64-1_70.a(decorator.o)'
to global weak symbol 'boost::unit_test::basic_cstring<char
const>::null_str()::null' from file
'/Users/raffi/code/mpi/mpi_kmeans/build/MPI-Kmeans.build/Debug/test_mpi_kmeans.build/Objects-normal/x86_64/test_cls_and_func_impl.o'
means the weak symbol cannot be overridden at runtime. This was likely
caused by different translation units being compiled with different
visibility settings.

running Xcode 10.1 on 10.14/mojave.

I am building boost like this:

./b2 \
  cflags="-mmacosx-version-min=10.10" \
  cxxflags="-std=c++11 -stdlib=libc++ -mmacosx-version-min=10.10" \
  mflags="-mmacosx-version-min=10.10" \
  mmflags="-mmacosx-version-min=10.10" \
  linkflags="-stdlib=libc++ -mmacosx-version-min=10.10" \
  --prefix=`pwd`/../${build_folder} \
  --without-log \
  --layout=versioned \
  install

Each of the files that are being built in my project and that are
raising the warning have a compilation command like this:

/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/c++
 -DBOOST_ALL_NO_LIB -DKMEANS_VERBOSE=0
-I/Users/raffi/code/mpi/mpi_kmeans/include
-I/Users/raffi/code/mpi/mpi_kmeans/applications/include -isystem
/Users/raffi/from-big-laptop/code/software_workshop/sw_thirdparties/osx/boost_1_70_0_b1/include/boost-1_70
 -O3 -DNDEBUG -std=gnu++11 -o
CMakeFiles/test_mpi_kmeans.dir/test/test_kmeans.cpp.o -c
/Users/raffi/code/mpi/mpi_kmeans/test/test_kmeans.cpp

which is pretty much what I had so far and before 1.70.

Boost.test is using BOOST_SYMBOL_VISIBLE to make a symbol public,
including the static build variant. Why does the linker say

"""
This was likely caused by different translation units being compiled
with different visibility settings.
"""

is completely unclear to me. How can I inspect what b2 emits as
compilation command line for further debugging?
All those visibility issues are causing me a lot of headache :)

Thanks!
Raffi


Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk