-
-
Notifications
You must be signed in to change notification settings - Fork 817
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
Improve MSVC and clang modules compilation #2664
Conversation
Now tests/dependence work for clang, but tests/user_headerunits and tests/cpp_with_modules are broken for msvc. |
yeah i'm working on it |
i'm trying to have only needed flags when building a .cpp, is there a way to add cxxflags to a specific cpp file from build_modules_for_* ? |
no way now, we can only specify them when adding files. |
I added it on target("test2")
set_kind("binary")
add_files("src/*.cpp", {cxxflags = "-DTEST"})
before_build(function (target)
target:fileconfig_add("src/main.cpp", {cxxflags = {"-DTEST2", "-DTEST3"}, defines = "TEST4"})
end)
|
nice thanks |
i need to do the same for clang and gcc now |
gcc uses mapper files, and I don't think it would be a problem even if it's added globally to cxxflags. it works fine for gcc now. |
I tested new patches for msvc, it works fine for more tests, but user_headerunits will still be broken for msvc. |
e007c60
to
c6b465a
Compare
Does it work now? I try it, but it's still broken for user_headerunits/msvc. Z:\personal\xmake\tests\projects\c++\modules\user_headerunit>xmake clean -a && x
make f -c && xmake -r
checking for platform ... windows
checking for architecture ... x64
checking for Microsoft Visual Studio (x64) version ... 2022
checking for Microsoft C/C++ Compiler (x64) version ... 19.32.31332
[ 0%]: generating.cxx.module.deps src\main.cpp
[ 0%]: generating.cxx.module.deps src\hello.mpp
[ 15%]: generating.cxx.headerunit.bmi header.hpp
[ 53%]: generating.cxx.module.bmi hello
[ 76%]: ccache compiling.release src\main.cpp
error: main.cpp
src\main.cpp(2): error C7612: could not find header unit for 'Z:\personal\xmake\
tests\projects\c++\modules\user_headerunit\src\header.hpp'
src\main.cpp(5): error C2039: 'FOO': is not a member of 'hello'
Z:\personal\xmake\tests\projects\c++\modules\user_headerunit\src\hello.mpp(6): n
ote: see declaration of 'hello'
src\main.cpp(5): error C2065: 'FOO': undeclared identifier
> in src\main.cpp |
Weird, all the tests work on my machine. https://asciinema.org/a/0At3VCdO9rQxjcdqaqcMlfFVM Can you show me the command line of src\main.cpp ? |
checking for flags (cl_scan_dependencies) ... ok
[ 0%]: generating.cxx.module.deps src\main.cpp
checking for flags (-std:c++20) ... ok
checking for flags (-experimental:module) ... ok
C:\Program Files\Microsoft Visual Studio\2022\Community\VC\Tools\MSVC\14.32.31326\bin\HostX64\x64\cl.exe /EHsc -nologo -std:c++20 -experimental:module -TP -scanDependencies build\.gens\user_headerunit\windows\x64\release\rules\modules\cache\src\main.cpp.json src\main.cpp -Fobuild\.objs\user_headerunit\windows\x64\release\src\main.cpp.obj
[ 0%]: generating.cxx.module.deps src\hello.mpp
C:\Program Files\Microsoft Visual Studio\2022\Community\VC\Tools\MSVC\14.32.31326\bin\HostX64\x64\cl.exe /EHsc -nologo -std:c++20 -experimental:module -TP -scanDependencies build\.gens\user_headerunit\windows\x64\release\rules\modules\cache\src\hello.mpp.json src\hello.mpp -Fobuild\.objs\user_headerunit\windows\x64\release\src\hello.mpp.obj
checking for flags (cl_ifc_output) ... ok
checking for flags (cl_interface) ... ok
checking for flags (cl_reference) ... ok
checking for flags (cl_export_header) ... ok
checking for flags (cl_header_unit_quote) ... ok
checking for flags (cl_header_unit_angle) ... ok
checking for flags (cl_header_name_quote) ... ok
checking for flags (cl_header_name_angle) ... ok
[ 15%]: generating.cxx.headerunit.bmi header.hpp
C:\Program Files\Microsoft Visual Studio\2022\Community\VC\Tools\MSVC\14.32.31326\bin\HostX64\x64\cl.exe /EHsc -nologo -std:c++20 -experimental:module -TP -exportHeader -c -headerName:quote Z:\personal\xmake\tests\projects\c++\modules\user_headerunit\src\header.hpp -ifcOutput build\.gens\user_headerunit\windows\x64\release\rules\modules\cache\src /Fobuild\.objs\user_headerunit\windows\x64\release\src\header.hpp.obj
header.hpp
[ 53%]: generating.cxx.module.bmi hello
C:\Program Files\Microsoft Visual Studio\2022\Community\VC\Tools\MSVC\14.32.31326\bin\HostX64\x64\cl.exe /EHsc -nologo -std:c++20 -experimental:module -TP -c -Fobuild\.objs\user_headerunit\windows\x64\release\src\hello.mpp.obj -interface -ifcOutput build\.gens\user_headerunit\windows\x64\release\rules\modules\cache\hello.ifc src\hello.mpp
hello.mpp
[ 76%]: ccache compiling.release src\main.cpp
"C:\\Program Files\\Microsoft Visual Studio\\2022\\Community\\VC\\Tools\\MSVC\\14.32.31326\\bin\\HostX64\\x64\\cl.exe" -c /EHsc -nologo -std:c++20 -experimental:module -headerUnit:quote header.hpp=build\.gens\user_headerunit\windows\x64\release\rules\modules\cache\src\header.hpp.ifc -reference hello=build\.gens\user_headerunit\windows\x64\release\rules\modules\cache\hello.ifc -Fobuild\.objs\user_headerunit\windows\x64\release\src\main.cpp.obj src\main.cpp
checking for flags (cl_sourceDependencies) ... ok
error: main.cpp
src\main.cpp(2): error C7612: could not find header unit for 'Z:\personal\xmake\tests\projects\c++\modules\user_headerunit\src\header.hpp'
src\main.cpp(5): error C2039: 'FOO': is not a member of 'hello'
Z:\personal\xmake\tests\projects\c++\modules\user_headerunit\src\hello.mpp(6): note: see declaration of 'hello'
src\main.cpp(5): error C2065: 'FOO': undeclared identifier
|
Can you remove |
And tests/class example is also broken on ci (msvc), but it works for me. wired. >> testing tests\projects\c++\modules\class ...
>> running test_main ...
checking for platform ... windows
checking for architecture ... x64
checking for Microsoft Visual Studio (x64) version ... 2019
checking for Microsoft C/C++ Compiler (x64) version ... 19.29.30146
[ 0%]: generating.cxx.module.deps src\hello_impl.cpp
[ 0%]: generating.cxx.module.deps src\main.cpp
[ 0%]: generating.cxx.module.deps src\hello.mpp
[ 41%]: generating.cxx.module.bmi hello
[ 66%]: ccache compiling.release src\hello_impl.cpp
[ 66%]: ccache compiling.release src\main.cpp
error: hello_impl.cpp
src\hello_impl.cpp(4): error C2230: could not find module 'hello'
src\hello_impl.cpp(8): error C2653: 'say': is not a class or namespace name
src\hello_impl.cpp(8): error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
src\hello_impl.cpp(8): error C2550: 'hello::say': constructor initializer lists are only allowed on constructor definitions
src\hello_impl.cpp(10): warning C4508: 'hello::say': function should return a value; 'void' return type assumed
src\hello_impl.cpp(11): error C2653: 'say': is not a class or namespace name
src\hello_impl.cpp(12): error C2065: 'data_': undeclared identifier ohmm, I tested it on my vs2019, it will be broken for vs2019. and tests/dependence example has same issue. Z:\personal\xmake\tests\projects\c++\modules\class>xmake clean -a && xmake f -c && xmake -rv -j1
checking for platform ... windows
checking for architecture ... x64
checking for Microsoft Visual Studio (x64) version ... 2019
checking for Microsoft C/C++ Compiler (x64) version ... 19.28.29334
checking for flags (cl_scan_dependencies) ... no
[ 0%]: generating.cxx.module.deps src\hello_impl.cpp
[ 0%]: generating.cxx.module.deps src\main.cpp
[ 0%]: generating.cxx.module.deps src\hello.mpp
checking for flags (cl_ifc_output) ... ok
checking for flags (cl_interface) ... ok
checking for flags (cl_reference) ... ok
[ 41%]: generating.cxx.module.bmi hello
checking for flags (-std:c++20) ... no
checking for flags (-std:c++latest) ... ok
checking for flags (-experimental:module) ... ok
C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Tools\MSVC\14.28.29333\bin\HostX64\x64\cl.exe /EHsc -nologo -std:c++latest -experimental:module -TP -c -Fobuild\.objs\class\windows\x64\release\src\hello.mpp.obj -interface -ifcOutput build\.gens\class\windows\x64\release\rules\modules\cache\hello.ifc src\hello.mpp
hello.mpp
[ 66%]: ccache compiling.release src\hello_impl.cpp
"C:\\Program Files (x86)\\Microsoft Visual Studio\\2019\\Community\\VC\\Tools\\MSVC\\14.28.29333\\bin\\HostX64\\x64\\cl.exe" -c /EHsc -nologo -std:c++latest -experimental:module -Fobuild\.objs\class\windows\x64\release\src\hello_impl.cpp.obj src\hello_impl.cpp
checking for flags (cl_sourceDependencies) ... ok
error: hello_impl.cpp
src\hello_impl.cpp(4): error C2230: could not find module 'hello'
src\hello_impl.cpp(8): error C2653: 'say': is not a class or namespace name
src\hello_impl.cpp(8): error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
src\hello_impl.cpp(8): error C2550: 'hello::say': constructor initializer lists are only allowed on constructor definitions
src\hello_impl.cpp(10): warning C4508: 'hello::say': function should return a value; 'void' return type assumed
src\hello_impl.cpp(11): error C2653: 'say': is not a class or namespace name
src\hello_impl.cpp(12): error C2065: 'data_': undeclared identifier
|
The user_headerunits problem is probably related to the virtualbox shared disk partition, I copied it to my local c drive and it works fine. |
But the problem with impl_unit/class in vs2019 is still there |
About vs2019, because of missing /scandependence flag, fallback_generate_dependencies() call generate all requires for bmi provide. hello_impl.cpp has not been added
only main.cpp get |
maybe we cannot use we need add mapper flags for all cpp file if vs <= 2019, or we need improve fallback_generate_dependencies to scan all requires |
I have improved fallback_generate_dependencies, it should work for 2019. |
#2641
#2623