Skip to Content.
Sympa Menu

sm-commit - [SM-Commit] GIT changes to master grimoire by Ismael Luceno (e6fe2021033124e33b315419ff9805c22af8bda9)

sm-commit AT lists.ibiblio.org

Subject: Source Mage code commit list

List archive

Chronological Thread  
  • From: Ismael Luceno <scm AT sourcemage.org>
  • To: sm-commit AT lists.ibiblio.org
  • Subject: [SM-Commit] GIT changes to master grimoire by Ismael Luceno (e6fe2021033124e33b315419ff9805c22af8bda9)
  • Date: Fri, 9 Sep 2022 18:54:33 +0000

GIT changes to master grimoire by Ismael Luceno <ismael AT sourcemage.org>:

devel/mold/DEPENDS
| 2
devel/mold/HISTORY
| 3
libs/tbb/BUILD
| 10 +
libs/tbb/DEPENDS
| 5
libs/tbb/DETAILS
| 1
libs/tbb/HISTORY
| 13 ++
libs/tbb/PRE_BUILD
| 3
libs/tbb/patches/0001-Define-ITT_ARCH_IA64-when-undefiend.patch
| 31 ++++

libs/tbb/patches/0001-Detect-32-bit-x86-systems-while-adding-mwaitpkg-option.patch
| 51 +++++++
libs/tbb/patches/0001-Fix-build-against-musl-libc.patch
| 31 ++++
libs/tbb/patches/0001-Retry-if-pthread_create-fails-with-EAGAIN.patch
| 64 ++++++++++
libs/tbb/patches/0002-Enable-building-against-libucontext.patch
| 57 ++++++++
libs/tbb/patches/fix-dynload.patch
| 14 ++
13 files changed, 284 insertions(+), 1 deletion(-)

New commits:
commit e6fe2021033124e33b315419ff9805c22af8bda9
Author: Ismael Luceno <ismael AT sourcemage.org>
Commit: Ismael Luceno <ismael AT sourcemage.org>

mold: Switch dep to SSL

commit da97c0358b1340a3aa0b472d588f4856598a11fb
Author: Ismael Luceno <ismael AT sourcemage.org>
Commit: Ismael Luceno <ismael AT sourcemage.org>

tbb: PATCHLEVEL++

commit 78fc7021499bd0e84d3195d82e65f6633f312407
Author: Ismael Luceno <ismael AT sourcemage.org>
Commit: Ismael Luceno <ismael AT sourcemage.org>

tbb: Fix spurious thread creation issues

commit fd30fdc2fc204569b1374a26b4ed553a441c1f32
Author: Ismael Luceno <ismael AT sourcemage.org>
Commit: Ismael Luceno <ismael AT sourcemage.org>

tbb: Fix portability build issues

commit bfbf0f16240edc1bc82b243072ec3af703a1dff5
Author: Ismael Luceno <ismael AT sourcemage.org>
Commit: Ismael Luceno <ismael AT sourcemage.org>

tbb: Fix build against musl

diff --git a/devel/mold/DEPENDS b/devel/mold/DEPENDS
index 58b1a6a..75c0611 100755
--- a/devel/mold/DEPENDS
+++ b/devel/mold/DEPENDS
@@ -2,5 +2,5 @@ depends cmake &&
depends llvm &&
depends tbb &&
depends xxhash &&
-depends openssl &&
+depends SSL &&
depends zlib
diff --git a/devel/mold/HISTORY b/devel/mold/HISTORY
index 5004777..c0f2653 100644
--- a/devel/mold/HISTORY
+++ b/devel/mold/HISTORY
@@ -1,3 +1,6 @@
+2022-09-09 Ismael Luceno <ismael AT sourcemage.org>
+ * DEPENDS: switched to SSL
+
2022-08-04 Florian Franzmann <siflfran AT hawo.stw.uni-erlangen.de>
* DETAILS: version 1.4.2

