Skip to content

build failure in tbb/task.h #7

@bartman

Description

@bartman
simple cmake
# CMake file for a C++ program
cmake_minimum_required(VERSION 4.0)
project(work_contract_test VERSION 1.0 LANGUAGES CXX)

# create compile_commands.json
set(CMAKE_CXX_STANDARD 20)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
#set(CMAKE_CXX_EXTENSIONS OFF)

# https://github.com/buildingcpp/work_contract
include(FetchContent)
FetchContent_Declare(
    work_contract
    #GIT_REPOSITORY https://github.com/buildingcpp/work_contract.git
    GIT_REPOSITORY https://github.com/bartman/work_contract.git
    GIT_TAG        origin/main
)
FetchContent_MakeAvailable(work_contract)

# include pthread
find_package(Threads REQUIRED)

# build main.cpp
add_executable(mytest main.cpp)

# use pthread and work_contract libraries
target_link_libraries(mytest PRIVATE Threads::Threads work_contract)
using the first example
#include <library/work_contract.h>
#include <iostream>
#include <thread>

int main()
{
    // Create a work contract group
    bcpp::work_contract_group group;

    // Start worker thread to process scheduled work contracts
    std::jthread worker([&group](auto stopToken)
            {
                while (not stopToken.stop_requested())
                    group.execute_next_contract();
            });

    // Create a work contract from the work contract group
    auto contract = group.create_contract([]()
            {
                std::cout << "Hello, World! from Work Contract\n";
                bcpp::this_contract::release(); // Release to async destroy this contract
            });

    // Schedule the contract
    contract.schedule();

    // Main thread waits for contract to be released
    while (contract.is_valid()) {}

    // Signal worker to stop
    worker.request_stop();
    worker.join();

    return 0;
}

cmake -S. -Bbuild reports...

-- The CXX compiler identification is Clang 21.1.7
-- The C compiler identification is Clang 21.1.7
...
-- url: https://github.com/fmtlib/fmt.git
-- tag: main
-- {fmt} version: 12.1.1
...
-- url: https://github.com/wjakob/tbb.git
-- tag: master
...
-- url: https://github.com/google/googletest.git
-- tag: main
...
-- TBB: NOT using libc++.

cmake --build build fails with...

arning: unknown warning option '-Wno-changes-meaning' [-Wunknown-warning-option]
In file included from /home/bart/proj/snippets/work_contracts/build/tbb-src/src/old/concurrent_vector_v2.cpp:20:
/home/bart/proj/snippets/work_contracts/build/tbb-src/include/tbb/task.h:590:28: error: in-class initializer for static data member is not a constant expression
  590 |     static const kind_type binding_completed = kind_type(bound+1);
      |                            ^                   ~~~~~~~~~~~~~~~~~~
/home/bart/proj/snippets/work_contracts/build/tbb-src/include/tbb/task.h:590:48: note: integer value 2 is outside the valid range of values [0, 1] for the enumeration type 'kind_type'
  590 |     static const kind_type binding_completed = kind_type(bound+1);
      |                                                ^
1 warning and 1 error generated.
make[2]: *** [tbb-build/CMakeFiles/tbb_static.dir/build.make:93: tbb-build/CMakeFiles/tbb_static.dir/src/old/concurrent_vector_v2.cpp.o] Error 1
make[1]: *** [CMakeFiles/Makefile2:1024: tbb-build/CMakeFiles/tbb_static.dir/all] Error 2
make: *** [Makefile:156: all] Error 2

I'm guessing this is a gcc vs clang thing.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions