Skip to content

Add RFC about C++20 modules support#2043

Open
isaevil wants to merge 9 commits intomasterfrom
rfc/isaevil/cxx20_modules
Open

Add RFC about C++20 modules support#2043
isaevil wants to merge 9 commits intomasterfrom
rfc/isaevil/cxx20_modules

Conversation

@isaevil
Copy link
Copy Markdown
Contributor

@isaevil isaevil commented Apr 2, 2026

Description

Add a comprehensive description of proposed changes

Fixes # - issue number(s) if exists

Type of change

Choose one or multiple, leave empty if none of the other choices apply

Add a respective label(s) to PR if you have permissions

  • bug fix - change that fixes an issue
  • new feature - change that adds functionality
  • tests - change in tests
  • infrastructure - change in infrastructure and CI
  • documentation - documentation update

Tests

  • added - required for new features and some bug fixes
  • not needed

Documentation

  • updated in # - add PR number
  • needs to be updated
  • not needed

Breaks backward compatibility

  • Yes
  • No
  • Unknown

Notify the following users

List users with @ to send notifications

Other information

Signed-off-by: Isaev, Ilya <ilya.isaev@intel.com>
Comment thread rfcs/proposed/cxx20_modules/README.md Outdated
Comment thread rfcs/proposed/cxx20_modules/README.md Outdated
Comment thread rfcs/proposed/cxx20_modules/README.md Outdated
Comment thread rfcs/proposed/cxx20_modules/README.md Outdated
Comment thread rfcs/proposed/cxx20_modules/README.md Outdated
Comment thread rfcs/proposed/cxx20_modules/README.md Outdated
Comment thread rfcs/proposed/cxx20_modules/README.md Outdated
isaevil and others added 2 commits April 13, 2026 10:05
Co-authored-by: Mike Voss <michaelj.voss@intel.com>
Signed-off-by: Isaev, Ilya <ilya.isaev@intel.com>
@isaevil isaevil requested a review from vossmjp April 15, 2026 11:21
Comment thread rfcs/proposed/cxx20_modules/README.md
Comment thread rfcs/proposed/cxx20_modules/README.md Outdated
isaevil added 2 commits April 15, 2026 17:50
Signed-off-by: Isaev, Ilya <ilya.isaev@intel.com>
…and 7

Signed-off-by: Isaev, Ilya <ilya.isaev@intel.com>
@isaevil isaevil requested a review from kboyarinov April 16, 2026 08:53
after `import tbb;`. Some options:
- Replace them with inline variables where possible or provide exported functions.
- Require the consumer to `#include <tbb/version.h>` alongside the import.

Copy link
Copy Markdown

@mropert mropert Apr 16, 2026

Choose a reason for hiding this comment

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

I would add a question about plans to handle transitive inclusion of the STL.
Since modules tend to break down when some project use the STL through #include directives and other through import std this should be considered.
I would recommend either toggling all #include into import when using TBB as a module, or at least provide a define to toggle between the two options.

Copy link
Copy Markdown
Contributor Author

@isaevil isaevil May 7, 2026

Choose a reason for hiding this comment

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

Do you mean that, since declarations in std module are attached to "unspecified" module, ABI compatibility may be broken when std module and standard headers are used in the same application?

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Most (all?) compilers will support something like this:

#include <vector>
import std;

But not this:

import std;
#include <vector>

This is also true if the includes/imports happens transitively by import/including files that themselves do import/includes.
So if people do import tbb, then need to be able to control how transitive inclusion of the STL by TBB will be done. The most common I have seen is that when in module mode all #include should be turned into import directives, but if you're worried this is too drastic you can provide a define that allow people to pick a strategy.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

It seems more like a compiler implementation limitation, not limitation of TBB named module itself, so I wouldn't say it is an open question for supporting modules in TBB. But we'll keep that issue in mind for sure, thanks.

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

I'm pretty sure it's a limitation of how modules work in practice (and maybe even on spec, that part isn't entirely clear).

Either way, it's defintely a question you'll have to solve because else you'll get constant complaints from module users.

isaevil added 3 commits May 7, 2026 11:42
Signed-off-by: Isaev, Ilya <ilya.isaev@intel.com>
Signed-off-by: Isaev, Ilya <ilya.isaev@intel.com>
vossmjp
vossmjp previously approved these changes May 7, 2026
Copy link
Copy Markdown
Contributor

@vossmjp vossmjp left a comment

Choose a reason for hiding this comment

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

LGTM

akukanov
akukanov previously approved these changes May 8, 2026
Copy link
Copy Markdown
Contributor

@akukanov akukanov left a comment

Choose a reason for hiding this comment

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

The RFC looks good for initial acceptance and implementation. Open questions can be additionally clarified though.

Comment thread rfcs/proposed/cxx20_modules/README.md Outdated
Comment on lines +207 to +210
2. How should module-based consumption be tested? Options include a dedicated test
that uses `import tbb;` instead of `#include`, or running the existing test suite
with module imports. Should whitebox tests be covered in the latter scenario?
* Currently extending `test_tbb_header` is suggested to check public API availability via modules.
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Are there usage scenarios that are not covered by the suggested approach with test_tbb_header?
If the only practical difference is for using import instead of #include, then the API availability checks seem sufficient.

Also, is there any practical way to check that only the desired public APIs are exported, and nothing else?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Are there usage scenarios that are not covered by the suggested approach with test_tbb_header?
If the only practical difference is for using import instead of #include, then the API availability checks seem sufficient.

I would say perhaps ABI compatibility check (combining TUs compiled with modules and headers) is not implemented currently, but my understanding is that can be done the similar way as with test_tbb_header_secondary.cpp.

Also, is there any practical way to check that only the desired public APIs are exported, and nothing else?

For now I can only think of marking somehow in headers what we believe is a public API (we usually have inline-namespace at the bottom of header with using-declarations) and auto-generating a module from that and comparing it with tbb.cppm.

Copy link
Copy Markdown
Contributor

@akukanov akukanov May 8, 2026

Choose a reason for hiding this comment

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

I would say perhaps ABI compatibility check (combining TUs compiled with modules and headers) is not implemented currently, but my understanding is that can be done the similar way as with test_tbb_header_secondary.cpp.

Should we then add this to the testing plan and close the question, or are there more nuances?

Running the whole test suite with module imports instead of includes would check if the functionality is not just accessible but also properly usable. However, based on what we know of the way modules work and the internals of our implementation, would that add sufficient value? I feel like it would not.

Comment thread rfcs/proposed/cxx20_modules/README.md Outdated
Comment thread rfcs/proposed/cxx20_modules/README.md
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants