Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
# RcppParallel (development version)

* The bundled oneTBB headers now guard against GCC's `<cpuid.h>` being
included before `<intrin.h>` on Windows (mingw). Previously, translation
units including `<cpuid.h>` before any TBB header would fail to compile,
as the `__cpuid` macro from `<cpuid.h>` conflicts with the `__cpuid()`
function declared by mingw's `<intrin.h>`.

* When building the bundled copy of oneTBB, RcppParallel no longer searches
for hwloc, and so no longer tries to build the optional 'tbbbind' library.
This fixes build failures on machines where a static hwloc library is
Expand Down
24 changes: 24 additions & 0 deletions patches/mingw_cpuid.diff
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
diff --git a/src/tbb/include/oneapi/tbb/detail/_machine.h b/src/tbb/include/oneapi/tbb/detail/_machine.h
index ca481380..8174f3d3 100644
--- a/src/tbb/include/oneapi/tbb/detail/_machine.h
+++ b/src/tbb/include/oneapi/tbb/detail/_machine.h
@@ -26,7 +26,19 @@
#include <cstddef>

#ifdef _WIN32
+
+// GCC's <cpuid.h> defines a function-like '__cpuid' macro that mangles the
+// __cpuid() declarations in mingw's <intrin.h>. Hide the macro while
+// including <intrin.h> so the two headers can coexist in any order.
+#if defined(__MINGW32__) && defined(__cpuid)
+#pragma push_macro("__cpuid")
+#undef __cpuid
+#include <intrin.h>
+#pragma pop_macro("__cpuid")
+#else
#include <intrin.h>
+#endif
+
#ifdef __TBBMALLOC_BUILD
#define WIN32_LEAN_AND_MEAN
#ifndef NOMINMAX
12 changes: 12 additions & 0 deletions src/tbb/include/oneapi/tbb/detail/_machine.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,19 @@
#include <cstddef>

#ifdef _WIN32

// GCC's <cpuid.h> defines a function-like '__cpuid' macro that mangles the
// __cpuid() declarations in mingw's <intrin.h>. Hide the macro while
// including <intrin.h> so the two headers can coexist in any order.
#if defined(__MINGW32__) && defined(__cpuid)
#pragma push_macro("__cpuid")
#undef __cpuid
#include <intrin.h>
#pragma pop_macro("__cpuid")
#else
#include <intrin.h>
#endif

#ifdef __TBBMALLOC_BUILD
#define WIN32_LEAN_AND_MEAN
#ifndef NOMINMAX
Expand Down
Loading