Skip to content

Commit 3138398

Browse files
committed
don't redeclare the legacy observer classes in the tbb stub
The bundled oneTBB carries a local 'provided for backwards compatibility' block declaring tbb::internal::task_scheduler_observer_v3 and tbb::interface6::task_scheduler_observer (added in c276b03; not upstream). tbb-compat.cpp declares them too, which was fine while the stub was only ever built against the pristine headers Rtools ships -- but building the bundled oneTBB on Windows makes the two collide: tbb-compat.cpp:25:7: error: redefinition of 'class tbb::internal::task_scheduler_observer_v3' Have the bundled header advertise what it provides, and skip the stub's own declarations when it does. Either way the stub still exports the out-of-line observe(), which is the whole reason it exists. Also spell that definition __TBB_EXPORTED_METHOD, matching its declaration here and in the old TBB ABI; the two attributes are both no-ops on the Windows targets we build for, so this is consistency rather than a fix.
1 parent 00076d9 commit 3138398

2 files changed

Lines changed: 17 additions & 2 deletions

File tree

src/tbb-compat/tbb-compat.cpp

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,13 @@
1414
# define DLL_EXPORT
1515
#endif
1616

17+
// The old ABI's observer classes, as they stood before oneTBB. The bundled
18+
// copy of oneTBB carries these too (see task_scheduler_observer.h), so only
19+
// declare them when compiling against headers that don't -- i.e. the pristine
20+
// ones Rtools ships. Either way, the out-of-line observe() below is what this
21+
// stub exists to export.
22+
#ifndef __TBB_LEGACY_TASK_SCHEDULER_OBSERVER_PROVIDED
23+
1724
namespace tbb {
1825

1926
namespace interface6 {
@@ -130,11 +137,13 @@ class task_scheduler_observer : public internal::task_scheduler_observer_v3 {
130137

131138
} // namespace tbb
132139

140+
#endif /* __TBB_LEGACY_TASK_SCHEDULER_OBSERVER_PROVIDED */
141+
133142
namespace tbb {
134143
namespace internal {
135144

136145
DLL_EXPORT
137-
void __TBB_EXPORTED_FUNC task_scheduler_observer_v3::observe( bool enable ) {
146+
void __TBB_EXPORTED_METHOD task_scheduler_observer_v3::observe( bool enable ) {
138147
auto* tso = (tbb::detail::d1::task_scheduler_observer*) (this);
139148
tbb::detail::r1::observe(*tso, enable);
140149
}

src/tbb/include/oneapi/tbb/task_scheduler_observer.h

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,13 @@ inline namespace v1 {
116116
} // namespace tbb
117117

118118

119-
// Provided for backwards compatibility.
119+
// Provided for backwards compatibility. This is a local addition, not part of
120+
// upstream oneTBB, so the tbb.dll stub built by src/install.libs.R must be
121+
// able to tell whether the TBB headers in use supply these declarations (the
122+
// bundled copy does) or whether it has to declare them itself (as with the
123+
// pristine headers shipped by Rtools).
124+
#define __TBB_LEGACY_TASK_SCHEDULER_OBSERVER_PROVIDED 1
125+
120126
namespace tbb {
121127
namespace interface6 {
122128
class task_scheduler_observer;

0 commit comments

Comments
 (0)