From 287b54b49c52e2c34dc1c87681025d8ced98fa65 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=B6rg=20Thalheim?= Date: Fri, 7 Nov 2025 20:27:49 +0100 Subject: [PATCH] build: Disable libstdc++ TBB backend to avoid unnecessary dependency boost::concurrent_flat_map (used in libutil and libstore) includes the C++17 header. GCC's libstdc++ implements parallel algorithms using Intel TBB as the backend, which creates a link-time dependency on libtbb even though we don't actually use any parallel algorithms. Disable the TBB backend for libstdc++ by setting _GLIBCXX_USE_TBB_PAR_BACKEND=0. This makes parallel algorithms fall back to serial execution, which is acceptable since we don't use them anyway. This only affects libstdc++ (GCC's standard library); other standard libraries like libc++ (LLVM) are unaffected. (cherry picked from commit 2f3ec16793b4ad029254be1ae25e7824ec0c1a71) --- nix-meson-build-support/common/meson.build | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/nix-meson-build-support/common/meson.build b/nix-meson-build-support/common/meson.build index 595503f61..23013d6ee 100644 --- a/nix-meson-build-support/common/meson.build +++ b/nix-meson-build-support/common/meson.build @@ -42,6 +42,26 @@ if cxx.get_id() == 'clang' add_project_arguments('-fpch-instantiate-templates', language : 'cpp') endif +# Detect if we're using libstdc++ (GCC's standard library) +# libstdc++ uses Intel TBB as backend for C++17 parallel algorithms when is included. +# boost::concurrent_flat_map includes , which would require linking against TBB. +# Since we don't actually use parallel algorithms, disable the TBB backend to avoid the dependency. +# TBB is a dependency of blake3 and leaking into our build environment. +is_using_libstdcxx = cxx.compiles( + ''' + #include + #ifndef __GLIBCXX__ + #error "not libstdc++" + #endif + int main() { return 0; } +''', + name : 'using libstdc++', +) + +if is_using_libstdcxx + add_project_arguments('-D_GLIBCXX_USE_TBB_PAR_BACKEND=0', language : 'cpp') +endif + # Darwin ld doesn't like "X.Y.ZpreABCD+W" nix_soversion = meson.project_version().split('+')[0].split('pre')[0]