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

MSVC named module enablement #604

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

MathiasMagnus
Copy link

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;

int main()
{
	using namespace boost::ut;
	"test-basic"_test = [] {
		int i = 42;
		expect(42_i == i);
	};

	return 0;
}

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 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.

1 participant