Commit 514d22f
committed
build the bundled onetbb as a shared library on windows
Windows was the only platform where TBB was not a shared library loaded at
runtime, and nearly every Windows-specific wart traced back to that. Use the
bundled oneTBB there too, built shared, shipped as tbb.dll / tbbmalloc.dll and
linked exactly as on other platforms.
Rtools ships static libraries only, so adopting its TBB meant linking it into
RcppParallel.dll. That made the TBB version -- and ABI -- a property of the
user's toolchain (Intel TBB 2017 on Rtools42, oneTBB later), and left
downstream packages with no TBB library to link against. The workarounds
accumulated: re-exporting the whole tbbmalloc archive so the allocator could be
resolved (#262), a tbb.dll stub so packages linking -ltbb could load (#249,
#250), building that stub differently for legacy toolchains (#258), offering it
from RcppParallelLibs() so rstan could link at all (#269), and a library lookup
that searched for archives never installed with the package (#270).
Worse, the stub linked the TBB archives itself, so it was a second complete
copy of the oneTBB scheduler. Both it and RcppParallel.dll export the same 81
tbb::detail::r1:: entry points, both are loaded in every session, and which one
a downstream package binds to is up to the linker. Two schedulers with separate
thread pools and separate global state is a correctness problem, not a linking
inconvenience.
This removes:
- the Rtools TBB detection in configure.R, and with it the TBB_NAME derivation
from archive names and the tbb12 special case
- the --whole-archive tbbmalloc re-export, which only existed because there was
no DLL to link
- BUILD_SHARED_LIBS=0 for Windows
- src/tbb-compat/ and buildTbbStub() entirely, along with the #ifndef _WIN32
guard in observer_proxy.cpp and the __TBB_LEGACY_..._PROVIDED macro that let
the stub tell which headers it was compiling against
- the Windows branches in .install.libs(), loadTbbLibrary(), tbbLdFlags() and
tbbLibraryPath(), and the Windows-first load order in .onLoad()
Notes on the pieces that are not just deletions:
- mingw CMake would name a shared build libtbb.dll; patch PREFIX to "" so the
runtime is tbb.dll, the name binaries built against 5.1.11 and earlier
import. The import library keeps its lib prefix, so -ltbb still resolves.
- the legacy task_scheduler_observer_v3::observe definition now applies on
Windows too. mingw has no .def file, so its export comes from a dllexport
directive: the declaration gains TBB_EXPORT, which is empty when consuming
the headers.
- .onLoad loads tbb before RcppParallel on every platform now, since
RcppParallel.dll imports from tbb.dll and the package library directory is
not on the DLL search path.
- tbbLdFlags() keeps -lRcppParallel on Windows: isProcessForkedChild is
compiled into RcppParallel.dll, and Windows has no lazy binding to resolve it
at load time.
The downstream CI check now asserts the property this is all for: the
downstream library's TBB symbols come from exactly one module, that module is
tbb.dll, and RcppParallel.dll imports from it rather than carrying its own copy.1 parent de75c55 commit 514d22f
16 files changed
Lines changed: 286 additions & 596 deletions
File tree
- .github/scripts
- R
- patches
- src
- tbb-compat
- tbb
- include/oneapi/tbb
- src
- tbbmalloc_proxy
- tbbmalloc
- tbb
- tests
- tools/config
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
97 | 97 | | |
98 | 98 | | |
99 | 99 | | |
100 | | - | |
101 | | - | |
102 | | - | |
103 | | - | |
104 | | - | |
105 | | - | |
106 | | - | |
107 | | - | |
108 | | - | |
109 | | - | |
| 100 | + | |
| 101 | + | |
| 102 | + | |
| 103 | + | |
| 104 | + | |
| 105 | + | |
| 106 | + | |
| 107 | + | |
110 | 108 | | |
111 | 109 | | |
112 | | - | |
113 | | - | |
| 110 | + | |
| 111 | + | |
| 112 | + | |
| 113 | + | |
114 | 114 | | |
| 115 | + | |
| 116 | + | |
| 117 | + | |
115 | 118 | | |
116 | 119 | | |
117 | | - | |
| 120 | + | |
118 | 121 | | |
119 | 122 | | |
120 | 123 | | |
| |||
125 | 128 | | |
126 | 129 | | |
127 | 130 | | |
128 | | - | |
129 | 131 | | |
130 | | - | |
| 132 | + | |
| 133 | + | |
| 134 | + | |
| 135 | + | |
| 136 | + | |
| 137 | + | |
| 138 | + | |
| 139 | + | |
| 140 | + | |
131 | 141 | | |
132 | | - | |
| 142 | + | |
| 143 | + | |
133 | 144 | | |
134 | | - | |
| 145 | + | |
| 146 | + | |
| 147 | + | |
| 148 | + | |
| 149 | + | |
| 150 | + | |
| 151 | + | |
135 | 152 | | |
136 | | - | |
137 | | - | |
138 | | - | |
139 | | - | |
140 | | - | |
141 | | - | |
| 153 | + | |
| 154 | + | |
| 155 | + | |
| 156 | + | |
| 157 | + | |
| 158 | + | |
| 159 | + | |
| 160 | + | |
142 | 161 | | |
143 | | - | |
| 162 | + | |
| 163 | + | |
| 164 | + | |
144 | 165 | | |
145 | | - | |
146 | | - | |
| 166 | + | |
147 | 167 | | |
148 | | - | |
149 | | - | |
150 | | - | |
151 | | - | |
152 | | - | |
153 | | - | |
154 | | - | |
| 168 | + | |
155 | 169 | | |
156 | | - | |
157 | | - | |
158 | | - | |
| 170 | + | |
| 171 | + | |
| 172 | + | |
| 173 | + | |
| 174 | + | |
159 | 175 | | |
160 | | - | |
161 | | - | |
162 | | - | |
163 | | - | |
164 | | - | |
| 176 | + | |
| 177 | + | |
| 178 | + | |
165 | 179 | | |
166 | 180 | | |
167 | 181 | | |
| 182 | + | |
| 183 | + | |
| 184 | + | |
| 185 | + | |
| 186 | + | |
| 187 | + | |
| 188 | + | |
| 189 | + | |
| 190 | + | |
| 191 | + | |
| 192 | + | |
168 | 193 | | |
169 | 194 | | |
170 | | - | |
| 195 | + | |
171 | 196 | | |
172 | 197 | | |
173 | 198 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
8 | 8 | | |
9 | 9 | | |
10 | 10 | | |
11 | | - | |
12 | | - | |
13 | | - | |
14 | | - | |
15 | | - | |
16 | | - | |
17 | | - | |
18 | | - | |
19 | | - | |
20 | | - | |
21 | | - | |
22 | | - | |
23 | | - | |
24 | | - | |
25 | | - | |
26 | | - | |
27 | | - | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
28 | 42 | | |
29 | 43 | | |
30 | 44 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
22 | 22 | | |
23 | 23 | | |
24 | 24 | | |
25 | | - | |
26 | | - | |
27 | | - | |
28 | | - | |
29 | 25 | | |
30 | 26 | | |
31 | | - | |
| 27 | + | |
32 | 28 | | |
33 | 29 | | |
34 | 30 | | |
| |||
89 | 85 | | |
90 | 86 | | |
91 | 87 | | |
92 | | - | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
93 | 94 | | |
94 | 95 | | |
95 | | - | |
96 | | - | |
97 | | - | |
98 | | - | |
99 | | - | |
100 | | - | |
101 | | - | |
102 | | - | |
103 | | - | |
104 | | - | |
105 | | - | |
106 | | - | |
107 | | - | |
108 | | - | |
109 | | - | |
110 | | - | |
111 | | - | |
112 | | - | |
113 | | - | |
114 | | - | |
115 | | - | |
116 | | - | |
117 | | - | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
| 100 | + | |
| 101 | + | |
| 102 | + | |
| 103 | + | |
| 104 | + | |
| 105 | + | |
| 106 | + | |
118 | 107 | | |
119 | 108 | | |
120 | | - | |
| 109 | + | |
121 | 110 | | |
122 | 111 | | |
123 | 112 | | |
| |||
150 | 139 | | |
151 | 140 | | |
152 | 141 | | |
153 | | - | |
154 | | - | |
155 | | - | |
156 | | - | |
157 | | - | |
158 | | - | |
159 | | - | |
160 | | - | |
161 | | - | |
162 | 142 | | |
163 | 143 | | |
164 | 144 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
12 | 12 | | |
13 | 13 | | |
14 | 14 | | |
15 | | - | |
16 | | - | |
17 | | - | |
18 | | - | |
19 | | - | |
20 | | - | |
21 | | - | |
22 | | - | |
23 | | - | |
24 | | - | |
25 | | - | |
26 | | - | |
27 | | - | |
28 | | - | |
29 | | - | |
30 | | - | |
31 | | - | |
32 | | - | |
33 | | - | |
34 | | - | |
35 | | - | |
36 | | - | |
37 | | - | |
38 | 15 | | |
39 | 16 | | |
40 | 17 | | |
| |||
52 | 29 | | |
53 | 30 | | |
54 | 31 | | |
55 | | - | |
56 | | - | |
57 | | - | |
58 | | - | |
59 | | - | |
60 | | - | |
61 | | - | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
62 | 37 | | |
63 | 38 | | |
64 | | - | |
| 39 | + | |
65 | 40 | | |
66 | 41 | | |
67 | 42 | | |
68 | 43 | | |
69 | | - | |
70 | | - | |
71 | | - | |
72 | | - | |
73 | | - | |
74 | | - | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
75 | 47 | | |
76 | 48 | | |
77 | 49 | | |
| |||
0 commit comments