From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from lists.gentoo.org (pigeon.gentoo.org [208.92.234.80]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (No client certificate requested) by finch.gentoo.org (Postfix) with ESMTPS id D8DF6158021 for ; Sat, 19 Nov 2022 03:19:59 +0000 (UTC) Received: from pigeon.gentoo.org (localhost [127.0.0.1]) by pigeon.gentoo.org (Postfix) with SMTP id AE16BE085B; Sat, 19 Nov 2022 03:19:58 +0000 (UTC) Received: from smtp.gentoo.org (woodpecker.gentoo.org [140.211.166.183]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits)) (No client certificate requested) by pigeon.gentoo.org (Postfix) with ESMTPS id 942A3E085B for ; Sat, 19 Nov 2022 03:19:58 +0000 (UTC) Received: from oystercatcher.gentoo.org (oystercatcher.gentoo.org [148.251.78.52]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by smtp.gentoo.org (Postfix) with ESMTPS id 873C63411F1 for ; Sat, 19 Nov 2022 03:19:57 +0000 (UTC) Received: from localhost.localdomain (localhost [IPv6:::1]) by oystercatcher.gentoo.org (Postfix) with ESMTP id D9E08756 for ; Sat, 19 Nov 2022 03:19:55 +0000 (UTC) From: "Sam James" To: gentoo-commits@lists.gentoo.org Content-Transfer-Encoding: 8bit Content-type: text/plain; charset=UTF-8 Reply-To: gentoo-dev@lists.gentoo.org, "Sam James" Message-ID: <1668827953.ae4a95da4cdb44ac97adfc4c48d89317c315b5d1.sam@gentoo> Subject: [gentoo-commits] repo/gentoo:master commit in: dev-cpp/tbb/, dev-cpp/tbb/files/ X-VCS-Repository: repo/gentoo X-VCS-Files: dev-cpp/tbb/files/tbb-2021.7.0-pthread-eagain.patch dev-cpp/tbb/tbb-2021.7.0-r1.ebuild X-VCS-Directories: dev-cpp/tbb/ dev-cpp/tbb/files/ X-VCS-Committer: sam X-VCS-Committer-Name: Sam James X-VCS-Revision: ae4a95da4cdb44ac97adfc4c48d89317c315b5d1 X-VCS-Branch: master Date: Sat, 19 Nov 2022 03:19:55 +0000 (UTC) Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Subscribe: List-Id: Gentoo Linux mail X-BeenThere: gentoo-commits@lists.gentoo.org X-Auto-Response-Suppress: DR, RN, NRN, OOF, AutoReply X-Archives-Salt: c0d16b1d-6b7e-4355-85db-a0b857af3645 X-Archives-Hash: 0442ae22424609cfed28c10c8d93186d commit: ae4a95da4cdb44ac97adfc4c48d89317c315b5d1 Author: Sam James gentoo org> AuthorDate: Sat Nov 19 02:27:29 2022 +0000 Commit: Sam James gentoo org> CommitDate: Sat Nov 19 03:19:13 2022 +0000 URL: https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=ae4a95da dev-cpp/tbb: backport pthread EAGAIN patch for mold Closes: https://bugs.gentoo.org/881161 Signed-off-by: Sam James gentoo.org> .../tbb/files/tbb-2021.7.0-pthread-eagain.patch | 135 +++++++++++++++++++++ dev-cpp/tbb/tbb-2021.7.0-r1.ebuild | 41 +++++++ 2 files changed, 176 insertions(+) diff --git a/dev-cpp/tbb/files/tbb-2021.7.0-pthread-eagain.patch b/dev-cpp/tbb/files/tbb-2021.7.0-pthread-eagain.patch new file mode 100644 index 000000000000..6c0912ec96b7 --- /dev/null +++ b/dev-cpp/tbb/files/tbb-2021.7.0-pthread-eagain.patch @@ -0,0 +1,135 @@ +https://bugs.gentoo.org/881161 +https://github.com/rui314/mold/issues/410 +https://github.com/oneapi-src/oneTBB/commit/ceacd2207edfb72a8fc235213265afe68ce74ad0 +https://github.com/oneapi-src/oneTBB/commit/137c1a88b690acf3525e0f279720ac489ce66481 + +From ceacd2207edfb72a8fc235213265afe68ce74ad0 Mon Sep 17 00:00:00 2001 +From: Ilya Isaev +Date: Wed, 26 Oct 2022 13:13:51 +0200 +Subject: [PATCH] Rework test_eh_thread to avoid sporadic failures (#946) + +Signed-off-by: Isaev, Ilya +--- a/test/tbb/test_eh_thread.cpp ++++ b/test/tbb/test_eh_thread.cpp +@@ -54,15 +54,16 @@ void limitThreads(size_t limit) + CHECK_MESSAGE(0 == ret, "setrlimit has returned an error"); + } + +-static bool g_exception_caught = false; +-static std::mutex m; +-static std::condition_variable cv; +-static std::atomic stop{ false }; ++size_t getThreadLimit() { ++ rlimit rlim; ++ ++ int ret = getrlimit(RLIMIT_NPROC, &rlim); ++ CHECK_MESSAGE(0 == ret, "getrlimit has returned an error"); ++ return rlim.rlim_cur; ++} + + static void* thread_routine(void*) + { +- std::unique_lock lock(m); +- cv.wait(lock, [] { return stop == true; }); + return nullptr; + } + +@@ -94,32 +95,17 @@ TEST_CASE("Too many threads") { + } + + // Some systems set really big limit (e.g. >45К) for the number of processes/threads +- limitThreads(1024); +- +- std::thread /* isolate test */ ([] { +- std::vector threads; +- stop = false; +- auto finalize = [&] { +- stop = true; +- cv.notify_all(); +- for (auto& t : threads) { +- t.join(); +- } +- }; +- +- for (int i = 0;; ++i) { ++ limitThreads(1); ++ if (getThreadLimit() == 1) { ++ for (int attempt = 0; attempt < 5; ++attempt) { + Thread thread; +- if (!thread.isValid()) { +- break; +- } +- threads.push_back(thread); +- if (i == 1024) { +- WARN_MESSAGE(false, "setrlimit seems having no effect"); +- finalize(); ++ if (thread.isValid()) { ++ WARN_MESSAGE(false, "We were able to create a thread. setrlimit seems having no effect"); ++ thread.join(); + return; + } + } +- g_exception_caught = false; ++ bool g_exception_caught = false; + try { + // Initialize the library to create worker threads + tbb::parallel_for(0, 2, [](int) {}); +@@ -132,9 +118,10 @@ TEST_CASE("Too many threads") { + } + // Do not CHECK to avoid memory allocation (we can be out of memory) + if (!g_exception_caught) { +- FAIL("No exception was caught"); ++ FAIL("No exception was thrown on library initialization"); + } +- finalize(); +- }).join(); ++ } else { ++ WARN_MESSAGE(false, "setrlimit seems having no effect"); ++ } + } + #endif + +From 137c1a88b690acf3525e0f279720ac489ce66481 Mon Sep 17 00:00:00 2001 +From: Rui Ueyama +Date: Wed, 26 Oct 2022 04:54:20 -0700 +Subject: [PATCH] Retry if pthread_create fails with EAGAIN (#824) + +Signed-off-by: Rui Ueyama +--- a/src/tbb/rml_thread_monitor.h ++++ b/src/tbb/rml_thread_monitor.h +@@ -31,6 +31,7 @@ + #include + #include + #include ++#include + #else + #error Unsupported platform + #endif +@@ -191,8 +192,25 @@ inline thread_monitor::handle_type thread_monitor::launch( void* (*thread_routin + check(pthread_attr_init( &s ), "pthread_attr_init has failed"); + if( stack_size>0 ) + check(pthread_attr_setstacksize( &s, stack_size ), "pthread_attr_setstack_size has failed" ); ++ ++ // pthread_create(2) can spuriously fail with EAGAIN. We retry ++ // max_num_tries times with progressively longer wait times. + pthread_t handle; +- check( pthread_create( &handle, &s, thread_routine, arg ), "pthread_create has failed" ); ++ const int max_num_tries = 20; ++ int error = EAGAIN; ++ ++ for (int i = 0; i < max_num_tries && error == EAGAIN; i++) { ++ if (i != 0) { ++ // Wait i milliseconds ++ struct timespec ts = {0, i * 1000 * 1000}; ++ nanosleep(&ts, NULL); ++ } ++ error = pthread_create(&handle, &s, thread_routine, arg); ++ } ++ ++ if (error) ++ handle_perror(error, "pthread_create has failed"); ++ + check( pthread_attr_destroy( &s ), "pthread_attr_destroy has failed" ); + return handle; + } + diff --git a/dev-cpp/tbb/tbb-2021.7.0-r1.ebuild b/dev-cpp/tbb/tbb-2021.7.0-r1.ebuild new file mode 100644 index 000000000000..d88f920769a0 --- /dev/null +++ b/dev-cpp/tbb/tbb-2021.7.0-r1.ebuild @@ -0,0 +1,41 @@ +# Copyright 1999-2022 Gentoo Authors +# Distributed under the terms of the GNU General Public License v2 + +EAPI=8 + +inherit cmake-multilib flag-o-matic + +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-libtbbmalloc-libtbbbind +SLOT="0/12.5-2.5-3.5" +KEYWORDS="~alpha ~amd64 ~arm ~arm64 ~hppa ~ia64 ~ppc ~ppc64 ~riscv ~sparc ~x86 ~amd64-linux ~x86-linux ~x64-macos" +IUSE="test" +RESTRICT="!test? ( test )" + +RDEPEND="!kernel_Darwin? ( sys-apps/hwloc:= )" +DEPEND="${RDEPEND}" +BDEPEND="virtual/pkgconfig" + +PATCHES=( + "${FILESDIR}"/${PN}-2021.7.0-pthread-eagain.patch +) + +src_configure() { + # bug #872287 + filter-flags -D_GLIBCXX_ASSERTIONS + append-cppflags -U_GLIBCXX_ASSERTIONS + + local mycmakeargs=( + -DTBB_TEST=$(usex test) + -DTBB_ENABLE_IPO=OFF + -DTBB_STRICT=OFF + ) + + cmake-multilib_src_configure +}