Skip to content

Commit eeb4197

Browse files
committed
link downstream packages against the tbb stub on windows
tbbLdFlags() returned only '-L<libs> -lRcppParallel' on Windows, leaving downstream packages to resolve TBB symbols against whichever objects happened to be pulled out of the static TBB when RcppParallel.dll was linked. That export surface is incidental rather than declared, and packages taking all of their PKG_LIBS from RcppParallelLibs() (e.g. rstan) have no other way to ask for TBB. Offer the stub library as well, after '-lRcppParallel' so the package's own exports still take precedence and no dependency on the stub is recorded unless something actually needs it. RcppParallel 5.1.11 and earlier appended '-ltbb -ltbbmalloc' here for the same reason.
1 parent 39afcb3 commit eeb4197

1 file changed

Lines changed: 15 additions & 2 deletions

File tree

R/tbb.R

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -87,12 +87,25 @@ tbbLdFlags <- function() {
8787

8888
# on Windows, we statically link to oneTBB
8989
if (is_windows()) {
90-
90+
9191
libPath <- archSystemFile("libs")
9292

9393
ldFlags <- sprintf("-L%s -lRcppParallel", asBuildPath(libPath))
94+
95+
# also offer the stub library. RcppParallel.dll re-exports whichever TBB
96+
# objects happened to be pulled out of the static library when it was
97+
# linked, which is an incidental export surface rather than a declared
98+
# one; the stub exports the runtime wholesale, so anything missing from
99+
# RcppParallel.dll can still be resolved. this comes last deliberately:
100+
# the linker satisfies symbols in order, so RcppParallel's own exports
101+
# still win, and no dependency on the stub is recorded unless something
102+
# actually needs it
103+
tbbPath <- archSystemFile("lib")
104+
if (file.exists(file.path(tbbPath, "tbb.dll")))
105+
ldFlags <- paste(ldFlags, sprintf("-L%s -ltbb", asBuildPath(tbbPath)))
106+
94107
return(ldFlags)
95-
108+
96109
}
97110

98111
# shortcut if TBB_LIB defined

0 commit comments

Comments
 (0)