From 47500e5b4c1696d2ec3a7898c02f769e6140c149 Mon Sep 17 00:00:00 2001 From: Kevin Ushey Date: Fri, 24 Jul 2026 12:51:16 -0700 Subject: [PATCH] enable tbb by default on musl-based linux (e.g. alpine) RcppParallel.h gated the default RCPP_PARALLEL_USE_TBB on __gnu_linux__, a glibc-only predefined macro. On musl-based systems such as Alpine, which define __linux__ but not __gnu_linux__, the default fell through to 0 -- disabling TBB for any downstream package that does not pass -DRCPP_PARALLEL_USE_TBB explicitly (i.e. does not use RcppParallel::CxxFlags() in its Makevars), even when RcppParallel itself was built with a working TBB. Match Linux via __linux__ instead, which covers both glibc and musl. This is consistent with the bundled TBB sources, which use __linux__ broadly and only guard on __GLIBC__ where glibc-specific behavior is required. Fixes #231 --- inst/include/RcppParallel.h | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/inst/include/RcppParallel.h b/inst/include/RcppParallel.h index a86f38b8..65f388f0 100644 --- a/inst/include/RcppParallel.h +++ b/inst/include/RcppParallel.h @@ -9,8 +9,11 @@ // (NOTE: Windows TBB is temporarily opt-in for packages for // compatibility with CRAN packages not previously configured // to link to TBB in Makevars.win) +// NOTE: match Linux via __linux__ rather than __gnu_linux__; the latter is +// only defined by glibc toolchains, which left TBB disabled by default on +// musl-based systems such as Alpine Linux (https://github.com/RcppCore/RcppParallel/issues/231) #ifndef RCPP_PARALLEL_USE_TBB -# if defined(__APPLE__) || defined(__gnu_linux__) || (defined(__sun) && defined(__SVR4) && !defined(__sparc)) +# if defined(__APPLE__) || defined(__linux__) || (defined(__sun) && defined(__SVR4) && !defined(__sparc)) # define RCPP_PARALLEL_USE_TBB 1 # else # define RCPP_PARALLEL_USE_TBB 0