FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

Fix C++ module builds and async imports on MSVC by lilong555 · Pull Request #812 · taskflow/taskflow · GitHub

Fix C++ module builds and async imports on MSVC - #812

Open
lilong555 wants to merge 2 commits into
taskflow:masterfrom
lilong555:codex/fix-780
Open

lilong555 wants to merge 2 commits into
taskflow:masterfrom
lilong555:codex/fix-780

Conversation

lilong555 commented Sep 9, 2026 •
edited
Loading

Copy link
Copy Markdown

Related to #780.

This PR restores C++ module builds and asynchronous task imports on the current master branch. On MSVC 19.44, importing tf and calling Executor::async produces C3779 because the core partition exports Executor without including its async definitions. The module interfaces also reference symbols that have since been removed or renamed, preventing the module library from building.

The core partition includes the public Taskflow entry point, exports Subflow, and uses the current GraphLike name. Obsolete exports are removed. The module-node constructors are defined in class so MSVC 19.51 can construct the node variant through imported composed_of templates; out-of-class definitions result in C2661 on that compiler. The profiler's two header helpers use external inline linkage so their definitions remain available when the profiler is used through a module; MSVC otherwise reports C2129.

The module target inherits Taskflow's include paths, thread linkage, compile options, and feature definitions. Its installed sources go under include/taskflow/modules, and exported module include paths no longer retain the source checkout. CMake 3.28 is required only when module support is enabled.

A consumer module regression test exercises captured async return values, runtime and dependent async tasks, subflows, hashing, and profiler output through a further import. A Windows Debug/Release CI job builds and runs the module tests.

Validation

Locally tested on Windows x64 with Visual Studio 2022, MSVC 19.44.35225, and CMake 3.31.6:

  • Debug: all 17 C++ module tests passed.
  • Release: all 264 selected tests passed, covering modules, basics, async tasks, dependent async tasks, subflows, and runtimes. This is not the full test suite.
  • A separate C++23 consumer using import std and /std:c++latest compiled and ran successfully.
  • An installed-package consumer using find_package(Taskflow) compiled and ran with MSVC and Ninja, without the source checkout in its exported module include paths.

The installed consumer requires Ninja with this CMake version: its Visual Studio generator does not support the necessary BMI-only compilation. The profiler consumer test includes <chrono>; removing it exposes a separate MSVC chrono-operator import diagnostic. CUDA and other compiler platforms have not been validated locally.

The missing <algorithm> include mentioned in #780 is already present upstream. VS 2026 / MSVC 19.51.36256 passes all 17 module tests in both Debug and Release in the fork Windows workflow. This verifies the C2661 module-composition failure; the original report's internal compiler crash has not been independently reproduced, so this PR does not claim to resolve every symptom in the issue.

Thank you for maintaining Taskflow. I would appreciate your feedback on this approach, particularly whether you would prefer the packaging changes in a separate PR.

Copilot AI lite review requested due to automatic review settings September 9, 2026 14:03

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

🟡 Changes recommended

The new module test introduces an unused structured-binding element that is likely to fail MSVC builds under /WX (warnings-as-errors) as configured by the project’s default settings.

Once you've addressed the issues Copilot identified, you can request another Copilot review.

Pull request overview

This PR restores Taskflow’s C++ module build on MSVC by correcting module partition exports/includes, updating the module CMake target to inherit the main library’s build settings, and adding regression coverage plus Windows CI to prevent module import/Executor::async failures (e.g., MSVC C3779).

Changes:

  • Fix module interface/partition surface (core/utility) by updating exported symbols and ensuring the public Taskflow entry point is included.
  • Adjust TFProf observer header helpers to be usable when consumed via modules (MSVC linkage-related diagnostics).
  • Add a transitive-import consumer module test and a Windows Debug/Release CI job that builds and runs the module tests.
File summaries
File Description
unittests/modules/test_tf.cppm New consumer module exercising async returns, dependent async, subflows, hashing, and profiler output.
unittests/modules/test_cxx_modules.cpp Adds a transitive-import doctest case that imports test_tf and validates module behavior across worker counts.
unittests/modules/CMakeLists.txt Builds the new test module interface via FILE_SET CXX_MODULES.
taskflow/observer/tfprof.hpp Changes profiler helper functions’ linkage to remain available when used through a module.
modules/tf.utility.cppm Removes exports for obsolete utility symbols (all_same, all_same_v).
modules/tf.core.cppm Includes the public Taskflow header and updates exported symbols (Subflow, GraphLike).
modules/CMakeLists.txt Requires CMake 3.28 for module builds, links module target to Taskflow::Taskflow, and installs module sources under include/taskflow/modules.
.github/workflows/windows.yml Adds a Windows CI job to build/run module tests in Debug/Release.
Review details
  • Files reviewed: 8/8 changed files
  • Comments generated: 3
  • Review effort level: Lite

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment thread unittests/modules/test_tf.cppm Outdated
Comment on lines +24 to +25
auto [last, done] = executor.dependent_async([&count] { ++count; }, first);
done.get();
Comment on lines 325 to 329
// helper: emit a horizontal rule of width w
static inline void _tf_rule(std::ostream& os, size_t w, char c = '-') {
inline void _tf_rule(std::ostream& os, size_t w, char c = '-') {
for(size_t i = 0; i < w; ++i) os << c;
os << '\n';
}
Comment on lines 331 to 340
// Helper: _tf_time_scale
// Given a duration in microseconds, returns a human-readable scaled value
// and sets unit to the appropriate suffix string.
// Thresholds:
// < 10,000 us -> us (microseconds)
// < 10,000 ms -> ms (milliseconds)
// < 10,000 s -> s (seconds)
// otherwise -> min (minutes)
static inline double _tf_time_scale(size_t us, const char*& unit) {
inline double _tf_time_scale(size_t us, const char*& unit) {
if(us < 10000ULL) {

This branch has not been deployed

No deployments
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants


Back | FazBrowse Home | New Git URL