Boost logo

Boost-Build :

Subject: [Boost-build] b2 + iOS: weird behaviour
From: Raffi Enficiaud (raffi.enficiaud_at_[hidden])
Date: 2017-08-08 11:39:50


Hi all,

I am trying to build boost for iOS/iPhone. I have found this:

https://github.com/faithfracture/Apple-Boost-BuildScript

which is nice, but I wanted to nail it down to the bare minimum. So I am
doing this:

./b2 \
   -j2 \
 
--prefix=/Users/raffi/Code/SoftwareWorkshop/sw_thirdparties/osx/boost_1_64_0_build/install
\
   toolset=clang \
   architecture=arm \
   cxxflags="-std=c++11 -stdlib=libc++ -arch armv7 -arch arm64 -isysroot
/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS10.1.sdk
-DBOOST_AC_USE_PTHREADS -DBOOST_SP_USE_PTHREADS -g -DNDEBUG
-fvisibility=hidden -fvisibility-inlines-hidden
-Wno-unused-local-typedef -fembed-bitcode -mios-version-min=10.1"\
   define=_LITTLE_ENDIAN \
   layout=versioned \
   install

The generated static libraries are ok:

> lipo -info ./install/lib/libboost_wserialization-clang-darwin42-mt-1_64.a
Architectures in the fat file:
./install/lib/libboost_wserialization-clang-darwin42-mt-1_64.a are:
armv7 arm64

The generated dynamic libraries are not ok:
> lipo -info
./install/lib/libboost_wserialization-clang-darwin42-mt-1_64.dylib
Non-fat file:
./install/lib/libboost_wserialization-clang-darwin42-mt-1_64.dylib is
architecture: x86_64

This is not the right architecture.

The other strange thing is this:
> ls -l ./install/lib/ | grep dylib
-rwxr-xr-x 1 raffi staff 4144 Aug 7 03:18
libboost_atomic-clang-darwin42-mt-1_64.dylib
-rwxr-xr-x 1 raffi staff 4144 Aug 7 03:18
libboost_chrono-clang-darwin42-mt-1_64.dylib
-rwxr-xr-x 1 raffi staff 50040 Aug 7 03:18
libboost_container-clang-darwin42-mt-1_64.dylib
-rwxr-xr-x 1 raffi staff 4144 Aug 7 03:18
libboost_date_time-clang-darwin42-mt-1_64.dylib
-rwxr-xr-x 1 raffi staff 4144 Aug 7 03:18
libboost_filesystem-clang-darwin42-mt-1_64.dylib
-rwxr-xr-x 1 raffi staff 4144 Aug 7 03:18
libboost_graph-clang-darwin42-mt-1_64.dylib
-rwxr-xr-x 1 raffi staff 4144 Aug 7 03:18
libboost_iostreams-clang-darwin42-mt-1_64.dylib
-rwxr-xr-x 1 raffi staff 4144 Aug 7 03:18
libboost_log-clang-darwin42-mt-1_64.dylib
-rwxr-xr-x 1 raffi staff 4144 Aug 7 03:18
libboost_log_setup-clang-darwin42-mt-1_64.dylib
-rwxr-xr-x 1 raffi staff 4144 Aug 7 03:18
libboost_math_c99-clang-darwin42-mt-1_64.dylib
-rwxr-xr-x 1 raffi staff 4144 Aug 7 03:18
libboost_math_c99f-clang-darwin42-mt-1_64.dylib
-rwxr-xr-x 1 raffi staff 4144 Aug 7 03:18
libboost_math_c99l-clang-darwin42-mt-1_64.dylib
-rwxr-xr-x 1 raffi staff 4144 Aug 7 03:18
libboost_math_tr1-clang-darwin42-mt-1_64.dylib
-rwxr-xr-x 1 raffi staff 4144 Aug 7 03:18
libboost_math_tr1f-clang-darwin42-mt-1_64.dylib
-rwxr-xr-x 1 raffi staff 4144 Aug 7 03:18
libboost_math_tr1l-clang-darwin42-mt-1_64.dylib
-rwxr-xr-x 1 raffi staff 4144 Aug 7 03:18
libboost_numpy-clang-darwin42-mt-1_64.dylib
-rwxr-xr-x 1 raffi staff 4144 Aug 7 03:18
libboost_prg_exec_monitor-clang-darwin42-mt-1_64.dylib
-rwxr-xr-x 1 raffi staff 4144 Aug 7 03:18
libboost_program_options-clang-darwin42-mt-1_64.dylib
-rwxr-xr-x 1 raffi staff 4144 Aug 7 03:18
libboost_python-clang-darwin42-mt-1_64.dylib
-rwxr-xr-x 1 raffi staff 4144 Aug 7 03:18
libboost_random-clang-darwin42-mt-1_64.dylib
-rwxr-xr-x 1 raffi staff 4144 Aug 7 03:18
libboost_regex-clang-darwin42-mt-1_64.dylib
-rwxr-xr-x 1 raffi staff 4144 Aug 7 03:18
libboost_serialization-clang-darwin42-mt-1_64.dylib
-rwxr-xr-x 1 raffi staff 4144 Aug 7 03:18
libboost_signals-clang-darwin42-mt-1_64.dylib
-rwxr-xr-x 1 raffi staff 4144 Aug 7 03:18
libboost_system-clang-darwin42-mt-1_64.dylib
-rwxr-xr-x 1 raffi staff 4144 Aug 7 03:18
libboost_thread-clang-darwin42-mt-1_64.dylib
-rwxr-xr-x 1 raffi staff 4144 Aug 7 03:18
libboost_timer-clang-darwin42-mt-1_64.dylib
-rwxr-xr-x 1 raffi staff 4144 Aug 7 03:18
libboost_type_erasure-clang-darwin42-mt-1_64.dylib
-rwxr-xr-x 1 raffi staff 4144 Aug 7 03:18
libboost_unit_test_framework-clang-darwin42-mt-1_64.dylib
-rwxr-xr-x 1 raffi staff 4144 Aug 7 03:18
libboost_wave-clang-darwin42-mt-1_64.dylib
-rwxr-xr-x 1 raffi staff 4144 Aug 7 03:18
libboost_wserialization-clang-darwin42-mt-1_64.dylib

As you can see, all but boost.container *shared* libraries have exactly
the same size.

Inspecting the symbols gives:

> nm -g
./install/lib/libboost_unit_test_framework-clang-darwin42-mt-1_64.dylib

                  U dyld_stub_binder

... so close to nothing.

I believe this comes from the "-fvisibility=hidden
-fvisibility-inlines-hidden" passed to clang, but I am not sure.

Questions are:
* has anyone some experience for iOS? :)
* it is relevant to build shared libraries for iOS? I believe this makes
all the process a bit more complicated, especially because of signing.
* why is this compiling the shared libraries with the wrong
architecture? I am never passing x86_64 on the command line
* why boost.container is different from the others?
* how do we do to export what is explicitly exported? I know for sure
that classes in boost.test have the proper export directive, so those
should appear at least in the exported table name

Thanks!
Raffi


Boost-Build list run by bdawes at acm.org, david.abrahams at rcn.com, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk