Opened 10 years ago

Closed 9 years ago

Last modified 9 years ago

#8458 closed Bugs (fixed)

-DBOOST_THREAD_DONT_USE_CHRONO in thread.obj.rsp but not explicitly set

Reported by: lukeocamden@… Owned by: viboes
Milestone: Boost 1.54.0 Component: thread
Version: Boost 1.53.0 Severity: Problem
Keywords: Cc:

Description

Wondering if anyone can reproduce this on Windows. In my setup I don't specify BOOST_THREAD_DONT_USE_CHRONO anywhere but it appears in the generated rsp files which are used to build boost. Unless I'm doing something wrong this would contradict the documentation at http://www.boost.org/doc/libs/1_53_0/doc/html/thread/build.html which states:

"Boost.Thread uses by default Boost.Chrono for the time related functions and define BOOST_THREAD_USES_CHRONO if BOOST_THREAD_DONT_USE_CHRONO is not defined. The user should define BOOST_THREAD_DONT_USE_CHRONO for compilers that don't work well with Boost.Chrono."

An unfortunate consequence is that boost::thread::try_join_until(const chrono::time_point<chrono::system_clock, chrono::nanoseconds>&) is marked with dllimport but is not actually exported by the boost thread dll. LNK2001 ensues!

I attach a patch which seems to fix the problem for me.

Attachments (3)

thread_use_chrono.patch (274 bytes ) - added by anonymous 10 years ago.
8458.patch (161 bytes ) - added by viboes 9 years ago.
Please, could you check the attached patch?
8458.2.patch (7.6 KB ) - added by viboes 9 years ago.
Replaced erroneus patch

Download all attachments as: .zip

Change History (18)

by anonymous, 10 years ago

Attachment: thread_use_chrono.patch added

comment:1 by viboes, 10 years ago

Are you sure you are using 1.53? Where do you see that

boost::thread::try_join_until(const chrono::time_point<chrono::system_clock, chrono::nanoseconds>&);

is declared with dllimport?

comment:2 by viboes, 10 years ago

Owner: changed from Anthony Williams to viboes
Status: newassigned

in reply to:  1 ; comment:3 by anonymous, 10 years ago

Replying to viboes:

Are you sure you are using 1.53? Where do you see that

boost::thread::try_join_until(const chrono::time_point<chrono::system_clock, chrono::nanoseconds>&);

is declared with dllimport?

It's implicitly dllexport/dllimport because the whole class boost::thread is declared so via BOOST_THREAD_DECL.

in reply to:  3 ; comment:4 by viboes, 10 years ago

Replying to anonymous:

Replying to viboes:

Are you sure you are using 1.53? Where do you see that

boost::thread::try_join_until(const chrono::time_point<chrono::system_clock, chrono::nanoseconds>&);

is declared with dllimport?

It's implicitly dllexport/dllimport because the whole class boost::thread is declared so via BOOST_THREAD_DECL.

Thanks for clarification. I don't know how to use msvc import/export correctly. Could I remove the BOOST_THREAD_DECL on the class thread declaration and add it to the functions that are really exported?

in reply to:  4 comment:5 by anonymous, 9 years ago

Replying to viboes:

Replying to anonymous:

Replying to viboes:

Are you sure you are using 1.53? Where do you see that

boost::thread::try_join_until(const chrono::time_point<chrono::system_clock, chrono::nanoseconds>&);

is declared with dllimport?

It's implicitly dllexport/dllimport because the whole class boost::thread is declared so via BOOST_THREAD_DECL.

Thanks for clarification. I don't know how to use msvc import/export correctly. Could I remove the BOOST_THREAD_DECL on the class thread declaration and add it to the functions that are really exported?

Yes I think that would work fine (untested). Thanks for taking a look at this.

by viboes, 9 years ago

Attachment: 8458.patch added

Please, could you check the attached patch?

comment:6 by anonymous, 9 years ago

Would you mind attaching a unified diff?

by viboes, 9 years ago

Attachment: 8458.2.patch added

Replaced erroneus patch

in reply to:  6 ; comment:7 by viboes, 9 years ago

Replying to anonymous:

Would you mind attaching a unified diff?

