Skip to content

Migrate ipr/impl and ipr/utility-impl to C++20 module cxx.ipr.impl#328

Merged
GabrielDosReis merged 1 commit into
GabrielDosReis:mainfrom
gdr-at-ms:modularize-impl
May 19, 2026
Merged

Migrate ipr/impl and ipr/utility-impl to C++20 module cxx.ipr.impl#328
GabrielDosReis merged 1 commit into
GabrielDosReis:mainfrom
gdr-at-ms:modularize-impl

Conversation

@gdr-at-ms

Copy link
Copy Markdown
Contributor

Merge the <ipr/impl> and <ipr/utility-impl> headers into a single module interface unit src/cxx-ipr-impl.ixx exporting module cxx.ipr.impl. The module implementation unit src/impl.cxx is adjusted accordingly.

Changes

  • Merge utility types (rb_tree, string pool, etc.) into the module interface
  • Remove src/utility.cxx (absorbed into impl.cxx)
  • Export only types that appear in the public API; ~75 internal infrastructure types (base templates, containers, comparison functions) are left unexported but reachable
  • Add GCC BUG workaround comments for cross-module destructor access
  • Update all test files to use import cxx.ipr.impl

Compiler status

  • MSVC 19.50: builds and passes all tests
  • Clang 21: builds and passes all tests
  • GCC 15/16: fails due to known module bugs:
    • Cross-module protected destructor not seen as accessible
    • Internal compiler error in is_really_empty_class from emit_mem_initializers

Assisted by: Claude Opus 4.6

Comment thread src/impl.cxx
}

impl::Scope* global_scope = unit.global_scope();
string::arena::~arena()
Comment thread src/impl.cxx
// If we need to allocate storage more than what can possibly fit
// in a fresh pool object, just allocate that string on its own.
else if (n > bufsz) {
pool* new_pool = static_cast<pool*>
Comment thread src/impl.cxx
// remain sufficient room in the buffer. This is likely so if
// the buffer is allocated sufficiently large to start with.
else {
pool* new_pool = static_cast<pool*>(operator new(poolsz));
Comment thread src/impl.cxx
{
string* header = allocate(n);
header->length = n;
std::copy(s, s + n, &header->data[0]);
Merge the <ipr/impl> and <ipr/utility-impl> headers into a single
module interface unit src/cxx-ipr-impl.ixx exporting module cxx.ipr.impl.
The module implementation unit src/impl.cxx is adjusted accordingly.

- Merge utility types (rb_tree, string pool, etc.) into the module interface
- Remove src/utility.cxx (absorbed into impl.cxx)
- Export only types that appear in the public API; ~75 internal
  infrastructure types (base templates, containers, comparison functions)
  are left unexported but reachable
- Add GCC BUG workaround comments for cross-module destructor access
- Update all test files to use 'import cxx.ipr.impl'

Builds and passes tests with MSVC 19.50 and Clang 21.
GCC 15/16 fail due to known module bugs (cross-module protected
destructor access, internal compiler error in is_really_empty_class).
@GabrielDosReis GabrielDosReis merged commit 9e58236 into GabrielDosReis:main May 19, 2026
10 of 12 checks passed
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.

3 participants