Skip to content

fix bundled tbb build issues on macos#247

Merged
kevinushey merged 1 commit into
masterfrom
bugfix/tbb-macos-build
Jul 23, 2026
Merged

fix bundled tbb build issues on macos#247
kevinushey merged 1 commit into
masterfrom
bugfix/tbb-macos-build

Conversation

@kevinushey

Copy link
Copy Markdown
Contributor

Summary

Fixes the RcppParallel build failure on the CRAN macOS machines
(https://www.r-project.org/nosvn/R.check/r-release-macos-arm64/RcppParallel-00install.html),
and resolves the getcontext / swapcontext / makecontext deprecation warnings there.

tbbbind link failure

oneTBB's CMake automatically searches for hwloc via pkg-config and, if found, builds the
optional tbbbind NUMA-support library. The CRAN macOS machines now have a static-only
hwloc discoverable via pkg-config, but pkg_search_module() requests the shared-link flags,
which omit the Libs.private frameworks (CoreFoundation, IOKit, OpenCL) required when
linking hwloc statically. The tbbbind_2_5 link then fails with undefined symbols.

RcppParallel doesn't use TBB's NUMA APIs (and libtbb only ever loads tbbbind lazily via
dlopen, falling back gracefully when absent), so we now pass
-DTBB_DISABLE_HWLOC_AUTOMATIC_SEARCH=1 and skip tbbbind entirely. This also makes the
build deterministic regardless of what's installed on the build machine, and avoids shipping
a libtbbbind bound to a build-machine hwloc that wouldn't exist on user machines.

ucontext deprecation warnings

The ucontext APIs used by oneTBB's coroutine implementation for resumable tasks have been
deprecated on macOS since 10.6. We now build the bundled oneTBB with
-D__TBB_RESUMABLE_TASKS_USE_THREADS=1 on macOS, selecting oneTBB's threads-based
coroutine implementation (the same code path upstream uses under sanitizers), so the
deprecated APIs are no longer referenced at all.

Testing

  • Fresh R CMD INSTALL --preclean on macOS arm64 succeeds; CMake logs confirm no tbbbind
    targets are created and the define is applied to all TBB compile lines.
  • nm -u libtbb.dylib shows no _getcontext / _swapcontext / _makecontext references
    (previously present).
  • Installed libs are exactly libtbb.dylib, libtbbmalloc.dylib, libtbbmalloc_proxy.dylib;
    package loads and setThreadOptions() / defaultNumThreads() work.

- 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)
@kevinushey
kevinushey merged commit da5ac93 into master Jul 23, 2026
5 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant