boost: fix static detection of lock-free atomic ints
PATCH 1/1 boost: fix static detection of lock-free atomic ints
When build statically, boost is unable to detect lock-free atomics ints because it tries to link dynamically, see output/build/boost-1.67.0/bin.v2/config.log (with -d5 option):
Using shell: /bin/sh -c
argv[0] = '/bin/sh'
argv[1] = '-c'
argv[2] = '
"/home/fabrice/buildroot/output/host/bin/arm-linux-g++" -D_LARGEFILE_SOURCE -D_LARGEFILE64_SOURCE -D_FILE_OFFSET_BITS=64 -Os -Wl,-elf2flt -static -Wl,-elf2flt -static -fPIC -pthread -O0 -fno-inline -Wall -pedantic -g -Wextra -Wno-long-long -Wno-unused-parameter -Wunused-function -pedantic -DBOOST_ALL_NO_LIB=1 -DBOOST_SYSTEM_DYN_LINK=1 -DBOOST_THREAD_BUILD_DLL=1 -I"." -c -o "bin.v2/libs/thread/build/gcc-6.4.0/debug/threading-multi/has_atomic_flag_lockfree_test.o" "libs/thread/src/../build/has_atomic_flag_lockfree_test.cpp"'
gcc.compile.c++ bin.v2/libs/thread/build/gcc-6.4.0/debug/threading-multi/has_atomic_flag_lockfree_test.o
"/home/fabrice/buildroot/output/host/bin/arm-linux-g++" -D_LARGEFILE_SOURCE -D_LARGEFILE64_SOURCE -D_FILE_OFFSET_BITS=64 -Os -Wl,-elf2flt -static -Wl,-elf2flt -static -fPIC -pthread -O0 -fno-inline -Wall -pedantic -g -Wextra -Wno-long-long -Wno-unused-parameter -Wunused-function -pedantic -DBOOST_ALL_NO_LIB=1 -DBOOST_SYSTEM_DYN_LINK=1 -DBOOST_THREAD_BUILD_DLL=1 -I"." -c -o "bin.v2/libs/thread/build/gcc-6.4.0/debug/threading-multi/has_atomic_flag_lockfree_test.o" "libs/thread/src/../build/has_atomic_flag_lockfree_test.cpp"
0.033561 sec system; 0.126314 sec user; 288.682473 sec clock gcc.compile.c++ bin.v2/libs/system/build/gcc-6.4.0/debug/threading-multi/error_code.o
"/home/fabrice/buildroot/output/host/bin/arm-linux-g++" -D_LARGEFILE_SOURCE -D_LARGEFILE64_SOURCE -D_FILE_OFFSET_BITS=64 -Os -Wl,-elf2flt -static -Wl,-elf2flt -static -fPIC -pthread -O0 -fno-inline -Wall -pedantic -g -DBOOST_ALL_NO_LIB=1 -DBOOST_SYSTEM_DYN_LINK=1 -I"." -c -o "bin.v2/libs/system/build/gcc-6.4.0/debug/threading-multi/error_code.o" "libs/system/src/error_code.cpp"
0.084060 sec system; 0.644133 sec user; 8.858824 sec clock
SEM: <s>gcc-link-semaphore now used by <pbin.v2/libs/system/build/gcc-6.4.0/debug/threading-multi>libboost_system.so.1.67.0 Using shell: /bin/sh -c
argv[0] = '/bin/sh'
argv[1] = '-c'
argv[2] = '
"/home/fabrice/buildroot/output/host/bin/arm-linux-g++" -o "bin.v2/libs/system/build/gcc-6.4.0/debug/threading-multi/libboost_system.so.1.67.0" -Wl,-h -Wl,libboost_system.so.1.67.0 -shared -Wl,--start-group "bin.v2/libs/system/build/gcc-6.4.0/debug/threading-multi/error_code.o" -Wl,-Bstatic -Wl,-Bdynamic -lrt -Wl,--end-group -fPIC -pthread -g -Wl,-elf2flt -static'
gcc.link.dll bin.v2/libs/system/build/gcc-6.4.0/debug/threading-multi/libboost_system.so.1.67.0
"/home/fabrice/buildroot/output/host/bin/arm-linux-g++" -o "bin.v2/libs/system/build/gcc-6.4.0/debug/threading-multi/libboost_system.so.1.67.0" -Wl,-h -Wl,libboost_system.so.1.67.0 -shared -Wl,--start-group "bin.v2/libs/system/build/gcc-6.4.0/debug/threading-multi/error_code.o" -Wl,-Bstatic -Wl,-Bdynamic -lrt -Wl,--end-group -fPIC -pthread -g -Wl,-elf2flt -static
ld (ld-elf2flt): -shared used without passing a shared library ID
collect2: error: ld a retourn? le statut de sortie 1
0.003123 sec system; 0.004732 sec user; 15.646509 sec clock
...failed gcc.link.dll bin.v2/libs/system/build/gcc-6.4.0/debug/threading-multi/libboost_system.so.1.67.0...
Due to this wrong detection, boost_atomic is wrongly selected by boost_thread which cause a build failure on missing select
Add a hack to fix this behavior in libs/thread/build/Jamfile.v2 as I'm not sufficiently knowledgeable in bjam to know why the configuration is not correctly passed
Fixes:
- http://autobuild.buildroot.net/results/bfc004ba10b50d4294be5ccd0abef7c00ed074d5
--- package/boost/boost.mk | 10 ++++++++++ 1 file changed, 10 insertions(+)
package/boost/boost.mk +10 -0
@@ -106,6 +106,16 @@ endif # variants. Override that if we want static only or shared only. ifeq ($(BR2_STATIC_LIBS),y) BOOST_OPTS += link=static runtime-link=static + +# When detecting features such as lockfree atomic ints, boost does not take into +# account the configuration provided by the user. Indeed, boost does not specify +# any value and as a result the default value (shared) is used +define BOOST_FIX_STATIC_FEATURES_DETECTION +$(SED) 's/has_atomic_flag_lockfree_test.cpp/has_atomic_flag_lockfree_test.cpp : <link>static <runtime-link>static/g;' \ + $(@D)/libs/thread/build/Jamfile.v2 +endef + +BOOST_PRE_CONFIGURE_HOOKS += BOOST_FIX_STATIC_FEATURES_DETECTION else ifeq ($(BR2_SHARED_LIBS),y) BOOST_OPTS += link=shared runtime-link=shared endif
Signature · 1 line
2.17.1
PATCH 1/1 boost: fix static detection of lock-free atomic ints
Hi Fabrice,
Quoted 13 lines · Fabrice Fontaine
Fixes:
- http://autobuild.buildroot.net/results/bfc004ba10b50d4294be5ccd0abef7c00ed074d5Signed-off-by Fabrice Fontaine <[email protected]>--- package/boost/boost.mk | 10 ++++++++++ 1 file changed, 10 insertions(+)package/boost/boost.mk +0
-0
package/boost/boost.mk endif · line 107
Quoted 2 lines
package/boost/boost.mk +0
-0@@ -106,6 +106,16 @@ endif # variants. Override that if we want static only or shared only. ifeq ($(BR2_STATIC_LIBS),y)
Ahem, the autobuild failure you refer to actually has BR2_SHARED_LIBS=y, so how
can this fix the issue?
Looking at the failing command (from your commit log):
"/home/fabrice/buildroot/output/host/bin/arm-linux-g++" -o
"bin.v2/libs/system/build/gcc-6.4.0/debug/threading-multi/libboost_system.so.1.67.0" -Wl,-h -Wl,libboost_system.so.1.67.0 -shared -Wl,--start-group "bin.v2/libs/system/build/gcc-6.4.0/debug/threading-multi/error_code.o" -Wl,-Bstatic -Wl,-Bdynamic -lrt -Wl,--end-group -fPIC -pthread -g -Wl,-elf2flt -static
It's doing a link without TARGET_LDFLAGS, and TARGET_LDFLAGS contains the
-mid-shared-library -mshared-library-id=0 that is needed to link a shared library on FLT.
And it makes sense that TARGET_LDFLAGS are not used, because we only pass that
*after* bootstrap.sh (I assume this stuff is evaluated by bootstrap.sh, and not when running bjam itself?) Or, if it is evaluated by bjam, somehow bjam is ignoring the linkflags we pass in user-config.jam.
package/boost/boost.mk endif · line 115
Quoted 8 lines
package/boost/boost.mk +7
-0BOOST_OPTS += link=static runtime-link=static + +# When detecting features such as lockfree atomic ints, boost does not take into +# account the configuration provided by the user. Indeed, boost does not specify +# any value and as a result the default value (shared) is used +define BOOST_FIX_STATIC_FEATURES_DETECTION +$(SED) 's/has_atomic_flag_lockfree_test.cpp/has_atomic_flag_lockfree_test.cpp : <link>static <runtime-link>static/g;' \ + $(@D)/libs/thread/build/Jamfile.v2
If such a change is needed for has_atomic_flag_lockfree, isn't it also needed
for the other build-time tests? has_iconv, has_icu, native_syslog, ...
Since I believe this patch cannot work, I've marked it as Changes Requested.
Regards,
Arnout
Quoted 3 lines
package/boost/boost.mk +3
-0+endef + +BOOST_PRE_CONFIGURE_HOOKS += BOOST_FIX_STATIC_FEATURES_DETECTION
Signature · 6 lines
Arnout Vandecappelle arnout at mind be Senior Embedded Software Architect +32-16-286500 Essensium/Mind http://www.mind.be G.Geenslaan 9, 3001 Leuven, Belgium BE 872 984 063 RPR Leuven LinkedIn profile: http://www.linkedin.com/in/arnoutvandecappelle GPG fingerprint: 7493 020B C7E3 8618 8DEC 222C 82EB F404 F9AC 0DDF
PATCH 1/1 boost: fix static detection of lock-free atomic ints
Dear Arnout,
Le mar. 4 sept. 2018 ? 23:39, Arnout Vandecappelle <[email protected]> a ?crit :
Quoted 13 lines
Hi Fabrice,
Quoted 2 lines · Fabrice Fontaine
Fixes:
-http://autobuild.buildroot.net/results/bfc004ba10b50d4294be5ccd0abef7c00ed074d5
Quoted 6 lines
Signed-off-by Fabrice Fontaine <[email protected]>--- package/boost/boost.mk | 10 ++++++++++ 1 file changed, 10 insertions(+)
Quoted 12 lines
package/boost/boost.mk endif · line 107
Quoted 7 lines
package/boost/boost.mk +0
-0@@ -106,6 +106,16 @@ endif # variants. Override that if we want static only or shared only. ifeq ($(BR2_STATIC_LIBS),y)Ahem, the autobuild failure you refer to actually has BR2_SHARED_LIBS=y,
so how
can this fix the issue?
Sorry, I was a little sleepy and the link was not the correct one, it took me a lot of time to find how to find the beginning of a fix for this issue :-(.
I will send a v2 with the correct one but basically this is fixing a lot of build falures:
http://autobuild.buildroot.org/?branch=master&status=NOK&static=1
Quoted 14 lines
Looking at the failing command (from your commit log):
"
/home/fabrice/buildroot/output/host/bin/arm-linux-g++" -o"bin.v2/libs/system/build/gcc-6.4.0/debug/threading-multi/libboost_system.so.1.67.0" -Wl,-h -Wl,libboost_system.so.1.67.0 -shared -Wl,--start-group "
bin.v2/libs/system/build/gcc-6.4.0/debug/threading-multi/error_code.o"(quoted diff) +0
-4-Wl,-Bstatic -Wl,-Bdynamic -lrt -Wl,--end-group -fPIC -pthread -g -Wl,-elf2flt -static It's doing a link without TARGET_LDFLAGS, and TARGET_LDFLAGS contains the -mid-shared-library -mshared-library-id=0 that is needed to link a shared
Quoted 2 lines
library on FLT.
The issue is that bjam takes the TARGET_LDFLAGS which have -Wl,-elf2flt -static but also adds its own flags such as -Wl,-Bdynamic -fPIC because it thinks it has to do a dynamic link.
This is more clear if you read also the console log with bjam configured to debug level 5 (-d5):
(builtin):>>>>|>>>>|>>>>|>>>>|>>>>|>>>>|>>>>|>>>>|>>>>|>>>>|>>>>|>>>>|>>>>|>>>>|>>>>|>>>>|>>>>|>>>>|>>>>|>>>>|
gcc.link
<pbin.v2/libs/thread/build/gcc-6.4.0/debug/threading-multi>has_atomic_flag_lockfree
:
<pbin.v2/libs/thread/build/gcc-6.4.0/debug/threading-multi>has_atomic_flag_lockfree_test.o <pbin.v2/libs/system/build/gcc-6.4.0/debug/threading-multi>libboost_system.so.1.67.0
: <abi>sysv <address-model>32 <architecture>arm <asynch-exceptions>off
<binary-format>elf <context-impl>fcontext <cxxflags>-Wextra
<cxxflags>-Wno-long-long <cxxflags>-Wno-unused-parameter
<cxxflags>-Wunused-function <cxxflags>-pedantic <debug-symbols>on
<deduced-address-model>32 <deduced-architecture>arm
<define>BOOST_ALL_NO_LIB=1 <define>BOOST_SYSTEM_DYN_LINK=1
<define>BOOST_THREAD_BUILD_DLL=1 <dll-path>/home/fabrice/buildroot/output/build/boost-1.67.0/bin.v2/libs/system/build/gcc-6.4.0/debug/threading-multi <exception-handling>on <extern-c-nothrow>off <hardcode-dll-paths>true
<host-os>linux <implicit-dependency>object(notfile-target)@2281 <include>.
<inlining>off <install-dependencies>off <library>object(file-target)@2595
<link>shared <main-target-type>EXE <optimization>off <os>LINUX <pch>on
<preserve-test-targets>on <profiling>off <python-debugging>off
<python.interpreter>python <python>2.7 <relevant>address-model
<relevant>architecture <relevant>c++-template-depth <relevant>cflags
<relevant>context-impl <relevant>cxxflags
<relevant>cxxflags:<relevant>toolset <relevant>cxxstd
<relevant>cxxstd-dialect <relevant>debug-symbols
<relevant>deduced-address-model <relevant>deduced-architecture
<relevant>define <relevant>define:<relevant>link
<relevant>define:<relevant>target-os <relevant>define:<relevant>toolset
<relevant>dll-path <relevant>exception-handling
<relevant>find-shared-library <relevant>find-static-library <relevant>htm
<relevant>include <relevant>inlining <relevant>instruction-set
<relevant>library-file <relevant>library-path <relevant>link
<relevant>link:<relevant>toolset <relevant>linkflags <relevant>optimization
<relevant>pch <relevant>pch-file <relevant>profiling
<relevant>python.interpreter:<relevant>python
<relevant>python.interpreter:<relevant>target-os <relevant>rtti
<relevant>runtime-link <relevant>segmented-stacks <relevant>strip
<relevant>target-os <relevant>threadapi:<relevant>target-os
<relevant>threading <relevant>toolset <relevant>toolset-gcc:version
<relevant>valgrind <relevant>variant <relevant>warnings
<relevant>warnings-as-errors <relevant>warnings:<relevant>toolset
<relevant>wavetool <relevant>xdll-path <rtti>on <runtime-debugging>on
<runtime-link>shared <stdlib>native <strip>off <suppress-import-lib>false
<symlink-location>project-relative <tag>@Jamfile</home/fabrice/buildroot/output/build/boost-1.67.0/libs/thread/build>%Jamfile</home/fabrice/buildroot/output/build/boost-1.67.0/libs/thread/build>.tag <target-os>linux <testing.execute>on <threadapi>pthread <threading>multi
<toolset-gcc:version>6.4.0 <toolset>gcc <user-interface>console
<variant>debug <vectorize>off <warnings-as-errors>off <warnings>all <xdll-path>/home/fabrice/buildroot/output/build/boost-1.67.0/bin.v2/libs/system/build/gcc-6.4.0/debug/threading-multi
<xsl:param>boost.defaults=Boost : : : : : : : : : : : : : : : (builtin):>>>>|>>>>|>>>>|>>>>|>>>>|>>>>|>>>>|>>>>|>>>>|>>>>|>>>>|>>>>|>>>>|>>>>|>>>>|>>>>|>>>>|>>>>|>>>>|>>>>|>>
gcc.quote-rpath <pbin.v2/libs/thread/build/gcc-6.4.0/debug/threading-multi>has_atomic_flag_lockfree (builtin):>>>>|>>>>|>>>>|>>>>|>>>>|>>>>|>>>>|>>>>|>>>>|>>>>|>>>>|>>>>|>>>>|>>>>|>>>>|>>>>|>>>>|>>>>|>>>>|>>>>|>>>> MATCH ('.*') :/home/fabrice/buildroot/output/build/boost-1.67.0/bin.v2/libs/system/build/gcc-6.4.0/debug/threading-multi (builtin):>>>>|>>>>|>>>>|>>>>|>>>>|>>>>|>>>>|>>>>|>>>>|>>>>|>>>>|>>>>|>>>>|>>>>|>>>>|>>>>|>>>>|>>>>|>>>> common.Clean clean-all :
<pbin.v2/libs/thread/build/gcc-6.4.0/debug/threading-multi>has_atomic_flag_lockfree (builtin):>>>>|>>>>|>>>>|>>>>|>>>>|>>>>|>>>>|>>>>|>>>>|>>>>|>>>>|>>>>|>>>>|>>>>|>>>>|>>>>|>>>>|> RULENAMES (builtin):>>>>|>>>>|>>>>|>>>>|>>>>|>>>>|>>>>|>>>>|>>>>|>>>>|>>>>|>>>>|>>>>|>>>>|>>>>|>>>>|>>>>|>
PAD - lockfree boost::atomic_flag : 30
(builtin):>>>>|>>>>|>>>>|>>>>|>>>>|>>>>|>>>>|>>>>|>>>>|>>>>|>>>>|>>>>|>>>>|>>>>|>>>>|>>>>|>>>>|> UPDATE_NOW
<pbin.v2/libs/thread/build/gcc-6.4.0/debug/threading-multi>has_atomic_flag_lockfree
: 7 : ignore-minus-n : ignore-minus-q (builtin):>>>>|>>>>|>>>>|>>>>|>>>>|>>>>|>>>>|>>>>|>>>>|>>>>|>>>>|>>>>|>>>>|>>>>|>>>>|>>>>|>>>>|>
configure.log-check-result - lockfree boost::atomic_flag : no
You can see in the trace above that link and runtimelink are set to shared even if we tell bjam to use static in BOOST_OPTS.
bjam seems to use the default value for these parameters as if I change the order of shared and static in boost-1.67.0/tools/build/src/tools/features/runtime-feature.jam and boost-1.67.0/tools/build/src/tools/features/link-feature.jam, the link will be static.
Quoted 8 lines
And it makes sense that
TARGET_LDFLAGSare not used, because we only pass
that
*after*bootstrap.sh(I assume this stuff is evaluated bybootstrap.sh, and not
when running bjam itself?) Or, if it is evaluated by bjam, somehow bjam is ignoring the linkflags we pass in user-config.jam.
From my understanding, this is evaluated by bjam and bjam ignores link or runtime-link option when using the exe command. I think it use it only for the lib directive but I don't know how to fix it "properly".
Quoted 12 lines
package/boost/boost.mk endif
Quoted 4 lines
package/boost/boost.mk +2
-0BOOST_OPTS += link=static runtime-link=static + +# When detecting features such as lockfree atomic ints, boost does nottake into
package/boost/boost.mk endif · line 111
Quoted 1 line
package/boost/boost.mk +1
-0+# account the configuration provided by the user. Indeed, boost doesnot specify
package/boost/boost.mk endif
Quoted 3 lines
package/boost/boost.mk +3
-0+# any value and as a result the default value (shared) is used +define BOOST_FIX_STATIC_FEATURES_DETECTION +$(SED)'s/has_atomic_flag_lockfree_test.cpp/has_atomic_flag_lockfree_test.cpp :
<link>static <runtime-link>static/g;' \
Quoted 6 lines
package/boost/boost.mk endif · line 115
Quoted 1 line
package/boost/boost.mk +1
-0+ $(@D)/libs/thread/build/Jamfile.v2If such a change is needed for
has_atomic_flag_lockfree, isn't it also
needed
for the other build-time tests?has_iconv,has_icu,native_syslog, ...
From my understanding, this is only needed for the exe directive which is indeed used in boost-1.67.0/libs/locale/build/Jamfile.v2 to detect icu or iconv support.
For now, I did not check if the detection of these features was working when building statically.
Quoted 13 lines
Since I believe this patch cannot work, I've marked it as Changes
Requested.Regards,
Arnoutpackage/boost/boost.mk endif · line 118
Quoted 3 lines
package/boost/boost.mk +3
-0+endef + +BOOST_PRE_CONFIGURE_HOOKS += BOOST_FIX_STATIC_FEATURES_DETECTION--
Quoted 7 lines
Arnout Vandecappelle arnout at mind be Senior Embedded Software Architect +32-16-286500 Essensium/Mind http://www.mind.be G.Geenslaan 9, 3001 Leuven, Belgium BE 872 984 063 RPR Leuven LinkedIn profile: http://www.linkedin.com/in/arnoutvandecappelle GPG fingerprint: 7493 020B C7E3 8618 8DEC 222C 82EB F404 F9AC 0DDF
Best Regards,
Fabrice
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.busybox.net/pipermail/buildroot/attachments/20180905/de95525d/attachment-0001.html>