Skip to content

Commit 39afcb3

Browse files
authored
guard tbb concepts-based iterator dispatch on __TBB_CPP20_CONCEPTS_PRESENT (#268)
parallel_for_each.h selected its concepts-based iterator_tag_dispatch on __TBB_CPP20_PRESENT, which only tests the language mode (__TBB_LANG >= 202002L). Toolchains that accept -std=c++20 but ship a pre-C++20 standard library then take the concepts branch and fail to find std::random_access_iterator; this broke installation on CRAN's macOS x86_64 machines, which pair Apple clang 14 with the macOS 11.3 SDK. Every other C++20 library dependency in these headers is already gated on __TBB_CPP20_CONCEPTS_PRESENT (or, for <compare>, on both the language and library feature-test macros), so parallel_for_each.h was the lone offender. This mirrors the upstream fix from oneTBB PR #1611 (issue #1552), first released in oneTBB 2022.1.0, and can be dropped once the bundled oneTBB is updated past 2022.0.0.
1 parent a3c7cd7 commit 39afcb3

3 files changed

Lines changed: 42 additions & 2 deletions

File tree

NEWS.md

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

3+
* Fixed an issue where compiling code including `tbb/parallel_for_each.h`
4+
could fail with toolchains that accept `-std=c++20` but provide a
5+
pre-C++20 standard library, with errors of the form "no member named
6+
'random_access_iterator' in namespace 'std'". This affected CRAN's macOS
7+
x86_64 machines, which pair Apple clang 14 with the macOS 11.3 SDK.
8+
39
* Fixed an issue where building the bundled oneTBB could fail when `CXX`
410
(or `CC`) was configured with a leading compiler launcher such as `ccache`
511
(e.g. `CXX = "ccache g++"`). The launcher is now forwarded to cmake via

patches/cpp20_concepts.diff

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
Guard the concepts-based iterator tag dispatch in parallel_for_each on
2+
__TBB_CPP20_CONCEPTS_PRESENT rather than __TBB_CPP20_PRESENT. The latter only
3+
tests the language mode (__TBB_LANG >= 202002L), so toolchains that accept
4+
-std=c++20 but ship a pre-C++20 standard library -- e.g. Apple clang 14 with
5+
the macOS 11.3 SDK, as used on CRAN's macOS x86_64 builders -- would take the
6+
concepts branch and fail with 'no member named random_access_iterator in
7+
namespace std'.
8+
9+
This is the upstream fix from oneTBB PR #1611 (issue #1552), first released in
10+
oneTBB 2022.1.0; it can be dropped once the bundled oneTBB is updated past
11+
2022.0.0.
12+
13+
diff --git a/src/tbb/include/oneapi/tbb/parallel_for_each.h b/src/tbb/include/oneapi/tbb/parallel_for_each.h
14+
index ce68a7ff..13d945ce 100644
15+
--- a/src/tbb/include/oneapi/tbb/parallel_for_each.h
16+
+++ b/src/tbb/include/oneapi/tbb/parallel_for_each.h
17+
@@ -409,7 +409,7 @@ public:
18+
template<typename It>
19+
using tag = typename std::iterator_traits<It>::iterator_category;
20+
21+
-#if __TBB_CPP20_PRESENT
22+
+#if __TBB_CPP20_CONCEPTS_PRESENT
23+
template <typename It>
24+
struct move_iterator_dispatch_helper {
25+
using type = It;
26+
@@ -448,7 +448,7 @@ using iterator_tag_dispatch = typename
27+
std::input_iterator_tag
28+
>::type
29+
>::type;
30+
-#endif // __TBB_CPP20_PRESENT
31+
+#endif // __TBB_CPP20_CONCEPTS_PRESENT
32+
33+
template <typename Body, typename Iterator, typename Item>
34+
using feeder_is_required = tbb::detail::void_t<decltype(tbb::detail::invoke(std::declval<const Body>(),

src/tbb/include/oneapi/tbb/parallel_for_each.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -409,7 +409,7 @@ class parallel_for_body_wrapper {
409409
template<typename It>
410410
using tag = typename std::iterator_traits<It>::iterator_category;
411411

412-
#if __TBB_CPP20_PRESENT
412+
#if __TBB_CPP20_CONCEPTS_PRESENT
413413
template <typename It>
414414
struct move_iterator_dispatch_helper {
415415
using type = It;
@@ -448,7 +448,7 @@ using iterator_tag_dispatch = typename
448448
std::input_iterator_tag
449449
>::type
450450
>::type;
451-
#endif // __TBB_CPP20_PRESENT
451+
#endif // __TBB_CPP20_CONCEPTS_PRESENT
452452

453453
template <typename Body, typename Iterator, typename Item>
454454
using feeder_is_required = tbb::detail::void_t<decltype(tbb::detail::invoke(std::declval<const Body>(),

0 commit comments

Comments
 (0)