tbb: Fix ptest build on musl

Two tests fail to compile on musl:

- conformance_resumable_tasks uses its own platform list instead of
  __TBB_RESUMABLE_TASKS, which the library leaves disabled on Linux
  without glibc, so tbb::task::suspend() is not declared.
- test_malloc_overload calls mallopt(), mallinfo() and pvalloc(), which
  are glibc extensions musl does not provide.

Guard both on what is actually available. All 142 tbb ptests pass in
meta-oe-image-ptest-tbb on qemux86-64 musl.

AI-Generated: Uses Claude Code
Signed-off-by: Khem Raj <khem.raj@oss.qualcomm.com>
This commit is contained in:
Khem Raj committed 2026-09-29 07:59:04 -07:00
1 parent 35c75d8978
commit 2791a9502b
3 files changed
+86

No files matched your search

@@ -0,0 +1,27 @@
From: Khem Raj <raj.khem@gmail.com>
Subject: [PATCH] test: Skip conformance_resumable_tasks when resumable tasks are disabled
The library only enables resumable tasks when __TBB_RESUMABLE_TASKS is
set, which excludes Linux with a C library other than glibc (e.g. musl).
test_resumable_tasks.cpp checks that macro, but the conformance test
repeats an older list of platforms and fails to build on musl:
conformance_resumable_tasks.cpp:39:5: error: no member named 'suspend' in namespace 'tbb::task'
Use __TBB_RESUMABLE_TASKS instead, keeping the WINAPI_FAMILY exclusion.
Upstream-Status: Pending
Signed-off-by: Khem Raj <raj.khem@gmail.com>
---
--- a/test/conformance/conformance_resumable_tasks.cpp
+++ b/test/conformance/conformance_resumable_tasks.cpp
@@ -17,8 +17,7 @@
#include "common/test.h"
-#if (!__TBB_WIN8UI_SUPPORT && !defined(WINAPI_FAMILY) && !__ANDROID__ \
- && !__QNX__)
+#if __TBB_RESUMABLE_TASKS && !defined(WINAPI_FAMILY)
#include "oneapi/tbb/task.h"
#include "oneapi/tbb/task_group.h"
@@ -0,0 +1,57 @@
From: Khem Raj <raj.khem@gmail.com>
Subject: [PATCH] test: malloc_overload: Only use glibc malloc extensions where available
mallopt(), mallinfo() and pvalloc() are GNU extensions that musl does not
provide, so test_malloc_overload fails to build there:
test_malloc_overload.cpp:401:13: error: use of undeclared identifier 'mallopt'
test_malloc_overload.cpp:451:18: error: use of undeclared identifier 'pvalloc'; did you mean 'valloc'?
test_malloc_overload.cpp:466:21: error: variable has incomplete type 'struct mallinfo'
Only test them on glibc (and Android for mallopt()/mallinfo()), matching
the guard tbbmalloc_proxy already uses for its mallinfo() override.
Upstream-Status: Pending
Signed-off-by: Khem Raj <raj.khem@gmail.com>
---
--- a/test/tbbmalloc/test_malloc_overload.cpp
+++ b/test/tbbmalloc/test_malloc_overload.cpp
@@ -53,7 +53,9 @@
#endif
#define __TBB_POSIX_MEMALIGN_PRESENT (__unix__ && !__ANDROID__) || __APPLE__
-#define __TBB_PVALLOC_PRESENT __unix__ && !__ANDROID__
+#define __TBB_PVALLOC_PRESENT __unix__ && !__ANDROID__ && __GLIBC__
+// mallopt() and mallinfo() are not provided by every C library, e.g. musl
+#define __TBB_MALLOPT_MALLINFO_PRESENT __unix__ && (__GLIBC__ || __ANDROID__)
#if __GLIBC__
// aligned_alloc available since GLIBC 2.16
#define __TBB_ALIGNED_ALLOC_PRESENT __GLIBC_PREREQ(2, 16)
@@ -397,9 +399,9 @@
//! Testing tbbmalloc_proxy overload capabilities
//! \brief \ref error_guessing
TEST_CASE("Main set of tests") {
-#if __unix__
+#if __TBB_MALLOPT_MALLINFO_PRESENT
REQUIRE(mallopt(0, 0)); // add dummy mallopt call for coverage
-#endif // __unix__
+#endif // __TBB_MALLOPT_MALLINFO_PRESENT
void *ptr = nullptr;
utils::suppress_unused_warning(ptr); // for android
@@ -456,6 +458,7 @@
CheckMemalignFuncOverload(aligned_alloc, free);
#endif
+#if __TBB_MALLOPT_MALLINFO_PRESENT
#if __INTEL_COMPILER
#pragma warning(push)
#pragma warning(disable: 1478)
@@ -473,6 +476,7 @@
REQUIRE((!info.arena && !info.ordblks && !info.smblks && !info.hblks
&& !info.hblkhd && !info.usmblks && !info.fsmblks
&& !info.uordblks && !info.fordblks && !info.keepcost));
+#endif // __TBB_MALLOPT_MALLINFO_PRESENT
#if !__ANDROID__
// These non-standard functions are exported by GLIBC, and might be used
@@ -16,6 +16,8 @@ BRANCH = "onetbb_2023"
SRCREV = "3046c8b0c29df995980003ea24f4d78c80ec0c8d"
SRC_URI = "git://github.com/oneapi-src/oneTBB.git;protocol=https;branch=${BRANCH} \
file://run-ptest \
file://0001-test-Skip-conformance_resumable_tasks-when-resumable.patch \
file://0002-test-malloc_overload-Only-use-glibc-malloc-extension.patch \
"
LDFLAGS += "${@bb.utils.contains('DISTRO_FEATURES', 'ld-is-lld', ' -Wl,--undefined-version', '', d)}"