diff options
Diffstat (limited to 'dev-cpp/tbb')
-rw-r--r-- | dev-cpp/tbb/Manifest | 1 | ||||
-rw-r--r-- | dev-cpp/tbb/files/tbb-2021.4.0-lto.patch | 247 | ||||
-rw-r--r-- | dev-cpp/tbb/tbb-2021.4.0.ebuild | 37 |
3 files changed, 285 insertions, 0 deletions
diff --git a/dev-cpp/tbb/Manifest b/dev-cpp/tbb/Manifest index d2d3f1d78cf8..fee2e0bbf7fd 100644 --- a/dev-cpp/tbb/Manifest +++ b/dev-cpp/tbb/Manifest @@ -1 +1,2 @@ DIST tbb-2020.3.tar.gz 2639788 BLAKE2B 3e92bccdc8179fc049379ccbb8ad7f615623177abc61d813b1a601020c345137bfd7d4c4600cf5b0d587e5ebef677635c3c8124d06b05fdd3325128ed8c9f84a SHA512 04c4b5501418792827190691d03d20d4dc1fd3cbbcf459a4d40c5c2281d964e658f31f133ad3907b78e17ed04f4ff16728ed89487ed0ce2cb239f23feb34bd87 +DIST tbb-2021.4.0.tar.gz 2452533 BLAKE2B a635c6efa1894c33e2f75c1aa03b6c0f4a86ebef3b58fa42bd25b53d661ed7a9d21f49f121dd3679735f219fbfc35604600bcc72ba60d3602e6de77b0d62e37b SHA512 96da2bc351fd64dfa854f8e6cabc1c4e53af3d55760e99d6f83ad53779c727af333d13d6be0828ed70371cf796498d2063e9dd0e4b2f6451623bb5d28ccbf20b diff --git a/dev-cpp/tbb/files/tbb-2021.4.0-lto.patch b/dev-cpp/tbb/files/tbb-2021.4.0-lto.patch new file mode 100644 index 000000000000..5be97b90605d --- /dev/null +++ b/dev-cpp/tbb/files/tbb-2021.4.0-lto.patch @@ -0,0 +1,247 @@ +From 6feeba8035ea2bdf652d473a35730b19427752db Mon Sep 17 00:00:00 2001 +From: Ivan Kochin <kochin.ivan@intel.com> +Date: Wed, 27 Oct 2021 17:23:32 +0300 +Subject: [PATCH] Use native CMake way to detect the IPO support (#608) + +* Use native CMake way to detect the IPO support + +Signed-off-by: Kochin Ivan <kochin.ivan@intel.com> +--- + CMakeLists.txt | 17 +++++++++++++++++ + cmake/README.md | 1 + + cmake/compilers/Clang.cmake | 8 ++------ + cmake/compilers/GNU.cmake | 8 +++----- + cmake/compilers/MSVC.cmake | 1 + + cmake/utils.cmake | 13 +++++++++++++ + src/tbb/CMakeLists.txt | 5 ++--- + src/tbbbind/CMakeLists.txt | 6 +++--- + src/tbbmalloc/CMakeLists.txt | 5 ++--- + 9 files changed, 44 insertions(+), 20 deletions(-) + +diff --git a/CMakeLists.txt b/CMakeLists.txt +index 13b1dbc2c..4dbdadb97 100644 +--- a/CMakeLists.txt ++++ b/CMakeLists.txt +@@ -103,6 +103,7 @@ option(TBBMALLOC_BUILD "Enable tbbmalloc build" ON) + option(TBB_CPF "Enable preview features of the library" OFF) + option(TBB_FIND_PACKAGE "Enable search for external oneTBB using find_package instead of build from sources" OFF) + option(TBB_DISABLE_HWLOC_AUTOMATIC_SEARCH "Disable HWLOC automatic search by pkg-config tool" OFF) ++option(TBB_ENABLE_IPO "Enable Interprocedural Optimization (IPO) during the compilation" ON) + + if (NOT DEFINED BUILD_SHARED_LIBS) + set(BUILD_SHARED_LIBS ON) +@@ -181,6 +182,22 @@ foreach(FILE_WITH_EXTRA_TARGETS ${FILES_WITH_EXTRA_TARGETS}) + include(${FILE_WITH_EXTRA_TARGETS}) + endforeach() + ++# - Enabling LTO on Android causes the NDK bug. ++# NDK throws the warning: "argument unused during compilation: '-Wa,--noexecstack'" ++# - For some reason GCC does not instrument code with Thread Sanitizer when lto is enabled and C linker is used. ++if (TBB_ENABLE_IPO AND BUILD_SHARED_LIBS AND NOT ANDROID_PLATFORM AND NOT TBB_SANITIZE MATCHES "thread") ++ if (NOT CMAKE_VERSION VERSION_LESS 3.9) ++ cmake_policy(SET CMP0069 NEW) ++ include(CheckIPOSupported) ++ check_ipo_supported(RESULT TBB_IPO_PROPERTY) ++ else() ++ set(TBB_IPO_FLAGS TRUE) ++ endif() ++ if (TBB_IPO_PROPERTY OR TBB_IPO_FLAGS) ++ message(STATUS "IPO enabled") ++ endif() ++endif() ++ + set(TBB_COMPILER_SETTINGS_FILE ${CMAKE_CURRENT_SOURCE_DIR}/cmake/compilers/${CMAKE_CXX_COMPILER_ID}.cmake) + if (EXISTS ${TBB_COMPILER_SETTINGS_FILE}) + include(${TBB_COMPILER_SETTINGS_FILE}) +diff --git a/cmake/README.md b/cmake/README.md +index ec56e423c..ed1631de3 100644 +--- a/cmake/README.md ++++ b/cmake/README.md +@@ -16,6 +16,7 @@ TBB_CPF:BOOL - Enable preview features of the library (OFF by default) + TBB_INSTALL_VARS:BOOL - Enable auto-generated vars installation(packages generated by `cpack` and `make install` will also include the vars script)(OFF by default) + TBB_VALGRIND_MEMCHECK:BOOL - Enable scan for memory leaks using Valgrind (OFF by default) + TBB_DISABLE_HWLOC_AUTOMATIC_SEARCH - Disable HWLOC automatic search by pkg-config tool (OFF by default) ++TBB_ENABLE_IPO - Enable Interprocedural Optimization (IPO) during the compilation (ON by default) + ``` + + ## Configure, build and test +diff --git a/cmake/compilers/Clang.cmake b/cmake/compilers/Clang.cmake +index 183341fcc..69aa51932 100644 +--- a/cmake/compilers/Clang.cmake ++++ b/cmake/compilers/Clang.cmake +@@ -58,12 +58,8 @@ if (MINGW) + list(APPEND TBB_COMMON_COMPILE_FLAGS -U__STRICT_ANSI__) + endif() + +-# Enabling LTO on Android causes the NDK bug. +-# NDK throws the warning: "argument unused during compilation: '-Wa,--noexecstack'" +-if (NOT ANDROID_PLATFORM AND BUILD_SHARED_LIBS) +- set(TBB_IPO_COMPILE_FLAGS $<$<NOT:$<CONFIG:Debug>>:-flto>) +- set(TBB_IPO_LINK_FLAGS $<$<NOT:$<CONFIG:Debug>>:-flto>) +-endif() ++set(TBB_IPO_COMPILE_FLAGS $<$<NOT:$<CONFIG:Debug>>:-flto>) ++set(TBB_IPO_LINK_FLAGS $<$<NOT:$<CONFIG:Debug>>:-flto>) + + # TBB malloc settings + set(TBBMALLOC_LIB_COMPILE_FLAGS -fno-rtti -fno-exceptions) +diff --git a/cmake/compilers/GNU.cmake b/cmake/compilers/GNU.cmake +index fa14c869e..a9cfa8927 100644 +--- a/cmake/compilers/GNU.cmake ++++ b/cmake/compilers/GNU.cmake +@@ -63,11 +63,9 @@ if (MINGW) + list(APPEND TBB_COMMON_COMPILE_FLAGS -U__STRICT_ANSI__) + endif() + +-# For some reason GCC does not instrument code with Thread Sanitizer when lto is enabled and C linker is used. +-if (NOT TBB_SANITIZE MATCHES "thread") +- set(TBB_IPO_COMPILE_FLAGS $<$<NOT:$<CONFIG:Debug>>:-flto>) +- set(TBB_IPO_LINK_FLAGS $<$<NOT:$<CONFIG:Debug>>:-flto>) +-endif() ++set(TBB_IPO_COMPILE_FLAGS $<$<NOT:$<CONFIG:Debug>>:-flto>) ++set(TBB_IPO_LINK_FLAGS $<$<NOT:$<CONFIG:Debug>>:-flto>) ++ + + # TBB malloc settings + set(TBBMALLOC_LIB_COMPILE_FLAGS -fno-rtti -fno-exceptions) +diff --git a/cmake/compilers/MSVC.cmake b/cmake/compilers/MSVC.cmake +index 3447418cc..5767235a0 100644 +--- a/cmake/compilers/MSVC.cmake ++++ b/cmake/compilers/MSVC.cmake +@@ -77,6 +77,7 @@ if (CMAKE_CXX_COMPILER_ID MATCHES "(Clang|IntelLLVM)") + endif() + set(TBB_OPENMP_NO_LINK_FLAG TRUE) + set(TBB_IPO_COMPILE_FLAGS $<$<NOT:$<CONFIG:Debug>>:-flto>) ++ set(TBB_IPO_LINK_FLAGS $<$<NOT:$<CONFIG:Debug>>:-flto>) + else() + set(TBB_IPO_COMPILE_FLAGS $<$<NOT:$<CONFIG:Debug>>:/GL>) + set(TBB_IPO_LINK_FLAGS $<$<NOT:$<CONFIG:Debug>>:-LTCG> $<$<NOT:$<CONFIG:Debug>>:-INCREMENTAL:NO>) +diff --git a/cmake/utils.cmake b/cmake/utils.cmake +index 06d3a9aee..f74abfcf9 100644 +--- a/cmake/utils.cmake ++++ b/cmake/utils.cmake +@@ -44,3 +44,16 @@ macro(tbb_install_target target) + COMPONENT devel) + endif() + endmacro() ++ ++macro(tbb_handle_ipo target) ++ if (TBB_IPO_PROPERTY) ++ set_target_properties(${target} PROPERTIES INTERPROCEDURAL_OPTIMIZATION TRUE) ++ elseif (TBB_IPO_FLAGS) ++ target_compile_options(${target} PRIVATE ${TBB_IPO_COMPILE_FLAGS}) ++ if (COMMAND target_link_options) ++ target_link_options(${target} PRIVATE ${TBB_IPO_LINK_FLAGS}) ++ else() ++ target_link_libraries(${target} PRIVATE ${TBB_IPO_LINK_FLAGS}) ++ endif() ++ endif() ++endmacro() +diff --git a/src/tbb/CMakeLists.txt b/src/tbb/CMakeLists.txt +index 80fdcdcde..021392d89 100644 +--- a/src/tbb/CMakeLists.txt ++++ b/src/tbb/CMakeLists.txt +@@ -79,7 +79,6 @@ target_compile_options(tbb + ${TBB_WARNING_SUPPRESS} + ${TBB_LIB_COMPILE_FLAGS} + ${TBB_COMMON_COMPILE_FLAGS} +- ${TBB_IPO_COMPILE_FLAGS} + ) + + # Avoid use of target_link_libraries here as it changes /DEF option to \DEF on Windows. +@@ -89,6 +88,8 @@ set_target_properties(tbb PROPERTIES + SOVERSION ${TBB_BINARY_VERSION} + ) + ++tbb_handle_ipo(tbb) ++ + if (TBB_DEF_FILE_PREFIX) # If there's no prefix, assume we're using export directives + set_target_properties(tbb PROPERTIES + LINK_FLAGS ${TBB_LINK_DEF_FILE_FLAG}${CMAKE_CURRENT_SOURCE_DIR}/def/${TBB_DEF_FILE_PREFIX}-tbb.def +@@ -103,14 +104,12 @@ if (COMMAND target_link_options) + PRIVATE + ${TBB_LIB_LINK_FLAGS} + ${TBB_COMMON_LINK_FLAGS} +- ${TBB_IPO_LINK_FLAGS} + ) + else() + target_link_libraries(tbb + PRIVATE + ${TBB_LIB_LINK_FLAGS} + ${TBB_COMMON_LINK_FLAGS} +- ${TBB_IPO_LINK_FLAGS} + ) + endif() + +diff --git a/src/tbbbind/CMakeLists.txt b/src/tbbbind/CMakeLists.txt +index 99b7ccaac..3233ec718 100644 +--- a/src/tbbbind/CMakeLists.txt ++++ b/src/tbbbind/CMakeLists.txt +@@ -46,7 +46,6 @@ function(tbbbind_build TBBBIND_NAME REQUIRED_HWLOC_TARGET) + ${TBB_WARNING_LEVEL} + ${TBB_LIB_COMPILE_FLAGS} + ${TBB_COMMON_COMPILE_FLAGS} +- ${TBB_IPO_COMPILE_FLAGS} + ) + + # Avoid use of target_link_libraries here as it changes /DEF option to \DEF on Windows. +@@ -55,6 +54,9 @@ function(tbbbind_build TBBBIND_NAME REQUIRED_HWLOC_TARGET) + VERSION ${TBBBIND_BINARY_VERSION}.${TBB_BINARY_MINOR_VERSION} + SOVERSION ${TBBBIND_BINARY_VERSION} + ) ++ ++ tbb_handle_ipo(${TBBBIND_NAME}) ++ + if (TBB_DEF_FILE_PREFIX) # If there's no prefix, assume we're using export directives + set_target_properties(${TBBBIND_NAME} PROPERTIES + LINK_FLAGS ${TBB_LINK_DEF_FILE_FLAG}${CMAKE_CURRENT_SOURCE_DIR}/def/${TBB_DEF_FILE_PREFIX}-tbbbind.def +@@ -69,14 +71,12 @@ function(tbbbind_build TBBBIND_NAME REQUIRED_HWLOC_TARGET) + PRIVATE + ${TBB_LIB_LINK_FLAGS} + ${TBB_COMMON_LINK_FLAGS} +- ${TBB_IPO_LINK_FLAGS} + ) + else() + target_link_libraries(${TBBBIND_NAME} + PRIVATE + ${TBB_LIB_LINK_FLAGS} + ${TBB_COMMON_LINK_FLAGS} +- ${TBB_IPO_LINK_FLAGS} + ) + endif() + +diff --git a/src/tbbmalloc/CMakeLists.txt b/src/tbbmalloc/CMakeLists.txt +index f77bc8f10..5a851851f 100644 +--- a/src/tbbmalloc/CMakeLists.txt ++++ b/src/tbbmalloc/CMakeLists.txt +@@ -59,7 +59,6 @@ target_compile_options(tbbmalloc + ${TBB_LIB_COMPILE_FLAGS} + ${TBBMALLOC_LIB_COMPILE_FLAGS} + ${TBB_COMMON_COMPILE_FLAGS} +- ${TBB_IPO_COMPILE_FLAGS} + ) + + enable_language(C) +@@ -72,6 +71,8 @@ set_target_properties(tbbmalloc PROPERTIES + LINKER_LANGUAGE C + ) + ++tbb_handle_ipo(tbbmalloc) ++ + if (TBB_DEF_FILE_PREFIX) # If there's no prefix, assume we're using export directives + set_target_properties(tbbmalloc PROPERTIES + LINK_FLAGS ${TBB_LINK_DEF_FILE_FLAG}${CMAKE_CURRENT_SOURCE_DIR}/def/${TBB_DEF_FILE_PREFIX}-tbbmalloc.def +@@ -88,14 +89,12 @@ if (COMMAND target_link_options) + PRIVATE + ${TBB_LIB_LINK_FLAGS} + ${TBB_COMMON_LINK_FLAGS} +- ${TBB_IPO_LINK_FLAGS} + ) + else() + target_link_libraries(tbbmalloc + PRIVATE + ${TBB_LIB_LINK_FLAGS} + ${TBB_COMMON_LINK_FLAGS} +- ${TBB_IPO_LINK_FLAGS} + ) + endif() + diff --git a/dev-cpp/tbb/tbb-2021.4.0.ebuild b/dev-cpp/tbb/tbb-2021.4.0.ebuild new file mode 100644 index 000000000000..9a99edb24ae8 --- /dev/null +++ b/dev-cpp/tbb/tbb-2021.4.0.ebuild @@ -0,0 +1,37 @@ +# Copyright 1999-2021 Gentoo Authors +# Distributed under the terms of the GNU General Public License v2 + +EAPI=8 + +inherit cmake-multilib flag-o-matic toolchain-funcs + +DESCRIPTION="High level abstract threading library" +HOMEPAGE="https://www.threadingbuildingblocks.org" +SRC_URI="https://github.com/oneapi-src/oneTBB/archive/refs/tags/v${PV}.tar.gz -> ${P}.tar.gz" +S="${WORKDIR}/oneTBB-${PV}" + +LICENSE="Apache-2.0" +# https://github.com/oneapi-src/oneTBB/blob/master/CMakeLists.txt#L53 +# libtbb<SONAME>-libtbbmalloc<SONAME>-libtbbbind<SONAME> +SLOT="0/12-2-3" +KEYWORDS="~alpha ~amd64 ~arm ~arm64 ~hppa ~ia64 ~ppc ~ppc64 ~riscv ~sparc ~x86 ~amd64-linux ~x86-linux" +IUSE="test" +RESTRICT="!test? ( test )" + +RDEPEND="sys-apps/hwloc:=" +DEPEND="${RDEPEND}" +BDEPEND="virtual/pkgconfig" + +PATCHES=( + "${FILESDIR}"/${P}-lto.patch +) + +src_configure() { + local mycmakeargs=( + -DTBB_TEST=$(usex test) + -DTBB_ENABLE_IPO=OFF + -DTBB_STRICT=OFF + ) + + cmake-multilib_src_configure +} |