diff --git a/libs/tbb/BUILD b/libs/tbb/BUILD
index 6ee19b3..a776dfd 100755
--- a/libs/tbb/BUILD
+++ b/libs/tbb/BUILD
@@ -1,3 +1,13 @@
+case "$CM_TESTS:$HOST" in
+ (-DBUILD_TESTING=1:*-musl)
+ message "${PROBLEM_COLOR}Disabling tests, these are incompatible with" \
+ "${SPELL_COLOR}musl$DEFAULT_COLOR"
+ ;&
+ (-DBUILD_TESTING=0:*)
+ OPTS+=" -DTBB_TEST=off"
+ ;;
+esac &&
+
OPTS+=" -DTBB_STRICT=off" &&

default_build
diff --git a/libs/tbb/DEPENDS b/libs/tbb/DEPENDS
index efa39f4..a3c47fa 100755
--- a/libs/tbb/DEPENDS
+++ b/libs/tbb/DEPENDS
@@ -1,3 +1,8 @@
source "$GRIMOIRE/CMAKE_DEPENDS" &&

+case "$HOST" in
+ (*-musl)
+ depends libucontext
+ ;;
+esac &&
depends -sub CXX gcc
diff --git a/libs/tbb/DETAILS b/libs/tbb/DETAILS
index 2412fa3..d0ca905 100755
--- a/libs/tbb/DETAILS
+++ b/libs/tbb/DETAILS
@@ -1,6 +1,7 @@
source "$GRIMOIRE/CMAKE_FUNCTIONS"
SPELL=tbb
VERSION=2021.5.0
+ PATCHLEVEL=1

SOURCE_HASH=sha512:0e7b71022e397a6d7abb0cea106847935ae79a1e12a6976f8d038668c6eca8775ed971202c5bd518f7e517092b67af805cc5feb04b5c3a40e9fbf972cc703a46
SOURCE=$SPELL-$VERSION.tar.gz
SOURCE_DIRECTORY=$BUILD_DIRECTORY/oneTBB-${VERSION}
diff --git a/libs/tbb/HISTORY b/libs/tbb/HISTORY
index 1ccf4cc..1be11d9 100644
--- a/libs/tbb/HISTORY
+++ b/libs/tbb/HISTORY
@@ -1,3 +1,16 @@
+2022-09-09 Ismael Luceno <ismael AT sourcemage.org>
+ * BUILD, DEPENDS, PRE_BUILD,
+ patches/0001-Fix-build-against-musl-libc.patch,
+ patches/0002-Fix-build-against-libucontext.patch,
+ patches/fix-dynload.patch:
+ fixed build against musl
+ * 0001-Define-ITT_ARCH_IA64-when-undefiend.patch,
+ 0001-Detect-32-bit-x86-systems-while-adding-mwaitpkg-option.patch:
+ added portability build fixes
+ * 0001-Retry-if-pthread_create-fails-with-EAGAIN.patch,
+ added patch to fix spurious thread creation issues
+ * DETAILS: PATCHLEVEL++
+
2021-12-26 Florian Franzmann <bwlf AT bandrate.org>
* DETAILS: version 2021.5.0

diff --git a/libs/tbb/PRE_BUILD b/libs/tbb/PRE_BUILD
new file mode 100755
index 0000000..c230ad1
--- /dev/null
+++ b/libs/tbb/PRE_BUILD
@@ -0,0 +1,3 @@
+default_pre_build &&
+cd "$SOURCE_DIRECTORY" &&
+apply_patch_dir patches
diff --git a/libs/tbb/patches/0001-Define-ITT_ARCH_IA64-when-undefiend.patch
b/libs/tbb/patches/0001-Define-ITT_ARCH_IA64-when-undefiend.patch
new file mode 100644
index 0000000..0f7f160
--- /dev/null
+++ b/libs/tbb/patches/0001-Define-ITT_ARCH_IA64-when-undefiend.patch
@@ -0,0 +1,31 @@
+From 524d9bebf06439048072e5266fca3cb7ce2aacc1 Mon Sep 17 00:00:00 2001
+From: Felix Yan <felixonmars AT archlinux.org>
+Date: Sun, 29 Aug 2021 20:11:28 +0800
+Subject: [PATCH] Define ITT_ARCH_IA64 when undefiend
+
+I am not sure why ITT_ARCH_IA64 was skipped here. This results
+in unsupported architecture (RISC-V, in my case) falls to
+the `ITT_ARCH==ITT_ARCH_IA64` branch below (because both
+of them are undefined) and results in a build error due to
+`__TBB_machine_fetchadd4` being undefined.
+
+Origin: Arch Linux
+---
+ src/tbb/tools_api/ittnotify_config.h | 4 ++++
+ 1 file changed, 4 insertions(+)
+
+diff --git a/src/tbb/tools_api/ittnotify_config.h
b/src/tbb/tools_api/ittnotify_config.h
+index 8ecc23781..f904a8e9d 100644
+--- a/src/tbb/tools_api/ittnotify_config.h
++++ b/src/tbb/tools_api/ittnotify_config.h
+@@ -147,6 +147,10 @@
+ # define ITT_ARCH_IA32E 2
+ #endif /* ITT_ARCH_IA32E */
+
++#ifndef ITT_ARCH_IA64
++# define ITT_ARCH_IA64 3
++#endif /* ITT_ARCH_IA64 */
++
+ #ifndef ITT_ARCH_ARM
+ # define ITT_ARCH_ARM 4
+ #endif /* ITT_ARCH_ARM */
diff --git
a/libs/tbb/patches/0001-Detect-32-bit-x86-systems-while-adding-mwaitpkg-option.patch

