Skip to content

Commit c6be776

Browse files
committed
Merge remote-tracking branch 'origin/master' into bugfix/windows-load-tbb-stub
# Conflicts: # NEWS.md
2 parents 1912736 + 4426b8c commit c6be776

3 files changed

Lines changed: 42 additions & 0 deletions

File tree

NEWS.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,12 @@
77
RcppParallel 6.0.0, such packages would fail to load with "LoadLibrary
88
failure: The specified module could not be found".
99

10+
* The bundled oneTBB headers now guard against GCC's `<cpuid.h>` being
11+
included before `<intrin.h>` on Windows (mingw). Previously, translation
12+
units including `<cpuid.h>` before any TBB header would fail to compile,
13+
as the `__cpuid` macro from `<cpuid.h>` conflicts with the `__cpuid()`
14+
function declared by mingw's `<intrin.h>`.
15+
1016
* When building the bundled copy of oneTBB, RcppParallel no longer searches
1117
for hwloc, and so no longer tries to build the optional 'tbbbind' library.
1218
This fixes build failures on machines where a static hwloc library is

patches/mingw_cpuid.diff

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
diff --git a/src/tbb/include/oneapi/tbb/detail/_machine.h b/src/tbb/include/oneapi/tbb/detail/_machine.h
2+
index ca481380..8174f3d3 100644
3+
--- a/src/tbb/include/oneapi/tbb/detail/_machine.h
4+
+++ b/src/tbb/include/oneapi/tbb/detail/_machine.h
5+
@@ -26,7 +26,19 @@
6+
#include <cstddef>
7+
8+
#ifdef _WIN32
9+
+
10+
+// GCC's <cpuid.h> defines a function-like '__cpuid' macro that mangles the
11+
+// __cpuid() declarations in mingw's <intrin.h>. Hide the macro while
12+
+// including <intrin.h> so the two headers can coexist in any order.
13+
+#if defined(__MINGW32__) && defined(__cpuid)
14+
+#pragma push_macro("__cpuid")
15+
+#undef __cpuid
16+
+#include <intrin.h>
17+
+#pragma pop_macro("__cpuid")
18+
+#else
19+
#include <intrin.h>
20+
+#endif
21+
+
22+
#ifdef __TBBMALLOC_BUILD
23+
#define WIN32_LEAN_AND_MEAN
24+
#ifndef NOMINMAX

src/tbb/include/oneapi/tbb/detail/_machine.h

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,19 @@
2626
#include <cstddef>
2727

2828
#ifdef _WIN32
29+
30+
// GCC's <cpuid.h> defines a function-like '__cpuid' macro that mangles the
31+
// __cpuid() declarations in mingw's <intrin.h>. Hide the macro while
32+
// including <intrin.h> so the two headers can coexist in any order.
33+
#if defined(__MINGW32__) && defined(__cpuid)
34+
#pragma push_macro("__cpuid")
35+
#undef __cpuid
36+
#include <intrin.h>
37+
#pragma pop_macro("__cpuid")
38+
#else
2939
#include <intrin.h>
40+
#endif
41+
3042
#ifdef __TBBMALLOC_BUILD
3143
#define WIN32_LEAN_AND_MEAN
3244
#ifndef NOMINMAX

0 commit comments

Comments
 (0)