Skip to content

Commit

Permalink
[tbb] Fix build for macOS with GCC
Browse files Browse the repository at this point in the history
  • Loading branch information
Jhuighuy committed Feb 10, 2025
1 parent 74ec888 commit 9441450
Show file tree
Hide file tree
Showing 5 changed files with 90 additions and 2 deletions.
82 changes: 82 additions & 0 deletions ports/tbb/fix-gcc-without-gas.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
diff --git a/cmake/compilers/GNU.cmake b/cmake/compilers/GNU.cmake
index da6b408..f699015 100644
--- a/cmake/compilers/GNU.cmake
+++ b/cmake/compilers/GNU.cmake
@@ -55,16 +55,18 @@ execute_process(
ERROR_STRIP_TRAILING_WHITESPACE
)
set(ASSEMBLER_VERSION_LINE ${ASSEMBLER_VERSION_LINE_OUT}${ASSEMBLER_VERSION_LINE_ERR})
-string(REGEX REPLACE ".*GNU assembler version ([0-9]+)\\.([0-9]+).*" "\\1" _tbb_gnu_asm_major_version "${ASSEMBLER_VERSION_LINE}")
-string(REGEX REPLACE ".*GNU assembler version ([0-9]+)\\.([0-9]+).*" "\\2" _tbb_gnu_asm_minor_version "${ASSEMBLER_VERSION_LINE}")
-unset(ASSEMBLER_VERSION_LINE_OUT)
-unset(ASSEMBLER_VERSION_LINE_ERR)
-unset(ASSEMBLER_VERSION_LINE)
-message(TRACE "Extracted GNU assembler version: major=${_tbb_gnu_asm_major_version} minor=${_tbb_gnu_asm_minor_version}")
-
-math(EXPR _tbb_gnu_asm_version_number "${_tbb_gnu_asm_major_version} * 1000 + ${_tbb_gnu_asm_minor_version}")
-set(TBB_COMMON_COMPILE_FLAGS ${TBB_COMMON_COMPILE_FLAGS} "-D__TBB_GNU_ASM_VERSION=${_tbb_gnu_asm_version_number}")
-message(STATUS "GNU Assembler version: ${_tbb_gnu_asm_major_version}.${_tbb_gnu_asm_minor_version} (${_tbb_gnu_asm_version_number})")
+if ("${ASSEMBLER_VERSION_LINE}" MATCHES "GNU assembler version")
+ string(REGEX REPLACE ".*GNU assembler version ([0-9]+)\\.([0-9]+).*" "\\1" _tbb_gnu_asm_major_version "${ASSEMBLER_VERSION_LINE}")
+ string(REGEX REPLACE ".*GNU assembler version ([0-9]+)\\.([0-9]+).*" "\\2" _tbb_gnu_asm_minor_version "${ASSEMBLER_VERSION_LINE}")
+ unset(ASSEMBLER_VERSION_LINE_OUT)
+ unset(ASSEMBLER_VERSION_LINE_ERR)
+ unset(ASSEMBLER_VERSION_LINE)
+ message(TRACE "Extracted GNU assembler version: major=${_tbb_gnu_asm_major_version} minor=${_tbb_gnu_asm_minor_version}")
+
+ math(EXPR _tbb_gnu_asm_version_number "${_tbb_gnu_asm_major_version} * 1000 + ${_tbb_gnu_asm_minor_version}")
+ set(TBB_COMMON_COMPILE_FLAGS ${TBB_COMMON_COMPILE_FLAGS} "-D__TBB_GNU_ASM_VERSION=${_tbb_gnu_asm_version_number}")
+ message(STATUS "GNU Assembler version: ${_tbb_gnu_asm_major_version}.${_tbb_gnu_asm_minor_version} (${_tbb_gnu_asm_version_number})")
+endif()

# Enable Intel(R) Transactional Synchronization Extensions (-mrtm) and WAITPKG instructions support (-mwaitpkg) on relevant processors
if (CMAKE_SYSTEM_PROCESSOR MATCHES "(AMD64|amd64|i.86|x86)" AND NOT EMSCRIPTEN)
diff --git a/include/oneapi/tbb/detail/_config.h b/include/oneapi/tbb/detail/_config.h
index e676b15..e144a16 100644
--- a/include/oneapi/tbb/detail/_config.h
+++ b/include/oneapi/tbb/detail/_config.h
@@ -335,7 +335,7 @@

