From d9fe3ed9a6cea55f7057cbc243367ccd936734aa Mon Sep 17 00:00:00 2001 From: Bartosz Taudul Date: Sat, 8 Jun 2024 00:20:12 +0200 Subject: [PATCH] Add CMake option to not use parallel STL. --- capture/CMakeLists.txt | 1 + cmake/server.cmake | 2 +- cmake/vendor.cmake | 46 +++++++++++++++++++---------------- csvexport/CMakeLists.txt | 2 ++ import-chrome/CMakeLists.txt | 1 + import-fuchsia/CMakeLists.txt | 1 + profiler/CMakeLists.txt | 1 + update/CMakeLists.txt | 1 + 8 files changed, 33 insertions(+), 22 deletions(-) diff --git a/capture/CMakeLists.txt b/capture/CMakeLists.txt index 97cb8e0c..2417c781 100644 --- a/capture/CMakeLists.txt +++ b/capture/CMakeLists.txt @@ -2,6 +2,7 @@ cmake_minimum_required(VERSION 3.16) option(NO_ISA_EXTENSIONS "Disable ISA extensions (don't pass -march=native or -mcpu=native to the compiler)" OFF) option(NO_STATISTICS "Disable calculation of statistics" ON) +option(NO_PARALLEL_STL "Disable parallel STL" OFF) include(${CMAKE_CURRENT_LIST_DIR}/../cmake/version.cmake) diff --git a/cmake/server.cmake b/cmake/server.cmake index 403cfe00..c12a3408 100644 --- a/cmake/server.cmake +++ b/cmake/server.cmake @@ -34,6 +34,6 @@ if(NO_STATISTICS) target_compile_definitions(TracyServer PUBLIC TRACY_NO_STATISTICS) endif() -if(UNIX AND NOT APPLE AND NOT EMSCRIPTEN) +if(NOT NO_PARALLEL_STL AND UNIX AND NOT APPLE AND NOT EMSCRIPTEN) target_link_libraries(TracyServer PRIVATE TracyTbb) endif() diff --git a/cmake/vendor.cmake b/cmake/vendor.cmake index 87e112db..bd53a4db 100644 --- a/cmake/vendor.cmake +++ b/cmake/vendor.cmake @@ -208,27 +208,31 @@ if (NOT NO_FILESELECTOR AND NOT EMSCRIPTEN) endif() # TBB +if (NO_PARALLEL_STL) + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DNO_PARALLEL_SORT") + set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -DNO_PARALLEL_SORT") +else() + if (UNIX AND NOT APPLE AND NOT EMSCRIPTEN) + # Tracy does not use TBB directly, but the implementation of parallel algorithms + # in some versions of libstdc++ depends on TBB. When it does, you must + # explicitly link against -ltbb. + # + # Some distributions have pgk-config files for TBB, others don't. -if (UNIX AND NOT APPLE AND NOT EMSCRIPTEN) - # Tracy does not use TBB directly, but the implementation of parallel algorithms - # in some versions of libstdc++ depends on TBB. When it does, you must - # explicitly link against -ltbb. - # - # Some distributions have pgk-config files for TBB, others don't. - - pkg_check_modules(TBB tbb) - if (TBB_FOUND) - add_library(TracyTbb INTERFACE) - target_include_directories(TracyTbb INTERFACE ${TBB_INCLUDE_DIRS}) - target_link_libraries(TracyTbb INTERFACE ${TBB_LINK_LIBRARIES}) - else() - CPMAddPackage( - NAME tbb - GITHUB_REPOSITORY oneapi-src/oneTBB - GIT_TAG v2021.12.0-rc2 - OPTIONS "TBB_TEST OFF" - ) - add_library(TracyTbb INTERFACE) - target_link_libraries(TracyTbb INTERFACE tbb) + pkg_check_modules(TBB tbb) + if (TBB_FOUND) + add_library(TracyTbb INTERFACE) + target_include_directories(TracyTbb INTERFACE ${TBB_INCLUDE_DIRS}) + target_link_libraries(TracyTbb INTERFACE ${TBB_LINK_LIBRARIES}) + else() + CPMAddPackage( + NAME tbb + GITHUB_REPOSITORY oneapi-src/oneTBB + GIT_TAG v2021.12.0-rc2 + OPTIONS "TBB_TEST OFF" + ) + add_library(TracyTbb INTERFACE) + target_link_libraries(TracyTbb INTERFACE tbb) + endif() endif() endif() diff --git a/csvexport/CMakeLists.txt b/csvexport/CMakeLists.txt index da9294d0..a69c03a8 100644 --- a/csvexport/CMakeLists.txt +++ b/csvexport/CMakeLists.txt @@ -1,6 +1,8 @@ cmake_minimum_required(VERSION 3.16) option(NO_ISA_EXTENSIONS "Disable ISA extensions (don't pass -march=native or -mcpu=native to the compiler)" OFF) +option(NO_PARALLEL_STL "Disable parallel STL" OFF) + set(NO_STATISTICS OFF) include(${CMAKE_CURRENT_LIST_DIR}/../cmake/version.cmake) diff --git a/import-chrome/CMakeLists.txt b/import-chrome/CMakeLists.txt index 4b15f1a7..f7062feb 100644 --- a/import-chrome/CMakeLists.txt +++ b/import-chrome/CMakeLists.txt @@ -2,6 +2,7 @@ cmake_minimum_required(VERSION 3.16) option(NO_ISA_EXTENSIONS "Disable ISA extensions (don't pass -march=native or -mcpu=native to the compiler)" OFF) option(NO_STATISTICS "Disable calculation of statistics" ON) +option(NO_PARALLEL_STL "Disable parallel STL" OFF) include(${CMAKE_CURRENT_LIST_DIR}/../cmake/version.cmake) diff --git a/import-fuchsia/CMakeLists.txt b/import-fuchsia/CMakeLists.txt index 5d8cb033..16327e4b 100644 --- a/import-fuchsia/CMakeLists.txt +++ b/import-fuchsia/CMakeLists.txt @@ -2,6 +2,7 @@ cmake_minimum_required(VERSION 3.16) option(NO_ISA_EXTENSIONS "Disable ISA extensions (don't pass -march=native or -mcpu=native to the compiler)" OFF) option(NO_STATISTICS "Disable calculation of statistics" ON) +option(NO_PARALLEL_STL "Disable parallel STL" OFF) include(${CMAKE_CURRENT_LIST_DIR}/../cmake/version.cmake) diff --git a/profiler/CMakeLists.txt b/profiler/CMakeLists.txt index 07d86b48..928aec3f 100644 --- a/profiler/CMakeLists.txt +++ b/profiler/CMakeLists.txt @@ -6,6 +6,7 @@ option(LEGACY "Instead of Wayland, use the legacy X11 backend on Linux" OFF) option(NO_ISA_EXTENSIONS "Disable ISA extensions (don't pass -march=native or -mcpu=native to the compiler)" OFF) option(NO_STATISTICS "Disable calculation of statistics" OFF) option(SELF_PROFILE "Enable self-profiling" OFF) +option(NO_PARALLEL_STL "Disable parallel STL" OFF) include(${CMAKE_CURRENT_LIST_DIR}/../cmake/version.cmake) diff --git a/update/CMakeLists.txt b/update/CMakeLists.txt index 06a70845..6c347e39 100644 --- a/update/CMakeLists.txt +++ b/update/CMakeLists.txt @@ -2,6 +2,7 @@ cmake_minimum_required(VERSION 3.16) option(NO_ISA_EXTENSIONS "Disable ISA extensions (don't pass -march=native or -mcpu=native to the compiler)" OFF) option(NO_STATISTICS "Disable calculation of statistics" ON) +option(NO_PARALLEL_STL "Disable parallel STL" OFF) include(${CMAKE_CURRENT_LIST_DIR}/../cmake/version.cmake)