Skip to content

Commit 0d03027

Browse files
committed
fix bundled tbb build issues on macos
- disable oneTBB's automatic hwloc search, so the optional tbbbind library is no longer built; its link fails on the CRAN macOS machines, where a static hwloc is discoverable via pkg-config but its required frameworks are not on the link line - build the bundled oneTBB with __TBB_RESUMABLE_TASKS_USE_THREADS on macOS, avoiding the deprecated ucontext APIs (getcontext, swapcontext, makecontext)
1 parent 3690aba commit 0d03027

2 files changed

Lines changed: 20 additions & 0 deletions

File tree

NEWS.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,14 @@
11
# RcppParallel (development version)
22

3+
* When building the bundled copy of oneTBB, RcppParallel no longer searches
4+
for hwloc, and so no longer tries to build the optional 'tbbbind' library.
5+
This fixes build failures on machines where a static hwloc library is
6+
discoverable via pkg-config, as on the CRAN macOS machines.
7+
8+
* On macOS, the bundled copy of oneTBB is now built with
9+
`__TBB_RESUMABLE_TASKS_USE_THREADS`, avoiding use of the deprecated
10+
ucontext APIs (`getcontext`, `swapcontext`, `makecontext`).
11+
312

413
# RcppParallel 6.0.0
514

src/install.libs.R

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -116,12 +116,23 @@ useBundledTbb <- function() {
116116
prependFlags("CPPFLAGS", "CFLAGS")
117117
prependFlags("CPPFLAGS", "CXXFLAGS")
118118

119+
# the ucontext APIs (getcontext, swapcontext, ...) are deprecated on macOS,
120+
# so use the threads-based coroutine implementation for resumable tasks
121+
if (Sys.info()[["sysname"]] == "Darwin") {
122+
flags <- c(Sys.getenv("CXXFLAGS"), "-D__TBB_RESUMABLE_TASKS_USE_THREADS=1")
123+
setenv("CXXFLAGS", flags[nzchar(flags)])
124+
}
125+
119126
cmakeFlags <- c(
120127
forwardEnvVar("CC", "CMAKE_C_COMPILER"),
121128
forwardEnvVar("CXX", "CMAKE_CXX_COMPILER"),
122129
forwardEnvVar("CFLAGS", "CMAKE_C_FLAGS"),
123130
forwardEnvVar("CXXFLAGS", "CMAKE_CXX_FLAGS"),
124131
forwardEnvVar("CMAKE_BUILD_TYPE", "CMAKE_BUILD_TYPE"),
132+
# tbbbind requires hwloc, and hwloc's pkg-config file doesn't advertise
133+
# the macOS frameworks needed when linking it statically; RcppParallel
134+
# doesn't use TBB's NUMA APIs, so skip tbbbind altogether
135+
"-DTBB_DISABLE_HWLOC_AUTOMATIC_SEARCH=1",
125136
"-DTBB_TEST=0",
126137
"-DTBB_EXAMPLES=0",
127138
"-DTBB_STRICT=0",

0 commit comments

Comments
 (0)