Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support the Standard Library Modules in C++20 mode #3977

Merged
merged 1 commit into from
Aug 31, 2023

Conversation

StephanTLavavej
Copy link
Member

Fixes #3945.

  • stl/inc/ctime
    • Activate the workaround for internal OS-33790456 "static inline functions cannot be called when using modules" whenever _BUILD_STD_MODULE is defined, instead of additionally guarding it with _HAS_CXX23. This follows what <new> is already doing to detect whether we're building std.ixx:
      #ifdef _BUILD_STD_MODULE
  • stl/inc/yvals_core.h
    • Move the paper comment from the C++23 section to the C++20 section.
    • Originally, I silently ignored attempts to define _BUILD_STD_MODULE in too-old Standard modes. If they were then attempting to build std.ixx, they'd be confused by the results with no export appearing, and if they weren't building std.ixx then I was letting them get away with something very squirrely 🐿️. Now, _EXPORT_STD is simply directly controlled by _BUILD_STD_MODULE, but we have enforcement that immediately rejects attempts to do this in C++17 and older.
    • Move the feature-test macro from C++23 to C++20.
  • stl/modules/std.ixx
    • Guard the 5 C++23-only headers (so far).
    • ⚠️ Stealth merge conflict with the remaining C++23 headers: <mdspan>, <flat_map>, <flat_set>, <generator>
  • tests/std/tests/VSO_0157762_feature_test_macros/test.compile.pass.cpp
    • Update the feature-test macro test accordingly.
  • tests/std/tests/P1502R1_standard_library_header_units/env.lst
    • Originally, I was testing the Standard Library Header Units (an official C++20 feature) only in /std:c++latest mode because it took a while to build, and we didn't have a lot of C++23 content yet. Now we should be more disciplined and actually test it in all possible Standard modes like everything else. Although Header Units emit macros, this test machinery is shared with the Named Modules test, so I'm having the test detect the Standard mode with a dedicated TEST_STANDARD macro (following a different convention than the product code, to avoid confusion).
  • tests/std/tests/P2465R3_standard_library_modules/env.lst
    • Add C++20 coverage in an identical manner.
  • tests/std/include/test_header_units_and_modules.hpp
    • Update the shared test code to guard the C++23-only headers.
  • tests/std/tests/P1502R1_standard_library_header_units/test.cpp
    • Also guard the imports of C++23-only headers.

@StephanTLavavej StephanTLavavej added the modules C++23 modules, C++20 header units label Aug 18, 2023
@StephanTLavavej StephanTLavavej requested a review from a team as a code owner August 18, 2023 03:12
@CaseyCarter CaseyCarter self-assigned this Aug 29, 2023
@CaseyCarter
Copy link
Member

I'm mirroring this to the MSVC-internal repo - please notify me if any further changes are pushed.

@CaseyCarter CaseyCarter merged commit ab60075 into microsoft:main Aug 31, 2023
37 checks passed
@CaseyCarter
Copy link
Member

Thank you for bringing the slick modern magic of import std to those poor neanderthals stuck using the ancient C++20 standard.

@CaseyCarter
Copy link
Member

Really late thought: will we have ODR problems in a project that includes both C++20 TUs and C++23 TUs that import std?

@StephanTLavavej StephanTLavavej deleted the import-std-cxx20 branch September 2, 2023 09:12
@StephanTLavavej
Copy link
Member Author

Not any more than we already have with classic headers.

This was referenced Sep 6, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
modules C++23 modules, C++20 header units
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Supporting import std; in C++20
2 participants