Skip to contentSkip to conversation

boost: context needs thread if gcc <= 4.6

PATCH New Fabrice Fontaine 2 participants 4 messages Aug 20, 2018 – Aug 21, 2018

lore
Share & tools
lore
#0 lore raw

PATCH v2 1/2 boost: context needs thread if gcc <= 4.6

mutex is available on gcc 4.7.x, the issue is that boost does not correctly detect it because -std=c++11 is missing.
Keep thread select for gcc version lower or equal to 4.6

---
Changes v1 -> v2 (after review of Thomas Petazzoni):
- Update first patch to keep selection of boost-thread but lower gcc version from 4.8 to 4.7
- Update second patch to add -std=c++11 only if gcc >= 4.7

 package/boost/Config.in | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
package/boost/Config.in +1 -1
index 965d198ebf..627cf2f356 100644
@@ -83,7 +83,7 @@ config BR2_PACKAGE_BOOST_CONTEXT
 	bool "boost-context"
 	depends on BR2_PACKAGE_BOOST_CONTEXT_ARCH_SUPPORTS
 	depends on !BR2_TOOLCHAIN_HAS_GCC_BUG_64735
-	select BR2_PACKAGE_BOOST_THREAD if !BR2_TOOLCHAIN_GCC_AT_LEAST_4_8
+	select BR2_PACKAGE_BOOST_THREAD if !BR2_TOOLCHAIN_GCC_AT_LEAST_4_7
 	help
 	  C++11 context switching library.
 
Signature · 1 line
2.14.1
#1 lore raw

PATCH v2 2/2 boost: context needs C++11

Without this flag, mutex is not always correctly detected with gcc 4.x or 5.x. As a result, boost_thread is wrongly selected by boost_context.

Fixes:
- http://autobuild.buildroot.net/results/fb046c04fe18bec973d120e4ab33971f32ba5769
- http://autobuild.buildroot.net/results/99f1a255b78a973faeb8bf3b94d78efc54426a8b

---
Changes v1 -> v2 (after review of Thomas Petazzoni):
- Update first patch to keep selection of boost-thread but lower gcc version from 4.8 to 4.7
- Update second patch to add -std=c++11 only if gcc >= 4.7

 package/boost/boost.mk | 5 +++++
 1 file changed, 5 insertions(+)
package/boost/boost.mk +5 -0
index 14f6162003..f4a44fa123 100644
@@ -61,6 +61,11 @@ else
 BOOST_FLAGS += --without-icu
 endif
 
+# boost-context needs C++11
+ifeq ($(BR2_PACKAGE_BOOST_CONTEXT)$(BR2_TOOLCHAIN_GCC_AT_LEAST_4_7),yy)
+BOOST_TARGET_CXXFLAGS += -std=c++11
+endif
+
 ifeq ($(BR2_PACKAGE_BOOST_IOSTREAMS),y)
 BOOST_DEPENDENCIES += bzip2 zlib
 endif
Signature · 1 line
2.14.1
#2 lore raw

PATCH v2 1/2 boost: context needs thread if gcc <= 4.6

In reply to Fabrice Fontaine

Hello,

Quoted 2 lines · Fabrice Fontaine

mutex is available on gcc 4.7.x, the issue is that boost does not correctly detect it because -std=c++11 is missing.

Where did you get the information that mutex is available since gcc 4.7 ? Is it by testing gcc 4.6 and 4.7 ?

I couldn't get this information by looking at
https://gcc.gnu.org/projects/cxx-status.html#cxx11.

Also, I am wondering if the two patches should really be separate. Aren't they in fact both intimately related, where std::mutex will only be visible in gcc >= 4.7 if std=c++11 is passed ?

To me, they are basically one single patch:

- Below gcc 4.7, we don't have std::mutex, so boost-thread must be used
- Above gcc 4.7, we have std::mutex, but we need to pass std=c++11 for std::mutex to be visible/usable

Thanks,

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 boost: context needs thread if gcc <= 4.6

Dear Thomas,

Le mar. 21 ao?t 2018 ? 11:27, Thomas Petazzoni <[email protected]> a ?crit :

Quoted 9 lines

Hello,

Quoted 2 lines · Fabrice Fontaine

mutex is available on gcc 4.7.x, the issue is that boost does not correctly detect it because -std=c++11 is missing.

Where did you get the information that mutex is available since gcc 4.7 ? Is it by testing gcc 4.6 and 4.7 ?

I tested with 4.7. but std::mutex is very old, it exists since gcc 4.4 (see history of
https://github.com/gcc-mirror/gcc/blob/gcc-4_7_0-release/libstdc%2B%2B-v3/include/std/mutex
).
As a result, it probably also works on gcc 4.4, 4.5 and 4.6 but we'll have to add std=c++0x instead of std=c++11. However, it seems that the current best practice in buildroot is to add a dependency on gcc 4.7 (poppler), 4.8 (mongodb) or 4.9 (upmpdcli) for C+11 packages (depending on the C++11 features required by the package). We're also adding std=c++11 for 6 C++11 packages (flatbuffers, libcrossguid, libmediaart, libv4l, mosh, ...) but we never add std=c++0x (except for host-kodi).

Quoted 8 lines

I couldn't get this information by looking at
https://gcc.gnu.org/projects/cxx-status.html#cxx11.

Also, I am wondering if the two patches should really be separate. Aren't they in fact both intimately related, where std::mutex will only be visible in gcc >= 4.7 if std=c++11 is passed ?

Quoted 6 lines

To me, they are basically one single patch:

- Below gcc 4.7, we don't have std::mutex, so boost-thread must be used
- Above gcc 4.7, we have std::mutex, but we need to pass std=c++11 for std::mutex to be visible/usable

OK I will merge both patches.

Quoted 9 lines

Thanks,

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/20180821/77062737/attachment.html>