fair-acc / gnuradio4

Prototype implementations for a more compile-time efficient flowgraph API
GNU Lesser General Public License v3.0
22 stars 8 forks source link

Missing link to TBB with libstdc++ on Fedora #361

Closed dennisklein closed 2 weeks ago

dennisklein commented 3 weeks ago

On Fedora 40 with GCC 14.1 and libstdc++ I get a couple of /usr/bin/ld: algorithm/test/CMakeFiles/qa_FilterTool.dir/qa_FilterTool.cpp.o: in function `void tbb::detail::(...). The following change made it compile for me with my system compiler:

--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -143,6 +143,8 @@ endif ()
 # Mainly for FMT
 set(CMAKE_POSITION_INDEPENDENT_CODE TRUE)

+find_package(TBB REQUIRED)
+
 add_library(gnuradio-options INTERFACE)
 include(cmake/CompilerWarnings.cmake)
 set_project_warnings(gnuradio-options)
--- a/algorithm/CMakeLists.txt
+++ b/algorithm/CMakeLists.txt
@@ -1,6 +1,6 @@
 add_library(gnuradio-algorithm INTERFACE)
 target_include_directories(gnuradio-algorithm INTERFACE $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include/> $<INSTALL_INTERFACE:include/>)
-target_link_libraries(gnuradio-algorithm INTERFACE gnuradio-options gnuradio-meta vir fftw fmt magic_enum)
+target_link_libraries(gnuradio-algorithm INTERFACE gnuradio-options gnuradio-meta vir fftw fmt magic_enum TBB::tbb)

 if (ENABLE_TESTING)
     add_subdirectory(test)

However, I am not too familiar with your build system, so someone else should review this and revise a proper fix. See also:

-ltbb - Linking to tbb (Thread Building Blocks) is required for use of the Parallel Standard Algorithms and execution policies in <execution>.

https://gcc.gnu.org/onlinedocs/libstdc++/manual/using.html#manual.intro.using.flags

wirew0rm commented 3 weeks ago

Thanks for sharing your findings :+1:

Since TBB is a rather heavy dependencies this should at least be optional, we'll have to look into how the decision to use it was made, I assume there will be some flags that will disable using the system TBB even if it is installed so that we can introduce an option that either disables TBB or adds the linker flag.

wirew0rm commented 2 weeks ago

gcc is indeed just checking if the tbb/tbb.h header is available. Defining _GLIBCXX_USE_TBB_PAR_BACKEND by default and having option to alternatively require TBB and add the linker flag should do the trick. https://github.com/gcc-mirror/gcc/blob/releases/gcc-14.1.0/libstdc%2B%2B-v3/include/bits/c%2B%2Bconfig#L874-L882