Skip to content

RcppParallel.h disables TBB on Alpine Linux #231

Description

@bastistician

Documentation says packages should call tbb only #if RCPP_PARALLEL_USE_TBB, which is false on Alpine Linux due to

# if defined(__APPLE__) || defined(__gnu_linux__) || (defined(__sun) && defined(__SVR4) && !defined(__sparc))
# define RCPP_PARALLEL_USE_TBB 1
# else
# define RCPP_PARALLEL_USE_TBB 0
# endif

I was able to successfully install RcppParallel using the system TBB (via --configure-vars='TBB_LIB=/usr/lib TBB_INC=/usr/include'), but the above means packages LinkingTo RcppParallel won't usually use TBB anyway.

Furthermore, several packages don't seem to use TBB conditionally, at least

  • CaseBasedReasoning
  • DER
  • FLSSS
  • GenomeAdmixR
  • RcppMeCab
  • Scalelink
  • bgms
  • evesim
  • junctions
  • secsse

fail to compile on Alpine Linux with errors such as "error: 'tbb' does not name a type" or "error: 'tbb' has not been declared" (see the corresponding outputs at https://github.com/bastistician/Rcheck/tree/results/musl/issues).

Is there something RcppParallel[.h] could do better with regard to its default setting so TBB is used by packages on Alpine Linux if RcppParallel was installed with the system TBB?

Activity

  1. bastistician commented on Jan 15, 2025

    @bastistician
    Author

    It looks like this could be fixed via f2f9dc1, at least for packages that include RcppParallel::CxxFlags() in their PKG_CXXFLAGS in src/Makevars, because that will now include -DRCPP_PARALLEL_USE_TBB=1 (if RcppParallel was installed with enabled TBB as usual). Thanks!

    BTW, the new TBB version bundled here seems to successfully compile on Alpine Linux -- well, I don't actually get any output between

    *** building tbb
    *** finished building tbb
    

    but assuming all went well a system installation is no longer needed.

  2. kevinushey commented on Jan 15, 2025

    @kevinushey
    Contributor

    Awesome! Thanks for reporting back. I'm going to start trying to prepare a CRAN release of RcppParallel soon as well, but this will take some time to verify since the ABI changes in TBB means all downstream dependencies need to be rebuilt.

    The output here is hidden mostly to discard compiler warnings and the like that might make certain CRAN maintainers unhappy. (I don't have any control over these and I don't want to be forced to ship a patched version of TBB here.)

  3. thijsjanzen commented on Mar 3, 2026

    @thijsjanzen

    I don't think this has been resolved yet, right?
    I'm involved in maintenance of four packages out of the list posted by @bastistician , and it seems weird to have to provide non-parallel code as well to resolve this, as this seems to be the result of an interaction between RcppParallel and Alpine Linux (Alpine Linux on itself does support tbb)

  4. bastistician commented on Mar 3, 2026

    @bastistician
    Author

    Thanks for chiming in. AFAIR, the next release of 'RcppParallel' should resolve this issue for Alpine Linux, but note that other systems may indeed lack TBB. I suspect compilation with musl-based Emscripten to WebAssembly might still fail.

  5. thijsjanzen commented on Mar 3, 2026

    @thijsjanzen

    Thanks for chiming in. AFAIR, the next release of 'RcppParallel' should resolve this issue for Alpine Linux, but note that other systems may indeed lack TBB. I suspect compilation with musl-based Emscripten to WebAssembly might still fail.

    That sounds great! We will look into this from our end as well, thank you for the reply.

  6. thijsjanzen commented on Mar 6, 2026

    @thijsjanzen

    We have fixed this now by 'overloading' the tbb namespace and relevant functions/classes, depending on the RCPP_PARALLEL_USE_TBB flag.

    See https://github.com/thijsjanzen/junctions/blob/master/src/tbb_stub.h

  7. bastistician commented on Jul 24, 2026

    @bastistician
    Author

    RcppParallel 6.0.0 now does output CxxFlags also on Alpine Linux (previously empty):

    R> RcppParallel::CxxFlags()
    -DRCPP_PARALLEL_USE_TBB=1 -DTBB_INTERFACE_NEW -I/mnt/runner/lib/RcppParallel/include
    

    Revdeps that include that output in their src/Makevars flags now get TBB support, i.e., those that were not prepared for the case RCPP_PARALLEL_USE_TBB=0 no longer fail, e.g., 'bgms'.
    Other packages from the original list still fail because they do not incorporate RcppParallel::CxxFlags(), so TBB remains disabled, e.g., 'FLSSS' and 'evesim'.

  8. kevinushey commented on Jul 24, 2026

    @kevinushey
    Contributor

    @bastistician are there any other changes we should make on the RcppParallel side to accommodate this?

  9. bastistician commented on Jul 26, 2026

    @bastistician
    Author

    Thanks. I can confirm that RcppParallel 6.1.0 enables TBB by default on Alpine Linux so packages that use TBB unconditionally no longer fail to install there.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions