Skip to contentSkip to conversation

Add BR2_TOOLCHAIN_SUPPORTS_ALWAYS_LOCKFREE_ATOMIC_INTS

PATCH New Fabrice Fontaine 2 participants 6 messages Aug 17, 2018 – Aug 18, 2018

lore
Share & tools
lore
#0 lore raw

PATCH v2 1/2 Add BR2_TOOLCHAIN_SUPPORTS_ALWAYS_LOCKFREE_ATOMIC_INTS

Add BR2_TOOLCHAIN_SUPPORTS_ALWAYS_LOCKFREE_ATOMIC_INTS variable and use it in BR2_TOOLCHAIN_HAS_GCC_BUG_64735
This new variable will be used to select boost atomic when lock-free atomic ints are not available

---
 toolchain/Config.in | 16 +++++++++++-----
 1 file changed, 11 insertions(+), 5 deletions(-)
toolchain/Config.in +11 -5
index 3a53a32a6d..ed9b59df46 100644
@@ -73,13 +73,19 @@ config BR2_TOOLCHAIN_HAS_BINUTILS_BUG_19615
 # exception_ptr, nested_exception, and future from libstdc++ are not
 # available for architectures not supporting always lock-free atomic
 # ints before GCC 7
+config BR2_TOOLCHAIN_SUPPORTS_ALWAYS_LOCKFREE_ATOMIC_INTS
+	bool
+	default y
+	depends on !BR2_nios2
+	depends on !BR2_ARM_CPU_ARMV4
+	depends on !BR2_ARM_CPU_ARMV5
+	depends on !BR2_sparc_v8
+	depends on !BR2_m68k_cf5208
+
 config BR2_TOOLCHAIN_HAS_GCC_BUG_64735
 	bool
-	default y if BR2_nios2
-	default y if BR2_ARM_CPU_ARMV4
-	default y if BR2_ARM_CPU_ARMV5
-	default y if BR2_sparc_v8
-	default y if BR2_m68k_cf5208
+	default y
+	depends on !BR2_TOOLCHAIN_SUPPORTS_ALWAYS_LOCKFREE_ATOMIC_INTS
 	depends on !BR2_TOOLCHAIN_GCC_AT_LEAST_7
 
 # https://gcc.gnu.org/bugzilla/show_bug.cgi?id=85180. This bug no
Signature · 1 line
2.14.1
#1 lore raw

PATCH v2 2/2 boost: thread needs atomic if GCC hasn't lock-free

When gcc has not always lock-free atomic ints:
- lockfree boost::atomic_flag : no

boost thread needs boost atomic:
output/host/usr/bin/nios2-linux-readelf -d output/staging/usr/lib/libboost_thread.so

Dynamic section at offset 0x2cee0 contains 32 entries:
Tag Type Name/Value
0x00000001 (NEEDED) Shared library: [libboost_system.so.1.67.0]
0x00000001 (NEEDED) Shared library: [libboost_atomic.so.1.67.0]

Fixes:
- http://autobuild.buildroot.net/results/5a7db292f1365f27e32695527701d5b827f60092
- http://autobuild.buildroot.net/results/413dff87f5329d3c5180167a8711cdedea5dec67
- http://autobuild.buildroot.net/results/a7eb4cbcdbd9412c344f45336dec58c82e84dab9

---
Changes v1 -> v2 (after review of Thomas Petazzoni):
- issue was not related to bug 64735 but to lock-free atomic ints so add a patch to toolchain/Config.in to get this information in a dedicated variable and use it in boost

 package/boost/Config.in | 1 +
 1 file changed, 1 insertion(+)
package/boost/Config.in +1 -0
index 97695e17b7..57e98c72e4 100644
@@ -313,6 +313,7 @@ config BR2_PACKAGE_BOOST_TEST
 
 config BR2_PACKAGE_BOOST_THREAD
 	bool "boost-thread"
+	select BR2_PACKAGE_BOOST_ATOMIC if !BR2_TOOLCHAIN_SUPPORTS_ALWAYS_LOCKFREE_ATOMIC_INTS
 	select BR2_PACKAGE_BOOST_CHRONO
 	select BR2_PACKAGE_BOOST_SYSTEM
 	help
Signature · 1 line
2.14.1
#2 lore raw

PATCH v2 1/2 Add BR2_TOOLCHAIN_SUPPORTS_ALWAYS_LOCKFREE_ATOMIC_INTS

In reply to Fabrice Fontaine

Hello,

Quoted 9 lines · Fabrice Fontaine

Add BR2_TOOLCHAIN_SUPPORTS_ALWAYS_LOCKFREE_ATOMIC_INTS variable and use it in BR2_TOOLCHAIN_HAS_GCC_BUG_64735
This new variable will be used to select boost atomic when lock-free atomic ints are not available

---
 toolchain/Config.in | 16 +++++++++++-----
 1 file changed, 11 insertions(+), 5 deletions(-)

Thanks a lot for this additional resarch. This time, I do agree with your findings. I improved a bit the comments in toolchain/Config.in to explain what was going on, feel free to have a look at the final commits that I applied to master.

However, we still have an issue: when static linking, libboost_atomic.a is produced even on platforms that do provide the "always lock-free atomic ints".

Examples:

- Cortex-M4

http://autobuild.buildroot.net/results/212/212651b677cfb0763b34596d4f999103039d89bc/build-end.log

   $ ./host/bin/arm-linux-gcc -dM -E - < /dev/null | grep
   ATOMIC_BOOL_LOCK_FREE #define __GCC_ATOMIC_BOOL_LOCK_FREE 2

- MIPS, statically linked

http://autobuild.buildroot.net/results/6d3/6d3db8a67a1de75920624b3e13e8110e783ddbd9/build-end.log

   $ ./host/bin/mipsel-linux-gcc -dM -E - < /dev/null | grep
   ATOMIC_BOOL_LOCK_FREE #define __GCC_ATOMIC_BOOL_LOCK_FREE 2

Do you have any idea ?

Best regards,

Thomas

Signature · 3 lines
Thomas Petazzoni, CTO, Bootlin (formerly Free Electrons)
Embedded Linux and Kernel engineering
https://bootlin.com
#3 lore raw

PATCH v2 1/2 Add BR2_TOOLCHAIN_SUPPORTS_ALWAYS_LOCKFREE_ATOMIC_INTS

Hello,

Quoted 13 lines · Thomas Petazzoni

However, we still have an issue: when static linking, libboost_atomic.a is produced even on platforms that do provide the "always lock-free atomic ints".

Examples:

- Cortex-M4

   http://autobuild.buildroot.net/results/212/212651b677cfb0763b34596d4f999103039d89bc/build-end.log

   $ ./host/bin/arm-linux-gcc -dM -E - < /dev/null | grep
   ATOMIC_BOOL_LOCK_FREE #define __GCC_ATOMIC_BOOL_LOCK_FREE 2
Quoted 6 lines

- MIPS, statically linked

http://autobuild.buildroot.net/results/6d3/6d3db8a67a1de75920624b3e13e8110e783ddbd9/build-end.log

   $ ./host/bin/mipsel-linux-gcc -dM -E - < /dev/null | grep
   ATOMIC_BOOL_LOCK_FREE #define __GCC_ATOMIC_BOOL_LOCK_FREE 2

And we have another situation here:

http://autobuild.buildroot.net/results/9c3/9c373d0b5a1a59e2271d71c480d55a90a67b84cb/build-end.log

This one is on PowerPC, and with dynamic linking. It is not going to be solved by the BR2_TOOLCHAIN_SUPPORTS_ALWAYS_LOCKFREE_ATOMIC_INTS stuff.

Thomas

Signature · 3 lines
Thomas Petazzoni, CTO, Bootlin (formerly Free Electrons)
Embedded Linux and Kernel engineering
https://bootlin.com
#4 lore raw

PATCH v2 1/2 Add BR2_TOOLCHAIN_SUPPORTS_ALWAYS_LOCKFREE_ATOMIC_INTS

Dear Thomas,

2018-08-18 21:29 GMT+02:00 Thomas Petazzoni <[email protected]>:

