Boost logo

Boost :

From: Rainer Deyke (rdeyke_at_[hidden])
Date: 2024-03-12 12:17:15


On 12.03.24 11:11, Peter Dimov via Boost wrote:
> Rainer Deyke wrote:
>> I am trying to produce portable binaries while using modern C++, so my policy
>> is this:
>> - Compile on a Docker image with an older OS installed (currently Ubuntu
>> 16.04 LTS) so that I can link to an older libc.
>> - Build my own compiler (currently gcc 13.2.0) instead of relying on the OS
>> package manager. This means libraries are installed in
>> /usr/local/lib64 instead of /usr/lib.
>> - Statically link everything except libc, including libstdc++ (by setting
>> CXXFLAGS=-static-libstdc++).
>> - Deliberately don't point LD_LIBRARY_PATH to /usr/local/lib64, because
>> these libraries won't exist on the target system and should only be statically
>> linked.
>>
>> The problem is that while tools/build/src/engine/build.sh respects CXXFLAGS,
>> bootstrap.sh deliberately clobbers CXXFLAGS from the environment, so b2 is
>> built dynamically linked to a version of libstdc++ that it can't find at runtime.
>
> You should use the --cxxflags option.

That would work for tools/build/src/engine/build.sh, but bootstrap.sh
neither understands that argument nor passes it along to build.sh.

Anyway, now that I understand the problem, it's not hard to work around
it by setting LD_LIBRARY_PATH just for while I'm building Boost. I
managed to successfully build the subset of Boost that I am interested
in, although I did get a warning about undefined behavior:

In file included from libs/container/src/dlmalloc_ext_2_8_6.c:52,
                  from libs/container/src/alloc_lib.c:24:
In function ‘internal_multialloc_arrays’,
     inlined from ‘boost_cont_multialloc_arrays’ at
libs/container/src/dlmalloc_ext_2_8_6.c:1112:13:
libs/container/src/dlmalloc_ext_2_8_6.c:1085:41: warning: iteration
2305843009213693951 invokes undefined behavior
[-Waggressive-loop-optimizations]
  1085 | size = request2size(sizes[i]*element_size);
       | ^
libs/container/src/dlmalloc_2_8_6.c:2231:6: note: in definition of macro
‘request2size’
  2231 | (((req) < MIN_REQUEST)? MIN_CHUNK_SIZE : pad_request(req))
       | ^~~
libs/container/src/dlmalloc_ext_2_8_6.c:1083:24: note: within this loop
  1083 | for(++i; i != next_i; ++i) {
       | ~~^~~~~~~~~

-- 
Rainer Deyke (rainerd_at_[hidden])

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