I did a svn st instead of a svn diff :( Please take a look at 8458.2.patch.

in reply to:  7 comment:8 by anonymous, 9 years ago

Replying to viboes:

Replying to anonymous:

Would you mind attaching a unified diff?

I did a svn st instead of a svn diff :( Please take a look at 8458.2.patch.

This doesn't build for me. I think you changed boost::this_thread::get_id() but you meant to change boost::thread::get_id(). Btw I'm not convinced you need the additional decoration in the cpp file: isn't it implied by what's in the header file? It's possible I'm misunderstanding something.

comment:9 by viboes, 9 years ago

Milestone: To Be DeterminedBoost 1.54.0

After more deeper analysis I will not fix it, and Boost.Thread will need Boost.Chrono on Windows. I'll force it and documented the constraint.

in reply to:  9 comment:10 by anonymous, 9 years ago

Replying to viboes:

After more deeper analysis I will not fix it, and Boost.Thread will need Boost.Chrono on Windows. I'll force it and documented the constraint.

OK great. I'll test any patch you post here.

comment:11 by viboes, 9 years ago

Could you tell me if the following works for you?

svn diff  libs/thread/build/Jamfile.v2 boost/thread/detail/config.hpp 
Index: libs/thread/build/Jamfile.v2
===================================================================
--- libs/thread/build/Jamfile.v2	(revision 84414)
+++ libs/thread/build/Jamfile.v2	(working copy)
@@ -263,8 +263,11 @@
                 result = <build>no ;
             }
         }
+        result += <define>BOOST_THREAD_DONT_USE_CHRONO ;
+    } else {
+        result += <define>BOOST_THREAD_USES_CHRONO ;
+        result += <library>/boost/chrono//boost_chrono ;
     }
-    result += <define>BOOST_THREAD_DONT_USE_CHRONO ;
 
     if <toolset>pgi in $(properties)  || <toolset>vacpp in $(properties)
     {
Index: boost/thread/detail/config.hpp
===================================================================
--- boost/thread/detail/config.hpp	(revision 84414)
+++ boost/thread/detail/config.hpp	(working copy)
@@ -318,6 +318,11 @@
 #define BOOST_THREAD_USES_DATETIME
 #endif
 
+#if defined(BOOST_THREAD_PLATFORM_WIN32) && defined BOOST_THREAD_DONT_USE_CHRONO
+#undef BOOST_THREAD_DONT_USE_CHRONO
+#define BOOST_THREAD_USES_CHRONO
+#endif
+
 // BOOST_THREAD_PROVIDES_DEPRECATED_FEATURES_SINCE_V3_0_0 defined by default up to Boost 1.55
 // BOOST_THREAD_DONT_PROVIDE_DEPRECATED_FEATURES_SINCE_V3_0_0 defined by default up to Boost 1.55
 #if defined BOOST_THREAD_PROVIDES_DEPRECATED_FEATURES_SINCE_V3_0_0

comment:12 by viboes, 9 years ago

Committed in trunk [84709]

in reply to:  11 comment:13 by anonymous, 9 years ago

Replying to viboes:

Could you tell me if the following works for you?

svn diff  libs/thread/build/Jamfile.v2 boost/thread/detail/config.hpp 
Index: libs/thread/build/Jamfile.v2
===================================================================
--- libs/thread/build/Jamfile.v2	(revision 84414)
+++ libs/thread/build/Jamfile.v2	(working copy)
@@ -263,8 +263,11 @@
                 result = <build>no ;
             }
         }
+        result += <define>BOOST_THREAD_DONT_USE_CHRONO ;
+    } else {
+        result += <define>BOOST_THREAD_USES_CHRONO ;
+        result += <library>/boost/chrono//boost_chrono ;
     }
-    result += <define>BOOST_THREAD_DONT_USE_CHRONO ;
 
     if <toolset>pgi in $(properties)  || <toolset>vacpp in $(properties)
     {
Index: boost/thread/detail/config.hpp
===================================================================
--- boost/thread/detail/config.hpp	(revision 84414)
+++ boost/thread/detail/config.hpp	(working copy)
@@ -318,6 +318,11 @@
 #define BOOST_THREAD_USES_DATETIME
 #endif
 
+#if defined(BOOST_THREAD_PLATFORM_WIN32) && defined BOOST_THREAD_DONT_USE_CHRONO
+#undef BOOST_THREAD_DONT_USE_CHRONO
+#define BOOST_THREAD_USES_CHRONO
+#endif
+
 // BOOST_THREAD_PROVIDES_DEPRECATED_FEATURES_SINCE_V3_0_0 defined by default up to Boost 1.55
 // BOOST_THREAD_DONT_PROVIDE_DEPRECATED_FEATURES_SINCE_V3_0_0 defined by default up to Boost 1.55
 #if defined BOOST_THREAD_PROVIDES_DEPRECATED_FEATURES_SINCE_V3_0_0

Yes it does. Thanks!

comment:14 by viboes, 9 years ago

Resolution: fixed
Status: assignedclosed

Committed revision [84750].

comment:15 by viboes, 9 years ago

(In [84792]) Thread: fix #8458 and update doc.

Note: See TracTickets for help on using tickets.