Quoted 26 lines

Hello,

Quoted 9 lines · Thomas Petazzoni

However, we still have an issue: when static linking, libboost_atomic.a is produced even on platforms that do provide the "always lock-free atomic ints".

Examples:

- Cortex-M4

   http://autobuild.buildroot.net/results/212/212651b677cfb0763

b34596d4f999103039d89bc/build-end.log

Quoted 7 lines
   $ ./host/bin/arm-linux-gcc -dM -E - < /dev/null | grep
   ATOMIC_BOOL_LOCK_FREE #define __GCC_ATOMIC_BOOL_LOCK_FREE 2

- MIPS, statically linked

   http://autobuild.buildroot.net/results/6d3/6d3db8a67a1de7592

0624b3e13e8110e783ddbd9/build-end.log

Quoted 3 lines
   $ ./host/bin/mipsel-linux-gcc -dM -E - < /dev/null | grep
   ATOMIC_BOOL_LOCK_FREE #define __GCC_ATOMIC_BOOL_LOCK_FREE 2
Quoted 8 lines

And we have another situation here:

http://autobuild.buildroot.net/results/9c3/9c373d0b5a1a59e22
71d71c480d55a90a67b84cb/build-end.log

This one is on PowerPC, and with dynamic linking. It is not going to be solved by the BR2_TOOLCHAIN_SUPPORTS_ALWAYS_LOCKFREE_ATOMIC_INTS stuff.

OK, this last one is easy, azmq selects BOOST_LOG but BOOST_LOG depends on !(BR2_powerpc && BR2_TOOLCHAIN_USES_UCLIBC):

warning: (BR2_PACKAGE_AZMQ) selects BR2_PACKAGE_BOOST_LOG which has unmet direct dependencies (BR2_PACKAGE_BOOST && BR2_TOOLCHAIN_HAS_THREADS_NPTL && (!BR2_powerpc || !BR2_TOOLCHAIN_USES_UCLIBC))

I will fix this by removing the dependency on !(BR2_powerpc && BR2_TOOLCHAIN_USES_UCLIBC) from BOOST_LOG as it seems that boost-log builds fine on powerpc with uclibc nowadays.

Quoted 7 lines

Thomas
--
Thomas Petazzoni, CTO, Bootlin (formerly Free Electrons) Embedded Linux and Kernel engineering
https://bootlin.com

Best Regards,

Fabrice
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.busybox.net/pipermail/buildroot/attachments/20180818/cdc513c6/attachment.html>

#5 lore raw

PATCH v2 1/2 Add BR2_TOOLCHAIN_SUPPORTS_ALWAYS_LOCKFREE_ATOMIC_INTS

Hello,

Quoted 10 lines · Fabrice Fontaine

OK, this last one is easy, azmq selects BOOST_LOG but BOOST_LOG depends on !(BR2_powerpc && BR2_TOOLCHAIN_USES_UCLIBC):

warning: (BR2_PACKAGE_AZMQ) selects BR2_PACKAGE_BOOST_LOG which has unmet direct dependencies (BR2_PACKAGE_BOOST && BR2_TOOLCHAIN_HAS_THREADS_NPTL && (!BR2_powerpc || !BR2_TOOLCHAIN_USES_UCLIBC))

I will fix this by removing the dependency on !(BR2_powerpc && BR2_TOOLCHAIN_USES_UCLIBC) from BOOST_LOG as it seems that boost-log builds fine on powerpc with uclibc nowadays.

OK. This was added by me in commit 7aaa9bee2e6009c6c00fa2a356b8f014999e9a54. There was no clear explanation of the problem, it was just "it doesn't build, and nobody cares". And it was 3 years ago, so there are high chances that the problem has been fixed either in uClibc or in Boost. So let's try to remove this dependency indeed. Waiting for your patch!

(BTW, you still haven't joined IRC! :-))

Thanks!

Thomas

Signature · 3 lines
Thomas Petazzoni, CTO, Bootlin (formerly Free Electrons)
Embedded Linux and Kernel engineering
https://bootlin.com