#define __TBB_TSX_INTRINSICS_PRESENT (__RTM__ || __INTEL_COMPILER || (_MSC_VER>=1700 && (__TBB_x86_64 || __TBB_x86_32)))

-#define __TBB_WAITPKG_INTRINSICS_PRESENT ((__INTEL_COMPILER >= 1900 || (__TBB_GCC_VERSION >= 110000 && __TBB_GNU_ASM_VERSION >= 2032) || __TBB_CLANG_VERSION >= 120000) \
+#define __TBB_WAITPKG_INTRINSICS_PRESENT ((__INTEL_COMPILER >= 1900 || (__TBB_GCC_VERSION >= 110000 && (__APPLE__ || __TBB_GNU_ASM_VERSION >= 2032)) || __TBB_CLANG_VERSION >= 120000) \
&& (_WIN32 || _WIN64 || __unix__ || __APPLE__) && (__TBB_x86_32 || __TBB_x86_64) && !__ANDROID__)

/** Internal TBB features & modes **/
diff --git a/src/tbb/co_context.h b/src/tbb/co_context.h
index 60d5437..86bbd7a 100644
--- a/src/tbb/co_context.h
+++ b/src/tbb/co_context.h
@@ -1,5 +1,5 @@
/*
- Copyright (c) 2005-2022 Intel Corporation
+ Copyright (c) 2005-2024 Intel Corporation

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
@@ -43,9 +43,9 @@
#if __INTEL_COMPILER
#pragma warning(push)
#pragma warning(disable:1478)
- #elif __clang__
- #pragma clang diagnostic push
- #pragma clang diagnostic ignored "-Wdeprecated-declarations"
+ #elif __GNUC__
+ #pragma GCC diagnostic push
+ #pragma GCC diagnostic ignored "-Wdeprecated-declarations"
#endif
#endif // __APPLE__

@@ -362,8 +362,8 @@ inline void destroy_coroutine(coroutine_type& c) {
#if __APPLE__
#if __INTEL_COMPILER
#pragma warning(pop) // 1478 warning
- #elif __clang__
- #pragma clang diagnostic pop // "-Wdeprecated-declarations"
+ #elif __GNUC__
+ #pragma GCC diagnostic pop // "-Wdeprecated-declarations"
#endif
#endif

--
1 change: 1 addition & 0 deletions ports/tbb/portfile.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ vcpkg_from_github(
HEAD_REF master
PATCHES
fix-lang.patch # https://github.com/uxlfoundation/oneTBB/pull/1606
fix-gcc-without-gas.patch # https://github.com/uxlfoundation/oneTBB/pull/1603
)

vcpkg_check_features(
Expand Down
2 changes: 1 addition & 1 deletion ports/tbb/vcpkg.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"$schema": "https://raw.githubusercontent.com/microsoft/vcpkg-tool/main/docs/vcpkg.schema.json",
"name": "tbb",
"version": "2022.0.0",
"port-version": 1,
"port-version": 2,
"description": "Intel's Threading Building Blocks.",
"homepage": "https://github.com/oneapi-src/oneTBB",
"license": "Apache-2.0",
Expand Down
2 changes: 1 addition & 1 deletion versions/baseline.json
Original file line number Diff line number Diff line change
Expand Up @@ -8954,7 +8954,7 @@
},
"tbb": {
"baseline": "2022.0.0",
"port-version": 1
"port-version": 2
},
"tcb-span": {
"baseline": "2022-06-15",
Expand Down
5 changes: 5 additions & 0 deletions versions/t-/tbb.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
{
"versions": [
{
"git-tree": "f60b50fadd0db67c1785c4c61b5bd7a1c688f32e",
"version": "2022.0.0",
"port-version": 2
},
{
"git-tree": "e8eb4f6f5f53c1b56598b26a951b8d49cf349d0d",
"version": "2022.0.0",
Expand Down

0 comments on commit 9441450

Please sign in to comment.