b/libs/tbb/patches/0001-Detect-32-bit-x86-systems-while-adding-mwaitpkg-option.patch
new file mode 100644
index 0000000..a745a61
--- /dev/null
+++
b/libs/tbb/patches/0001-Detect-32-bit-x86-systems-while-adding-mwaitpkg-option.patch
@@ -0,0 +1,51 @@
+From 542a27fa1cfafaf76772e793549d9f4d288d03a9 Mon Sep 17 00:00:00 2001
+From: Ilya Isaev <ilya.isaev AT intel.com>
+Date: Fri, 8 Oct 2021 10:18:16 +0300
+Subject: [PATCH] Detect 32 bit x86 systems while adding -mwaitpkg option
+
+Signed-off-by: Ilya Isaev <ilya.isaev AT intel.com>
+---
+ cmake/compilers/Clang.cmake | 2 +-
+ cmake/compilers/GNU.cmake | 2 +-
+ cmake/compilers/MSVC.cmake | 2 +-
+ 3 files changed, 3 insertions(+), 3 deletions(-)
+
+diff --git a/cmake/compilers/Clang.cmake b/cmake/compilers/Clang.cmake
+index bb7401e34..d551d3be2 100644
+--- a/cmake/compilers/Clang.cmake
++++ b/cmake/compilers/Clang.cmake
+@@ -44,7 +44,7 @@ if (NOT TBB_STRICT AND COMMAND tbb_remove_compile_flag)
+ endif()
+
+ # Enable Intel(R) Transactional Synchronization Extensions (-mrtm) and
WAITPKG instructions support (-mwaitpkg) on relevant processors
+-if (CMAKE_SYSTEM_PROCESSOR MATCHES "(x86|AMD64)")
++if (CMAKE_SYSTEM_PROCESSOR MATCHES "(x86|AMD64|i.86)")
+ set(TBB_COMMON_COMPILE_FLAGS ${TBB_COMMON_COMPILE_FLAGS} -mrtm
$<$<NOT:$<VERSION_LESS:${CMAKE_CXX_COMPILER_VERSION},12.0>>:-mwaitpkg>)
+ endif()
+
+diff --git a/cmake/compilers/GNU.cmake b/cmake/compilers/GNU.cmake
+index 86958e3a8..fee1c3bc2 100644
+--- a/cmake/compilers/GNU.cmake
++++ b/cmake/compilers/GNU.cmake
+@@ -36,7 +36,7 @@ if (NOT CMAKE_GENERATOR MATCHES "Ninja" AND NOT
CMAKE_CXX_DEPENDS_USE_COMPILER)
+ endif()
+
+ # Enable Intel(R) Transactional Synchronization Extensions (-mrtm) and
WAITPKG instructions support (-mwaitpkg) on relevant processors
+-if (CMAKE_SYSTEM_PROCESSOR MATCHES "(x86|AMD64)")
++if (CMAKE_SYSTEM_PROCESSOR MATCHES "(x86|AMD64|i.86)")
+ set(TBB_COMMON_COMPILE_FLAGS ${TBB_COMMON_COMPILE_FLAGS} -mrtm
$<$<AND:$<NOT:$<CXX_COMPILER_ID:Intel>>,$<NOT:$<VERSION_LESS:${CMAKE_CXX_COMPILER_VERSION},11.0>>>:-mwaitpkg>)
+ endif()
+
+diff --git a/cmake/compilers/MSVC.cmake b/cmake/compilers/MSVC.cmake
+index acf0952cf..2d2c29a6f 100644
+--- a/cmake/compilers/MSVC.cmake
++++ b/cmake/compilers/MSVC.cmake
+@@ -72,7 +72,7 @@ if (TBB_WINDOWS_DRIVER)
+ endif()
+
+ if (CMAKE_CXX_COMPILER_ID MATCHES "(Clang|IntelLLVM)")
+- if (CMAKE_SYSTEM_PROCESSOR MATCHES "(x86|AMD64)")
++ if (CMAKE_SYSTEM_PROCESSOR MATCHES "(x86|AMD64|i.86)")
+ set(TBB_COMMON_COMPILE_FLAGS ${TBB_COMMON_COMPILE_FLAGS} -mrtm
-mwaitpkg)
+ endif()
+ set(TBB_OPENMP_NO_LINK_FLAG TRUE)
diff --git a/libs/tbb/patches/0001-Fix-build-against-musl-libc.patch
b/libs/tbb/patches/0001-Fix-build-against-musl-libc.patch
new file mode 100644
index 0000000..d000f1d
--- /dev/null
+++ b/libs/tbb/patches/0001-Fix-build-against-musl-libc.patch
@@ -0,0 +1,31 @@
+From 1dccd3404486f171085d7239b2fbc710657c156e Mon Sep 17 00:00:00 2001
+From: Ismael Luceno <ismael AT iodev.co.uk>
+Date: Fri, 9 Sep 2022 16:18:18 +0200
+Subject: [PATCH 1/2] Fix build against musl libc
+
+Probably MALLOC_UNIXLIKE_OVERLOAD_ENABLED only works with glibc, so use
+__GLIBC__ in addition to __linux__ to define it.
+
+Origin: Source Mage GNU/Linux
+Upstream-Status: Pending
+Signed-off-by: Ismael Luceno <ismael AT iodev.co.uk>
+---
+ src/tbbmalloc_proxy/proxy.h | 2 +-
+ 1 file changed, 1 insertion(+), 1 deletion(-)
+
+diff --git a/src/tbbmalloc_proxy/proxy.h b/src/tbbmalloc_proxy/proxy.h
+index 5f0133f9e092..ba1a07c396c1 100644
+--- a/src/tbbmalloc_proxy/proxy.h
++++ b/src/tbbmalloc_proxy/proxy.h
+@@ -17,7 +17,7 @@
+ #ifndef _TBB_malloc_proxy_H_
+ #define _TBB_malloc_proxy_H_
+
+-#define MALLOC_UNIXLIKE_OVERLOAD_ENABLED __linux__
++#define MALLOC_UNIXLIKE_OVERLOAD_ENABLED (__linux__ && __GLIBC__)
+ #define MALLOC_ZONE_OVERLOAD_ENABLED __APPLE__
+
+ // MALLOC_UNIXLIKE_OVERLOAD_ENABLED depends on MALLOC_CHECK_RECURSION stuff
+--
+2.37.3
+
diff --git
a/libs/tbb/patches/0001-Retry-if-pthread_create-fails-with-EAGAIN.patch
b/libs/tbb/patches/0001-Retry-if-pthread_create-fails-with-EAGAIN.patch
new file mode 100644
index 0000000..95e7873
--- /dev/null
+++ b/libs/tbb/patches/0001-Retry-if-pthread_create-fails-with-EAGAIN.patch
@@ -0,0 +1,64 @@
+From f12c93efd04991bc982a27e2fa6142538c33ca82 Mon Sep 17 00:00:00 2001
+From: Rui Ueyama <ruiu AT cs.stanford.edu>
+Date: Sat, 7 May 2022 19:55:24 +0800
+Subject: [PATCH] Retry if pthread_create fails with EAGAIN
+
+On many Unix-like systems, pthread_create can fail spuriously even if
+the running machine has enough resources to spawn a new thread.
+Therefore, if EAGAIN is returned from pthread_create, we actually have
+to try again.
+
+I observed this issue when running the mold linker
+(https://github.com/rui314/mold) under a heavy load. mold uses OneTBB
+for parallelization.
+
+As another data point, Go has the same logic to retry on EAGAIN:
+https://go-review.googlesource.com/c/go/+/33894/
+
+nanosleep is defined in POSIX 2001, so I believe that all Unix-like
+systems support it.
+
+Signed-off-by: Rui Ueyama <ruiu AT cs.stanford.edu>
+Upstream-Status: Submitted [https://github.com/oneapi-src/oneTBB/pull/824]
+---
+ src/tbb/rml_thread_monitor.h | 19 ++++++++++++++++++-
+ 1 file changed, 18 insertions(+), 1 deletion(-)
+
+diff --git a/src/tbb/rml_thread_monitor.h b/src/tbb/rml_thread_monitor.h
+index 13b556380..5b844b232 100644
+--- a/src/tbb/rml_thread_monitor.h
++++ b/src/tbb/rml_thread_monitor.h
+@@ -31,6 +31,7 @@
+ #include <pthread.h>
+ #include <cstring>
+ #include <cstdlib>
++#include <time.h>
+ #else
+ #error Unsupported platform
+ #endif
+@@ -191,8 +192,24 @@ 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_t handle;
+- check( pthread_create( &handle, &s, thread_routine, arg ),
"pthread_create has failed" );
++ int tries = 0;
++ for (;;) {
++ int error_code = pthread_create(&handle, &s, thread_routine, arg);
++ if (!error_code)
++ break;
++ if (error_code != EAGAIN || tries++ > 20) {
++ handle_perror(error_code, "pthread_create has failed");
++ break;
++ }
++
++ // pthreaed_create can spuriously fail on many Unix-like systems.
++ // Retry after tries * 1 millisecond.
++ struct timespec ts = {0, tries * 1000 * 1000};
++ nanosleep(&ts, NULL);
++ }
++
+ check( pthread_attr_destroy( &s ), "pthread_attr_destroy has failed" );
+ return handle;
+ }
diff --git a/libs/tbb/patches/0002-Enable-building-against-libucontext.patch
b/libs/tbb/patches/0002-Enable-building-against-libucontext.patch
new file mode 100644
index 0000000..6767057
--- /dev/null
+++ b/libs/tbb/patches/0002-Enable-building-against-libucontext.patch
@@ -0,0 +1,57 @@
+From f5872f3f9726a2f91c0189735c0dbcf7b029337f Mon Sep 17 00:00:00 2001
+From: Ismael Luceno <ismael AT iodev.co.uk>
+Date: Fri, 9 Sep 2022 16:56:49 +0200
+Subject: [PATCH 2/2] Enable building against libucontext
+
+The ucontext.h API may be implemented outside the libc.
+
+Origin: Source Mage GNU/Linux
+Upstream-Status: Pending
+Signed-off-by: Ismael Luceno <ismael AT iodev.co.uk>
+---
+ cmake/ucontext.cmake | 20 ++++++++++++++++++++
+ src/tbb/CMakeLists.txt | 1 +
+ 2 files changed, 21 insertions(+)
+ create mode 100644 cmake/ucontext.cmake
+
+diff --git a/cmake/ucontext.cmake b/cmake/ucontext.cmake
+new file mode 100644
+index 000000000000..26f22559c78f
+--- /dev/null
++++ b/cmake/ucontext.cmake
+@@ -0,0 +1,20 @@
++# The ucontext API may be implemented outside the default library set
++include(CheckSymbolExists)
++if (NOT DEFINED UCONTEXT_LIBRARIES
++ AND CMAKE_SYSTEM_NAME MATCHES "^Linux")
++ check_symbol_exists("getcontext" "ucontext.h" HAVE_UCONTEXT)
++ if (NOT HAVE_UCONTEXT)
++ message(STATUS "Checking for libucontext")
++ find_library(LIBUCONTEXT "ucontext")
++ if (LIBUCONTEXT STREQUAL "LIBUCONTEXT-NOTFOUND")
++ message(WARNING "No ucontext API available")
++ set(LIBUCONTEXT "")
++ else()
++ message(STATUS "Found libucontext: ${LIBUCONTEXT}")
++ set(HAVE_UCONTEXT 1)
++ endif()
++ set(UCONTEXT_LIBRARIES "${LIBUCONTEXT}" CACHE FILEPATH
++ "Library providing the ucontext API (if not in the default set)")
++ endif()
++endif()
++mark_as_advanced(LIBUCONTEXT HAVE_UCONTEXT)
+diff --git a/src/tbb/CMakeLists.txt b/src/tbb/CMakeLists.txt
+index 7f8228c09d11..c24db1f34bd2 100644
+--- a/src/tbb/CMakeLists.txt
++++ b/src/tbb/CMakeLists.txt
+@@ -118,6 +118,7 @@ target_link_libraries(tbb
+ Threads::Threads
+ ${TBB_LIB_LINK_LIBS}
+ ${TBB_COMMON_LINK_LIBS}
++ ${UCONTEXT_LIBRARIES}
+ )
+
+ tbb_install_target(tbb)
+--
+2.37.3
+
diff --git a/libs/tbb/patches/fix-dynload.patch
b/libs/tbb/patches/fix-dynload.patch
new file mode 100644
index 0000000..8d5ac69
--- /dev/null
+++ b/libs/tbb/patches/fix-dynload.patch
@@ -0,0 +1,14 @@
+RTLD_DEEPBIND is a glibc definition
+
+Origin: Alpine Linux
+--- a/src/tbb/dynamic_link.cpp
++++ b/src/tbb/dynamic_link.cpp
+@@ -413,7 +413,7 @@
+ int flags = RTLD_NOW;
+ if (local_binding) {
+ flags = flags | RTLD_LOCAL;
+-#if __linux__ && !__ANDROID__ && !__TBB_USE_SANITIZERS
++#if __linux__ && __GLIBC__ && !__ANDROID__ && !__TBB_USE_SANITIZERS
+ flags = flags | RTLD_DEEPBIND;
+ #endif
+ } else {



  • [SM-Commit] GIT changes to master grimoire by Ismael Luceno (e6fe2021033124e33b315419ff9805c22af8bda9), Ismael Luceno, 09/09/2022

Archive powered by MHonArc 2.6.24.

Top of Page