modern-cmake / cppfront

CMake wrapper around the cppfront repository
BSD 3-Clause "New" or "Revised" License
75 stars 21 forks source link

CI complain about missing standard module interface for Windows build #68

Closed filipsajdak closed 5 months ago

filipsajdak commented 1 year ago

Some tests are failing due to the following error:

cpp2util.h(48): fatal error C1011: cannot locate standard module interface. Did you install the library part of the C++ modules feature in VS setup?
alexreinking commented 1 year ago

Thanks for opening this issue... I have not had a chance to look at this.

alexreinking commented 1 year ago

@JohelEGP -- do you have any idea why this is happening? It used to work, then became intermittent, and now is consistently failing.

JohelEGP commented 1 year ago

I suppose it's the pure2 tests that are failing because they're trying to use C++ modules. I can't find platform-specific flags in the CMake sources, so perhaps it's missing one of the advertised ones at https://github.com/hsutter/cppfront#how-do-i-build-cppfront.

alexreinking commented 1 year ago

so perhaps it's missing one of the advertised ones

No, unfortunately it's not so simple. Here's one of the command lines from the tests:

C:\PROGRA~1\MICROS~2\2022\ENTERP~1\VC\Tools\MSVC\1434~1.319\bin\HostX64\x64\cl.exe  /nologo /TP  -external:ID:\a\cppfront\cppfront\_local\include -external:W0 /DWIN32 /D_WINDOWS /EHsc /O2 /Ob2 /DNDEBUG -std:c++20 -MD /experimental:module /showIncludes /FoCMakeFiles\test-case.dir\_cppfront\pure2-bounds-safety-span.cpp.obj /FdCMakeFiles\test-case.dir\ /FS -c D:\a\cppfront\cppfront\build\regression-tests\pure2-bounds-safety-span\build\_cppfront\pure2-bounds-safety-span.cpp

I can clearly see both -std:c++20 and /EHsc in there.

JohelEGP commented 1 year ago

Then it might be -experimental:module from https://github.com/hsutter/cppfront/blob/main/regression-tests/test-results/msvc-2022/run-tests-msvc-2022.bat.

alexreinking commented 1 year ago

Ugh, I wish I knew why that wasn't always needed. We can try adding that.

JohelEGP commented 1 year ago

It seems like it's already added at https://github.com/modern-cmake/cppfront/blob/main/regression-tests/cmake/CMakeLists.txt.in#L14.

alexreinking commented 1 year ago

It seems like it's already added

Oh, and sure enough, it's in the command line above... maybe removing it would help, if the MSVC version is new enough?

JohelEGP commented 1 year ago

Another difference is that https://github.com/hsutter/cppfront/blob/main/regression-tests/test-results/msvc-2022/run-tests-msvc-2022.bat uses -std:c++latest.

alexreinking commented 1 year ago

We could try this

target_compile_features(
    cppfront_cpp2util
    INTERFACE
    $<IF:$<CXX_COMPILER_ID:MSVC>,cxx_std_23,cxx_std_20>
)

instead of this: https://github.com/modern-cmake/cppfront/blob/43340d35bbc34d8cb788e627dee2638fa3dcf218/CMakeLists.txt#L57

That should give -std:c++latest for MSVC and will turn into -std:c++23 in future versions.

JohelEGP commented 1 year ago

I don't think that's it. It still fails: https://compiler-explorer.com/z/aGaj5z58q.

JohelEGP commented 1 year ago

Maybe it's just as the error message says, and there's something that needs to be installed in the environment.

JohelEGP commented 1 year ago

See https://learn.microsoft.com/en-us/cpp/error-messages/compiler-errors-1/fatal-error-c1011?view=msvc-170.

alexreinking commented 1 year ago

See https://learn.microsoft.com/en-us/cpp/error-messages/compiler-errors-1/fatal-error-c1011?view=msvc-170.

Yeah, that's not going to work on GitHub Actions, though.

JohelEGP commented 1 year ago

Maybe you can downgrade the version of MSVC to one that works: https://github.com/ilammy/msvc-dev-cmd#inputs.

alexreinking commented 1 year ago

This is frustrating... I cannot reproduce the error locally (with VS2022, v14.34 toolset, same as GHA). Everything "just works" here. The documentation suggests that the C++ modules are indeed installed (component Microsoft.VisualStudio.Component.VC.Modules.x86.x64)

alexreinking commented 1 year ago

I've put in the time I have to look at this during the week. I'll try again on the weekend.

alexreinking commented 5 months ago

This is no longer the issue with MSVC. Now we have issues in the build/check tests