tracy icon indicating copy to clipboard operation
tracy copied to clipboard

Profiler (server) linker error (tbb)

Open Langwedocjusz opened this issue 1 year ago • 4 comments

When compiling the profiler on manjaro linux, using gcc I get linker error "undefined reference to tbb::detail::r1::execution_slot". It can be fixed by linking against tbb in the profiler cmake:

find_package(TBB REQUIRED COMPONENTS tbb)
target_link_libraries(${PROJECT_NAME} PRIVATE tbb)

I could open a pull request which does this, but I'm not certain if this should also be applied to other platforms.

Langwedocjusz avatar Dec 25 '24 18:12 Langwedocjusz

tbb is no longer used.

wolfpld avatar Dec 25 '24 19:12 wolfpld

Huh, so in that case should I assume the linker error stems from some environment misconfiguration on my part?

Langwedocjusz avatar Dec 26 '24 19:12 Langwedocjusz

For starters, please see #810 for more discussion on this topic.

To be precise, tbb was never a dependency of Tracy. It's just an artifact of how the <execution> header (and the parallel STL) is implemented on the gcc / stdc++ side. And it's implemented in such a way that if you use the header, you have to link in the tbb library, because gcc is too inept to be able to do this on its own. Now, given that this is just an internal implementation detail of gcc, it can change at any moment, and the applications should just, somehow, in some way, be able to predict what will be needed in future, and handle it properly. Every time it changes. There are some parallels with how -lpthread is sometimes maybe needed when you decide to use a different part of the standard library.

As you probably have guessed, I'm not particularly fond of the situation, so I just replaced all use of the parallel STL with a library that was explicitly designed to avoid the tbb dependency (1c1faeff2d51f).

In short, I don't depend on tbb, and I don't really want to know what fresh bullshit gcc has invented about it.

I run Arch, so that's basically the same as Manjaro. I checked the gcc build and I can see the errors you reference:

/usr/bin/ld: CMakeFiles/tracy-profiler.dir/src/main.cpp.o: in function `tbb::detail::d1::execution_slot(tbb::detail::d1::execution_data const&)':
/usr/include/oneapi/tbb/detail/_task.h:238:(.text._ZN3tbb6detail2d114execution_slotERKNS1_14execution_dataE[_ZN3tbb6detail2d114execution_slotERKNS1_14execution_dataE]+0x14): undefined reference to `tbb::detail::r1::execution_slot(tbb::detail::d1::execution_data const*)'
/usr/bin/ld: CMakeFiles/tracy-profiler.dir/src/main.cpp.o: in function `tbb::detail::d1::current_thread_index()':
/usr/include/oneapi/tbb/task_arena.h:451:(.text._ZN3tbb6detail2d120current_thread_indexEv[_ZN3tbb6detail2d120current_thread_indexEv]+0xe): undefined reference to `tbb::detail::r1::execution_slot(tbb::detail::d1::execution_data const*)'
collect2: error: ld returned 1 exit status

...when I have onetbb installed. Which I have to have installed, as it's a dependency of some packages. When I remove it, everything builds correctly. Sigh.

I have clang as my default compiler, and I recommend doing the same. It works as intended.

If someone wants to get gcc working back again, the above should be a good starting point.

wolfpld avatar Dec 26 '24 20:12 wolfpld

I took a look at the disassembly of the main.cpp.o object, and there are some tbb functions there which depend on the tbb library. No code sections from the actual source file reference these tbb functions though.

gcc is broken. Feel free to submit an issue in their bugtracker. I don't care, I use a different compiler.

wolfpld avatar Feb 12 '25 11:02 wolfpld