Skip to content

MSVC named module enablement - #604

Draft
MathiasMagnus wants to merge 1 commit into
boost-ext:masterfrom
MathiasMagnus:develop
Draft

MSVC named module enablement#604
MathiasMagnus wants to merge 1 commit into
boost-ext:masterfrom
MathiasMagnus:develop

Conversation

@MathiasMagnus

Copy link
Copy Markdown

Problem:
Consuming ut as a named module using MSVC has compiler errors.

Solution:

  • Don't include STL headers. (It results in ODR violation when consuming std as module.)
    • MS-STL is the only implementation to date with proper import std capable export definitions implemented as a named module and not as a header unit.
  • Skip the definition of a symbol with internal linkage.

The proposed changes work with a downstream project that builds both the standard binary interface module (from std.ixx) and ut (by renaming ut.hpp to ut.ixx).

import boost.ut;
intmain()
{
usingnamespaceboost::ut;"test-basic"_test = [] {
int i = 42;
expect(42_i == i);
};
return0;
}

Builds as:

C:\Kellekek\Kitware\CMake\3.28.0\bin\cmake.exe --build C:/Users/mate/Source/Repos/OpenCL-Module/.vscode/build/msbuild-msvc-v143 --config Debug --target test-basic -- /nologo /verbosity:minimal
1>Checking Build System
Building Custom Rule C:/Users/mate/Source/Repos/OpenCL-Module/CMakeLists.txt
Scanning sources for module dependencies...
std.ixx
Compiling...
std.ixx
StandardLibraryModule.vcxproj -> C:\Users\mate\Source\Repos\OpenCL-Module\.vscode\build\msbuild-msvc-v143\StandardLibraryModule.dir\Debug\StandardLibraryModule.lib
1>Copying ut.hpp as ut.ixx
Building Custom Rule C:/Users/mate/Source/Repos/OpenCL-Module/tests/CMakeLists.txt
Scanning sources for module dependencies...
ut.ixx
Compiling...
ut.ixx
BoostUtModule.vcxproj -> C:\Users\mate\Source\Repos\OpenCL-Module\.vscode\build\msbuild-msvc-v143\tests\BoostUtModule.dir\Debug\BoostUtModule.lib
Building Custom Rule C:/Users/mate/Source/Repos/OpenCL-Module/tests/CMakeLists.txt
test-basic.cpp
test-basic.vcxproj -> C:\Users\mate\Source\Repos\OpenCL-Module\.vscode\build\msbuild-msvc-v143\tests\Debug\test-basic.exe

The proposed changes don't build ut's own test infra, because none of the tests support import std. How should I go about adding support for that?

Issue: #558

Reviewers:
@kris-jusiak

Sign up for freeto 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.

1 participant

@MathiasMagnus