Skip to content

Commit dc824ec

Browse files
committed
build: Link TBB into io_exerciser if present
libstdc++ uses TBB to implement the execution library if it is available. If it's not present, we get a serial backend. Currently, we aren't getting link errors in most cases because the reference is optimized out, but when compiling with `-O0`, we hit a missing symbol. If we use more of the execution library, we'll reference TBB in ways that don't optimize out. As such, test if TBB is available. If so, link against it. See https://gcc.gnu.org/onlinedocs/libstdc++/manual/status.html#status.iso.2017 for more information. Signed-off-by: Adam Emerson <[email protected]>
1 parent 200c0af commit dc824ec

File tree

1 file changed

+14
-1
lines changed

1 file changed

+14
-1
lines changed

src/common/io_exerciser/CMakeLists.txt

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,4 +12,17 @@ target_link_libraries(object_io_exerciser
1212
librados
1313
global
1414
json_structures
15-
)
15+
)
16+
17+
# libstdc++ uses TBB to implement <execution> if it is available,
18+
# which means that if we're going to use <execution>, we need to link
19+
# against TBB if it's available.
20+
#
21+
# It happens to work by accident at present because the optimizer
22+
# optimizes out our one reference, for now, but this breaks compiling
23+
# with `-O0` and will break anyway once we try to do more.
24+
find_package(TBB QUIET)
25+
if(TBB_FOUND)
26+
message(STATUS "Linking to TBB for implementations of <execution>.")
27+
target_link_libraries(object_io_exerciser TBB::tbb)
28+
endif(TBB_FOUND)

0 commit comments

Comments
 (0)