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

在项目中使一些源文件不使用预编译头 #5960

Open
fengjinfuyl opened this issue Dec 12, 2024 · 23 comments
Open

在项目中使一些源文件不使用预编译头 #5960

fengjinfuyl opened this issue Dec 12, 2024 · 23 comments

Comments

@fengjinfuyl
Copy link

你在什么场景下需要该功能?

一般项目所有源文件都会用到编译头,然而有个别源文件不想使用。在vs中,独立选中某个cpp可以设计不使用编译头。xmake我看到可以设置单个文件的编译选项,但我不知道不使用预编译头的编译选项是什么,搜索议题与社区也未发现有。

描述可能的解决方案

CMAKE中似乎是使用SKIP_PRECOMPILE_HEADERS附加到cpp附属来做的。

描述你认为的候选方案

加个命令add_skip_pch_sources()?

其他信息

No response

@Issues-translate-bot
Copy link

Bot detected the issue body's language is not English, translate it automatically.


Title: Make some source files in the project not use precompiled headers

In what scenario do you need this function?

Generally, all source files in a project will use the compiled header, but some source files do not want to be used. In VS, you can design a cpp independently without using the compiled header. I saw that xmake can set the compilation options of a single file, but I don’t know what the compilation options are without using precompiled headers, and I didn’t find any by searching the issues and communities.

Describe possible solutions

CMAKE seems to be done by using SKIP_PRECOMPILE_HEADERS attached to the cpp attachment.

Describe your alternatives

Add a command add_skip_pch_sources()?

Other information

No response

@fengjinfuyl
Copy link
Author

/Y- 可禁用

@Issues-translate-bot
Copy link

Bot detected the issue body's language is not English, translate it automatically.


/Y- can be disabled

@fengjinfuyl
Copy link
Author

add_files("xxx.cpp",{cxxflags="/Y-"}),没有效果

@fengjinfuyl fengjinfuyl reopened this Dec 13, 2024
@Issues-translate-bot
Copy link

Bot detected the issue body's language is not English, translate it automatically.


add_files("xxx.cpp",{cxxflags="/Y-"}), has no effect

@waruqi
Copy link
Member

waruqi commented Dec 20, 2024

这边测试可以的么,/Y- 加进去了,并且编译到 test7.cpp 明显停滞变慢了。

"C:\Program Files\Microsoft Visual Studio\2022\Preview\VC\Tools\MSVC\14.41.33923\bin\HostX64\x64\cl.exe" -c -nologo -O2 -std:c++11 -YuD:\projects\personal\xmake\tests\projects\c++\precompiled_header\build.gens\main\windows\x64\release\src\header.h -FID:\projects\personal\xmake\tests\projects\c++\precompiled_header\build.gens\main\windows\x64\release\src\header.h -Fpbuild.objs\main\windows\x64\release\gens\src\cxx\header.h_v143.pch /EHsc -DNDEBUG /Y- -Fobuild.objs\main\windows\x64\release\src\test7.cpp.obj src\test7.cpp

add_rules("mode.debug", "mode.release")

target("main")
    set_kind("binary")
    set_languages("cxx11")
    set_pcxxheader("src/header.h")
    add_files("src/test7.cpp", {cxflags = "/Y-"})
    add_files("src/*.cpp|test7.cpp", "src/*.c", "*.cpp")

@Issues-translate-bot
Copy link

Bot detected the issue body's language is not English, translate it automatically.


Is it possible to test here? /Y- has been added, and the compilation to test7.cpp has obviously stalled and slowed down.

"C:\Program Files\Microsoft Visual Studio\2022\Preview\VC\Tools\MSVC\14.41.33923\bin\HostX64\x64\cl.exe" -c -nologo -O2 -std:c++11 -YuD:\projects\personal\xmake\tests\projects\c++\precompiled_header\build.gens\main\windows\x64\release\src\header.h -FID:\projects\personal\xmake\tests\projects\ c++\precompiled_header\build.gens\main\windows\x64\release\src\header.h -Fpbuild.objs\main\windows\x64\release\gens\src\cxx\header.h_v143.pch /EHsc -DNDEBUG /Y- -Fobuild.objs\main\windows\x64\release\src\test7. cpp.obj src\test7.cpp

add_rules("mode.debug", "mode.release")

target("main")
    set_kind("binary")
    set_languages("cxx11")
    set_pcxxheader("src/header.h")
    add_files("src/test7.cpp", {cxflags = "/Y-"})
    add_files("src/*.cpp|test7.cpp", "src/*.c", "*.cpp")

@fengjinfuyl
Copy link
Author

这边测试可以的么,/Y- 加进去了,并且编译到 test7.cpp 明显停滞变慢了。

"C:\Program Files\Microsoft Visual Studio\2022\Preview\VC\Tools\MSVC\14.41.33923\bin\HostX64\x64\cl.exe" -c -nologo -O2 -std:c++11 -YuD:\projects\personal\xmake\tests\projects\c++\precompiled_header\build.gens\main\windows\x64\release\src\header.h -FID:\projects\personal\xmake\tests\projects\c++\precompiled_header\build.gens\main\windows\x64\release\src\header.h -Fpbuild.objs\main\windows\x64\release\gens\src\cxx\header.h_v143.pch /EHsc -DNDEBUG /Y- -Fobuild.objs\main\windows\x64\release\src\test7.cpp.obj src\test7.cpp

add_rules("mode.debug", "mode.release")

target("main")
    set_kind("binary")
    set_languages("cxx11")
    set_pcxxheader("src/header.h")
    add_files("src/test7.cpp", {cxflags = "/Y-"})
    add_files("src/*.cpp|test7.cpp", "src/*.c", "*.cpp")

看到同时有/Y- 和YU,不知道/Y-到底起效没有;我之前是通过转换成sln后,查看cpp对应属性页,发现还是使用预编译头,且对应的命令行中没找到/Y-选项。你所说明显停滞变慢了可能只是感觉,可能还需要验证下。

@Issues-translate-bot
Copy link

Bot detected the issue body's language is not English, translate it automatically.


Is it possible to test here? /Y- has been added, and the compilation to test7.cpp has obviously stalled and slowed down.

"C:\Program Files\Microsoft Visual Studio\2022\Preview\VC\Tools\MSVC\14.41.33923\bin\HostX64\x64\cl.exe" -c -nologo -O2 -std:c++11 -YuD:\projects\personal\xmake\tests\projects\c++\precompiled_header\build.gens\main\windows\x64\release\src\header.h -FID:\projects\personal\xmake\tests\projects\c++ \precompiled_header\build.gens\main\windows\x64\release\src\header.h -Fpbuild.objs\main\windows\x64\release\gens\src\cxx\header.h_v143.pch /EHsc -DNDEBUG /Y- -Fobuild.objs\main\windows\x64\release\src\test7.cpp. obj src\test7.cpp

``lua
add_rules("mode.debug", "mode.release")

target("main")
set_kind("binary")
set_languages("cxx11")
set_pcxxheader("src/header.h")
add_files("src/test7.cpp", {cxflags = "/Y-"})
add_files("src/.cpp|test7.cpp", "src/.c", "*.cpp")

I saw /Y- and YU at the same time, and I don’t know if /Y- is effective. I checked the corresponding property page of cpp after converting it to sln, and found that the precompiled header was still used, and the corresponding command line was not found. /Y-option. The obvious stagnation and slowdown you said may just be a feeling, and it may need to be verified.

@waruqi
Copy link
Member

waruqi commented Dec 20, 2024

用这个 patch 的 进程性能耗时统计特性,来提供数据验证。

#5993
#5994

xmake update -s github:xmake-io/xmake#profile

test7.cpp 添加 /Y- 之后

PS D:\projects\personal\xmake\tests\projects\c++\precompiled_header> $env:XMAKE_PROFILE = "perf:process"
PS D:\projects\personal\xmake\tests\projects\c++\precompiled_header> xmake -r
[  7%]: compiling.release build\.gens\main\windows\x64\release\src\header.h
cl: 命令行 warning D9002 :忽略未知选项“-std:c++11”
[ 15%]: compiling.release src\test.c
[ 23%]: compiling.release src\test7.cpp
[ 30%]: compiling.release src\main.cpp
[ 38%]: compiling.release src\test.cpp
[ 46%]: compiling.release src\test2.cpp
[ 53%]: compiling.release src\test4.cpp
[ 61%]: compiling.release src\test5.cpp
cl: 命令行 warning D9002 :忽略未知选项“-std:c++11”
cl: 命令行 warning D9002 :忽略未知选项“-std:c++11”
[ 69%]: compiling.release src\test6.cpp
[ 76%]: compiling.release src\test8.cpp
cl: 命令行 warning D9002 :忽略未知选项“-std:c++11”
cl: 命令行 warning D9002 :忽略未知选项“-std:c++11”
cl: 命令行 warning D9002 :忽略未知选项“-std:c++11”
[ 84%]: compiling.release test3.cpp
cl: 命令行 warning D9002 :忽略未知选项“-std:c++11”
cl: 命令行 warning D9002 :忽略未知选项“-std:c++11”
cl: 命令行 warning D9002 :忽略未知选项“-std:c++11”
cl: 命令行 warning D9002 :忽略未知选项“-std:c++11”
[ 92%]: linking.release main.exe
[100%]: build ok, spent 1.765s
781.000,  22.83%,       1, C:\Program Files\Microsoft Visual Studio\2022\Preview\VC\Tools\MSVC\14.41.33923\bin\HostX64\x64\cl.exe -c -Yc -nologo -O2 -std:c++11 -FID:\projects\personal\xmake\tests\projects\c++\precompiled_header\build\.gens\main\windows\x64\release\src\header.h /EHsc -DNDEBUG /sourceDependencies C:\Users\WANGRU~1\AppData\Local\Temp\.xmake\241220\_4D8514E3509C42008412EAFE10550F00.json -TP -Fpbuild\.objs\main\windows\x64\release\gens\src\cxx\header.h_v143.pch -Fobuild\.objs\main\windows\x64\release\gens\src\cxx\header.h_v143.pch.obj build\.gens\main\windows\x64\release\src\header.h
657.000,  19.20%,       1, C:\Program Files\Microsoft Visual Studio\2022\Preview\VC\Tools\MSVC\14.41.33923\bin\HostX64\x64\cl.exe -c -nologo -O2 -std:c++11 -YuD:\projects\personal\xmake\tests\projects\c++\precompiled_header\build\.gens\main\windows\x64\release\src\header.h -FID:\projects\personal\xmake\tests\projects\c++\precompiled_header\build\.gens\main\windows\x64\release\src\header.h -Fpbuild\.objs\main\windows\x64\release\gens\src\cxx\header.h_v143.pch /EHsc -DNDEBUG /Y- /sourceDependencies C:\Users\WANGRU~1\AppData\Local\Temp\.xmake\241220\_1E184F2B5F404C408C47C48AFC7A5690.json -Fobuild\.objs\main\windows\x64\release\src\test7.cpp.obj src\test7.cpp
281.000,   8.21%,       1, C:\Program Files\Microsoft Visual Studio\2022\Preview\VC\Tools\MSVC\14.41.33923\bin\HostX64\x64\cl.exe -c -nologo -O2 -std:c++11 -YuD:\projects\personal\xmake\tests\projects\c++\precompiled_header\build\.gens\main\windows\x64\release\src\header.h -FID:\projects\personal\xmake\tests\projects\c++\precompiled_header\build\.gens\main\windows\x64\release\src\header.h -Fpbuild\.objs\main\windows\x64\release\gens\src\cxx\header.h_v143.pch /EHsc -DNDEBUG /sourceDependencies C:\Users\WANGRU~1\AppData\Local\Temp\.xmake\241220\_A2E0B57780E54810854D8C178438BF70.json -Fobuild\.objs\main\windows\x64\release\src\test4.cpp.obj src\test4.cpp
281.000,   8.21%,       1, C:\Program Files\Microsoft Visual Studio\2022\Preview\VC\Tools\MSVC\14.41.33923\bin\HostX64\x64\cl.exe -c -nologo -O2 -std:c++11 -YuD:\projects\personal\xmake\tests\projects\c++\precompiled_header\build\.gens\main\windows\x64\release\src\header.h -FID:\projects\personal\xmake\tests\projects\c++\precompiled_header\build\.gens\main\windows\x64\release\src\header.h -Fpbuild\.objs\main\windows\x64\release\gens\src\cxx\header.h_v143.pch /EHsc -DNDEBUG /sourceDependencies C:\Users\WANGRU~1\AppData\Local\Temp\.xmake\241220\_D0C5BEEAC35845308DE9E2D1B39CF680.json -Fobuild\.objs\main\windows\x64\release\src\main.cpp.obj src\main.cpp
250.000,   7.31%,       1, C:\Program Files\Microsoft Visual Studio\2022\Preview\VC\Tools\MSVC\14.41.33923\bin\HostX64\x64\cl.exe -c -nologo -O2 -std:c++11 -YuD:\projects\personal\xmake\tests\projects\c++\precompiled_header\build\.gens\main\windows\x64\release\src\header.h -FID:\projects\personal\xmake\tests\projects\c++\precompiled_header\build\.gens\main\windows\x64\release\src\header.h -Fpbuild\.objs\main\windows\x64\release\gens\src\cxx\header.h_v143.pch /EHsc -DNDEBUG /sourceDependencies C:\Users\WANGRU~1\AppData\Local\Temp\.xmake\241220\_0C42EC1459ED4A308E71EB1E5BED8C30.json -Fobuild\.objs\main\windows\x64\release\src\test8.cpp.obj src\test8.cpp
188.000,   5.50%,       1, C:\Program Files\Microsoft Visual Studio\2022\Preview\VC\Tools\MSVC\14.41.33923\bin\HostX64\x64\cl.exe -c -nologo -O2 -std:c++11 -YuD:\projects\personal\xmake\tests\projects\c++\precompiled_header\build\.gens\main\windows\x64\release\src\header.h -FID:\projects\personal\xmake\tests\projects\c++\precompiled_header\build\.gens\main\windows\x64\release\src\header.h -Fpbuild\.objs\main\windows\x64\release\gens\src\cxx\header.h_v143.pch /EHsc -DNDEBUG /sourceDependencies C:\Users\WANGRU~1\AppData\Local\Temp\.xmake\241220\_9097E1A2BA804770845450087885AD80.json -Fobuild\.objs\main\windows\x64\release\src\test2.cpp.obj src\test2.cpp
187.000,   5.47%,       1, C:\Program Files\Microsoft Visual Studio\2022\Preview\VC\Tools\MSVC\14.41.33923\bin\HostX64\x64\cl.exe -c -nologo -O2 -std:c++11 -YuD:\projects\personal\xmake\tests\projects\c++\precompiled_header\build\.gens\main\windows\x64\release\src\header.h -FID:\projects\personal\xmake\tests\projects\c++\precompiled_header\build\.gens\main\windows\x64\release\src\header.h -Fpbuild\.objs\main\windows\x64\release\gens\src\cxx\header.h_v143.pch /EHsc -DNDEBUG /sourceDependencies C:\Users\WANGRU~1\AppData\Local\Temp\.xmake\241220\_38035DFE971D4440808FBD9F6E5DFF80.json -Fobuild\.objs\main\windows\x64\release\src\test5.cpp.obj src\test5.cpp
172.000,   5.03%,       1, C:\Program Files\Microsoft Visual Studio\2022\Preview\VC\Tools\MSVC\14.41.33923\bin\HostX64\x64\cl.exe -c -nologo -O2 -std:c++11 -YuD:\projects\personal\xmake\tests\projects\c++\precompiled_header\build\.gens\main\windows\x64\release\src\header.h -FID:\projects\personal\xmake\tests\projects\c++\precompiled_header\build\.gens\main\windows\x64\release\src\header.h -Fpbuild\.objs\main\windows\x64\release\gens\src\cxx\header.h_v143.pch /EHsc -DNDEBUG /sourceDependencies C:\Users\WANGRU~1\AppData\Local\Temp\.xmake\241220\_259420B7C3C341208A2469FA0D0D7940.json -Fobuild\.objs\main\windows\x64\release\test3.cpp.obj test3.cpp
172.000,   5.03%,       1, C:\Program Files\Microsoft Visual Studio\2022\Preview\VC\Tools\MSVC\14.41.33923\bin\HostX64\x64\cl.exe -c -nologo -O2 -std:c++11 -YuD:\projects\personal\xmake\tests\projects\c++\precompiled_header\build\.gens\main\windows\x64\release\src\header.h -FID:\projects\personal\xmake\tests\projects\c++\precompiled_header\build\.gens\main\windows\x64\release\src\header.h -Fpbuild\.objs\main\windows\x64\release\gens\src\cxx\header.h_v143.pch /EHsc -DNDEBUG /sourceDependencies C:\Users\WANGRU~1\AppData\Local\Temp\.xmake\241220\_4DC14EA4C43D404088BF55AE66DFB650.json -Fobuild\.objs\main\windows\x64\release\src\test.cpp.obj src\test.cpp
141.000,   4.12%,       1, C:\Program Files\Microsoft Visual Studio\2022\Preview\VC\Tools\MSVC\14.41.33923\bin\HostX64\x64\link.exe -nologo -dynamicbase -nxcompat -machine:x64 /opt:ref /opt:icf -out:build\windows\x64\release\main.exe build\.objs\main\windows\x64\release\src\test7.cpp.obj build\.objs\main\windows\x64\release\src\main.cpp.obj build\.objs\main\windows\x64\release\src\test.cpp.obj build\.objs\main\windows\x64\release\src\test2.cpp.obj build\.objs\main\windows\x64\release\src\test4.cpp.obj build\.objs\main\windows\x64\release\src\test5.cpp.obj build\.objs\main\windows\x64\release\src\test6.cpp.obj build\.objs\main\windows\x64\release\src\test8.cpp.obj build\.objs\main\windows\x64\release\test3.cpp.obj build\.objs\main\windows\x64\release\src\test.c.obj build\.objs\main\windows\x64\release\gens\src\cxx\header.h_v143.pch.obj
140.000,   4.09%,       1, C:\Program Files\Microsoft Visual Studio\2022\Preview\VC\Tools\MSVC\14.41.33923\bin\HostX64\x64\cl.exe -c -nologo -O2 -std:c++11 -YuD:\projects\personal\xmake\tests\projects\c++\precompiled_header\build\.gens\main\windows\x64\release\src\header.h -FID:\projects\personal\xmake\tests\projects\c++\precompiled_header\build\.gens\main\windows\x64\release\src\header.h -Fpbuild\.objs\main\windows\x64\release\gens\src\cxx\header.h_v143.pch /EHsc -DNDEBUG /sourceDependencies C:\Users\WANGRU~1\AppData\Local\Temp\.xmake\241220\_07DB9DF1F81945608ED613C2051C1870.json -Fobuild\.objs\main\windows\x64\release\src\test6.cpp.obj src\test6.cpp
140.000,   4.09%,       1, C:\Program Files\Microsoft Visual Studio\2022\Preview\VC\Tools\MSVC\14.41.33923\bin\HostX64\x64\cl.exe -c -nologo -O2 /EHsc -DNDEBUG /sourceDependencies C:\Users\WANGRU~1\AppData\Local\Temp\.xmake\241220\_0E4990E10BDE41708A99EC5BB64D20F0.json -Fobuild\.objs\main\windows\x64\release\src\test.c.obj src\test.c

test7.cpp 没有添加 /Y- 之前

578.000,  12.98%,       1, C:\Program Files\Microsoft Visual Studio\2022\Preview\VC\Tools\MSVC\14.41.33923\bin\HostX64\x64\cl.exe -c -Yc -nologo -O2 -std:c++11 -FID:\projects\personal\xmake\tests\projects\c++\precompiled_header\build\.gens\main\windows\x64\release\src\header.h /EHsc -DNDEBUG /sourceDependencies C:\Users\WANGRU~1\AppData\Local\Temp\.xmake\241220\_3B76BE9739AF486080497EE6D0B261C0.json -TP -Fpbuild\.objs\main\windows\x64\release\gens\src\cxx\header.h_v143.pch -Fobuild\.objs\main\windows\x64\release\gens\src\cxx\header.h_v143.pch.obj build\.gens\main\windows\x64\release\src\header.h
407.000,   9.14%,       1, C:\Program Files\Microsoft Visual Studio\2022\Preview\VC\Tools\MSVC\14.41.33923\bin\HostX64\x64\cl.exe -c -nologo -O2 -std:c++11 -YuD:\projects\personal\xmake\tests\projects\c++\precompiled_header\build\.gens\main\windows\x64\release\src\header.h -FID:\projects\personal\xmake\tests\projects\c++\precompiled_header\build\.gens\main\windows\x64\release\src\header.h -Fpbuild\.objs\main\windows\x64\release\gens\src\cxx\header.h_v143.pch /EHsc -DNDEBUG /sourceDependencies C:\Users\WANGRU~1\AppData\Local\Temp\.xmake\241220\_298E8986E61D4A3083BB5FC1DBA79850.json -Fobuild\.objs\main\windows\x64\release\src\test4.cpp.obj src\test4.cpp
360.000,   8.08%,       1, C:\Program Files\Microsoft Visual Studio\2022\Preview\VC\Tools\MSVC\14.41.33923\bin\HostX64\x64\cl.exe -c -nologo /sourceDependencies C:\Users\WANGRU~1\AppData\Local\Temp\.xmake\241220\_BA00A7243D5E4C5080F3318D0169DF70.json -nologo -FoC:\Users\WANGRU~1\AppData\Local\Temp\.xmake\241220\_D549FF6D684C4F708A2F29E6147FE8E0 C:\Users\WANGRU~1\AppData\Local\Temp\.xmake\241220\_2A70BC855C6B47118314FA08E23BEC9B.c
344.000,   7.72%,       1, C:\Program Files\Microsoft Visual Studio\2022\Preview\VC\Tools\MSVC\14.41.33923\bin\HostX64\x64\cl.exe -c -nologo -O2 -std:c++11 -YuD:\projects\personal\xmake\tests\projects\c++\precompiled_header\build\.gens\main\windows\x64\release\src\header.h -FID:\projects\personal\xmake\tests\projects\c++\precompiled_header\build\.gens\main\windows\x64\release\src\header.h -Fpbuild\.objs\main\windows\x64\release\gens\src\cxx\header.h_v143.pch /EHsc -DNDEBUG /sourceDependencies C:\Users\WANGRU~1\AppData\Local\Temp\.xmake\241220\_101B4CFBFAB44B1085F7CC6ECC15B150.json -Fobuild\.objs\main\windows\x64\release\src\test5.cpp.obj src\test5.cpp
344.000,   7.72%,       1, C:\Program Files\Microsoft Visual Studio\2022\Preview\VC\Tools\MSVC\14.41.33923\bin\HostX64\x64\cl.exe -c -nologo -O2 -std:c++11 -YuD:\projects\personal\xmake\tests\projects\c++\precompiled_header\build\.gens\main\windows\x64\release\src\header.h -FID:\projects\personal\xmake\tests\projects\c++\precompiled_header\build\.gens\main\windows\x64\release\src\header.h -Fpbuild\.objs\main\windows\x64\release\gens\src\cxx\header.h_v143.pch /EHsc -DNDEBUG /sourceDependencies C:\Users\WANGRU~1\AppData\Local\Temp\.xmake\241220\_FFC797C49D6F4A508F1D7BF6D4AEC6C0.json -Fobuild\.objs\main\windows\x64\release\src\test2.cpp.obj src\test2.cpp
313.000,   7.03%,       1, C:\Program Files\Microsoft Visual Studio\2022\Preview\VC\Tools\MSVC\14.41.33923\bin\HostX64\x64\cl.exe -c -nologo -O2 -std:c++11 -YuD:\projects\personal\xmake\tests\projects\c++\precompiled_header\build\.gens\main\windows\x64\release\src\header.h -FID:\projects\personal\xmake\tests\projects\c++\precompiled_header\build\.gens\main\windows\x64\release\src\header.h -Fpbuild\.objs\main\windows\x64\release\gens\src\cxx\header.h_v143.pch /EHsc -DNDEBUG /sourceDependencies C:\Users\WANGRU~1\AppData\Local\Temp\.xmake\241220\_8C24AFC639054E3082F1430B3C96B680.json -Fobuild\.objs\main\windows\x64\release\src\main.cpp.obj src\main.cpp
312.000,   7.00%,       1, C:\Program Files\Microsoft Visual Studio\2022\Preview\VC\Tools\MSVC\14.41.33923\bin\HostX64\x64\cl.exe -c -FoC:\Users\WANGRU~1\AppData\Local\Temp\.xmake\241220\_83F3C06D084249708F2029E4A97B5B90.obj C:\Users\WANGRU~1\AppData\Local\Temp\.xmake\241220\_43BC133B2E03456084D41BE8340226A0.c
266.000,   5.97%,       2, where.exe nim.exe
249.000,   5.59%,       5, C:\Program Files\Microsoft Visual Studio\2022\Preview\VC\Tools\MSVC\14.41.33923\bin\HostX64\x64\cl.exe
235.000,   5.28%,       1, C:\Program Files\Microsoft Visual Studio\2022\Preview\VC\Tools\MSVC\14.41.33923\bin\HostX64\x64\cl.exe -c -nologo -O2 -std:c++11 -YuD:\projects\personal\xmake\tests\projects\c++\precompiled_header\build\.gens\main\windows\x64\release\src\header.h -FID:\projects\personal\xmake\tests\projects\c++\precompiled_header\build\.gens\main\windows\x64\release\src\header.h -Fpbuild\.objs\main\windows\x64\release\gens\src\cxx\header.h_v143.pch /EHsc -DNDEBUG /sourceDependencies C:\Users\WANGRU~1\AppData\Local\Temp\.xmake\241220\_1267EC2E4C9E4B308779107BB6CFCC90.json -Fobuild\.objs\main\windows\x64\release\src\test.cpp.obj src\test.cpp
157.000,   3.52%,       1, C:\Program Files\Microsoft Visual Studio\2022\Preview\VC\Tools\MSVC\14.41.33923\bin\HostX64\x64\cl.exe -c -nologo -O2 -std:c++11 -YuD:\projects\personal\xmake\tests\projects\c++\precompiled_header\build\.gens\main\windows\x64\release\src\header.h -FID:\projects\personal\xmake\tests\projects\c++\precompiled_header\build\.gens\main\windows\x64\release\src\header.h -Fpbuild\.objs\main\windows\x64\release\gens\src\cxx\header.h_v143.pch /EHsc -DNDEBUG /sourceDependencies C:\Users\WANGRU~1\AppData\Local\Temp\.xmake\241220\_4ED9DD472F564C108A48CE77C99E8E20.json -Fobuild\.objs\main\windows\x64\release\src\test8.cpp.obj src\test8.cpp
156.000,   3.50%,       1, C:\Program Files\Microsoft Visual Studio\2022\Preview\VC\Tools\MSVC\14.41.33923\bin\HostX64\x64\cl.exe -c -nologo -O2 -std:c++11 -YuD:\projects\personal\xmake\tests\projects\c++\precompiled_header\build\.gens\main\windows\x64\release\src\header.h -FID:\projects\personal\xmake\tests\projects\c++\precompiled_header\build\.gens\main\windows\x64\release\src\header.h -Fpbuild\.objs\main\windows\x64\release\gens\src\cxx\header.h_v143.pch /EHsc -DNDEBUG /sourceDependencies C:\Users\WANGRU~1\AppData\Local\Temp\.xmake\241220\_599A9C829DB049108497DFE01C676690.json -Fobuild\.objs\main\windows\x64\release\test3.cpp.obj test3.cpp
141.000,   3.17%,       1, C:\Program Files\Microsoft Visual Studio\2022\Preview\VC\Tools\MSVC\14.41.33923\bin\HostX64\x64\cl.exe -c -nologo -O2 -std:c++11 -YuD:\projects\personal\xmake\tests\projects\c++\precompiled_header\build\.gens\main\windows\x64\release\src\header.h -FID:\projects\personal\xmake\tests\projects\c++\precompiled_header\build\.gens\main\windows\x64\release\src\header.h -Fpbuild\.objs\main\windows\x64\release\gens\src\cxx\header.h_v143.pch /EHsc -DNDEBUG /sourceDependencies C:\Users\WANGRU~1\AppData\Local\Temp\.xmake\241220\_55189E9126D34E60856FF340F1BAAFB0.json -Fobuild\.objs\main\windows\x64\release\src\test6.cpp.obj src\test6.cpp
140.000,   3.14%,       1, C:\Program Files\Microsoft Visual Studio\2022\Preview\VC\Tools\MSVC\14.41.33923\bin\HostX64\x64\cl.exe -c -nologo -O2 -std:c++11 -YuD:\projects\personal\xmake\tests\projects\c++\precompiled_header\build\.gens\main\windows\x64\release\src\header.h -FID:\projects\personal\xmake\tests\projects\c++\precompiled_header\build\.gens\main\windows\x64\release\src\header.h -Fpbuild\.objs\main\windows\x64\release\gens\src\cxx\header.h_v143.pch /EHsc -DNDEBUG /sourceDependencies C:\Users\WANGRU~1\AppData\Local\Temp\.xmake\241220\_35803D00EF344E508F406994297EEFB0.json -Fobuild\.objs\main\windows\x64\release\src\test7.cpp.obj src\test7.cpp
140.000,   3.14%,       1, C:\Program Files\Microsoft Visual Studio\2022\Preview\VC\Tools\MSVC\14.41.33923\bin\HostX64\x64\link.exe -nologo -dynamicbase -nxcompat -machine:x64 /opt:ref /opt:icf -out:build\windows\x64\release\main.exe build\.objs\main\windows\x64\release\src\main.cpp.obj build\.objs\main\windows\x64\release\src\test.cpp.obj build\.objs\main\windows\x64\release\src\test2.cpp.obj build\.objs\main\windows\x64\release\src\test4.cpp.obj build\.objs\main\windows\x64\release\src\test5.cpp.obj build\.objs\main\windows\x64\release\src\test6.cpp.obj build\.objs\main\windows\x64\release\src\test7.cpp.obj build\.objs\main\windows\x64\release\src\test8.cpp.obj build\.objs\main\windows\x64\release\test3.cpp.obj build\.objs\main\windows\x64\release\src\test.c.obj build\.objs\main\windows\x64\release\gens\src\cxx\header.h_v143.pch.obj
140.000,   3.14%,       1, C:\Program Files\Microsoft Visual Studio\2022\Preview\VC\Tools\MSVC\14.41.33923\bin\HostX64\x64\cl.exe -c -nologo -O2 /EHsc -DNDEBUG /sourceDependencies C:\Users\WANGRU~1\AppData\Local\Temp\.xmake\241220\_A6DD26D14F004160855BC537EAE811A0.json -Fobuild\.objs\main\windows\x64\release\src\test.c.obj src\test.c
94.000,   2.11%,       1, C:\Program Files\Microsoft Visual Studio\2022\Preview\VC\Tools\MSVC\14.41.33923\bin\HostX64\x64\cl.exe -c -nologo /sourceDependencies C:\Users\WANGRU~1\AppData\Local\Temp\.xmake\241220\_B098962D255D492080CC2BAE33A7D830.json -nologo -FoC:\Users\WANGRU~1\AppData\Local\Temp\.xmake\241220\_D0AAB00193A14800882620E8A1026540 C:\Users\WANGRU~1\AppData\Local\Temp\.xmake\241220\_2A70BC855C6B47118314FA08E23BEC9B.cpp
47.000,   1.06%,       1, C:\Program Files\Microsoft Visual Studio\2022\Preview\VC\Tools\MSVC\14.41.33923\bin\HostX64\x64\link.exe -lib -out:C:\Users\WANGRU~1\AppData\Local\Temp\.xmake\241220\_B0FCE914DA564420868A4C368BDD0340.exe C:\Users\WANGRU~1\AppData\Local\Temp\.xmake\241220\_83F3C06D084249708F2029E4A97B5B90.obj

结果

657.000, 19.20%, 1, C:\Program Files\Microsoft Visual Studio\2022\Preview\VC\Tools\MSVC\14.41.33923\bin\HostX64\x64\cl.exe -c -nologo -O2 -std:c++11 -YuD:\projects\personal\xmake\tests\projects\c++\precompiled_header\build.gens\main\windows\x64\release\src\header.h -FID:\projects\personal\xmake\tests\projects\c++\precompiled_header\build.gens\main\windows\x64\release\src\header.h -Fpbuild.objs\main\windows\x64\release\gens\src\cxx\header.h_v143.pch /EHsc -DNDEBUG /Y- /sourceDependencies C:\Users\WANGRU~1\AppData\Local\Temp.xmake\241220_1E184F2B5F404C408C47C48AFC7A5690.json -Fobuild.objs\main\windows\x64\release\src\test7.cpp.obj src\test7.cpp

可以看到,add_files("src/test7.cpp", {cxflags = "/Y-"}) 之后,test7.cpp 的编译,明显排到了 top2,占了总时间的 19.2% ,仅次于 header.h 预处理头文件的编译的耗时,而没添加前,每个 cpp 的编译耗时分布都是均匀分布的。

所以,有数据验证确认,目前的配置就是生效的。

@waruqi
Copy link
Member

waruqi commented Dec 20, 2024

我之前是通过转换成sln后,查看cpp对应属性页,发现还是使用预编译头,且对应的命令行中没找到/Y-选项。你所说明显停滞变慢了可能只是感觉,可能还需要验证下。

不要用 生成 sln 来验证,那个不支持

@waruqi waruqi added this to the v2.9.8 milestone Dec 20, 2024
@Issues-translate-bot
Copy link

Bot detected the issue body's language is not English, translate it automatically.


Use this patch's process performance time statistics feature to provide data verification.

#5993
#5994

xmake update -s github:xmake-io/xmake#profile

test7.cpp after adding /Y-

PS D:\projects\personal\xmake\tests\projects\c++\precompiled_header> $env:XMAKE_PROFILE = "perf:process"
PS D:\projects\personal\xmake\tests\projects\c++\precompiled_header> xmake -r
[ 7%]: compiling.release build\.gens\main\windows\x64\release\src\header.h
cl: command line warning D9002: unknown option '-std:c++11' ignored
[15%]: compiling.release src\test.c
[23%]: compiling.release src\test7.cpp
[30%]: compiling.release src\main.cpp
[38%]: compiling.release src\test.cpp
[46%]: compiling.release src\test2.cpp
[53%]: compiling.release src\test4.cpp
[61%]: compiling.release src\test5.cpp
cl: command line warning D9002: unknown option '-std:c++11' ignored
cl: command line warning D9002: unknown option '-std:c++11' ignored
[69%]: compiling.release src\test6.cpp
[76%]: compiling.release src\test8.cpp
cl: command line warning D9002: unknown option '-std:c++11' ignored
cl: command line warning D9002: unknown option '-std:c++11' ignored
cl: command line warning D9002: unknown option '-std:c++11' ignored
[84%]: compiling.release test3.cpp
cl: command line warning D9002: unknown option '-std:c++11' ignored
cl: command line warning D9002: unknown option '-std:c++11' ignored
cl: command line warning D9002: unknown option '-std:c++11' ignored
cl: command line warning D9002: unknown option '-std:c++11' ignored
[92%]: linking.release main.exe
[100%]: build ok, spent 1.765s
781.000, 22.83%, 1, C:\Program Files\Microsoft Visual Studio\2022\Preview\VC\Tools\MSVC\14.41.33923\bin\HostX64\x64\cl.exe -c -Yc -nologo -O2 -std :c++11 -FID:\projects\personal\xmake\tests\projects\c++\precompiled_header\build\.gens\main\windows\x64\release\src\header.h /EHsc -DNDEBUG /sourceDependencies C:\Users\WANGRU~1\AppData\Local\Temp\.xmake\241220\_4D8514E3509C42008412EAFE10550F00.json -TP -Fpbuild\.objs\main\windows\x64\release\gens\src\cxx\header.h_v143.pch -Fobuild\.objs\main\windows\x64\release\gens\src\cxx\header.h_v143.pch.obj build\.gens\main\windows\x64\release\src\header.h
657.000, 19.20%, 1, C:\Program Files\Microsoft Visual Studio\2022\Preview\VC\Tools\MSVC\14.41.33923\bin\HostX64\x64\cl.exe -c -nologo -O2 -std:c ++11 -YuD:\projects\personal\xmake\tests\projects\c++\precompiled_header\build\.gens\main\windows\x64\release\src\header.h -FID:\projects\personal\xmake\tests\projects\ c++\precompiled_header\build\.gens\main\windows\x64\release\src\header.h -Fpbuild\.objs\main\windows\x64\release\gens\src\cxx\header.h_v143.pch /EHsc -DNDEBUG /Y- /sourceDependencies C:\Users\WANGRU~1\AppData\Local\Temp\.xmake\241220\_1E184F2B5F404C408C47C48AFC7A5690.json -Fobuild\.objs\main\windows\x64\release\src\test7.cpp.obj src\test7.cpp
281.000, 8.21%, 1, C:\Program Files\Microsoft Visual Studio\2022\Preview\VC\Tools\MSVC\14.41.33923\bin\HostX64\x64\cl.exe -c -nologo -O2 -std:c ++11 -YuD:\projects\personal\xmake\tests\projects\c++\precompiled_header\build\.gens\main\windows\x64\release\src\header.h -FID:\projects\personal\xmake\tests\projects\ c++\precompiled_header\build\.gens\main\windows\x64\release\src\header.h -Fpbuild\.objs\main\windows\x64\release\gens\src\cxx\header.h_v143.pch /EHsc -DNDEBUG /sourceDependencies C:\Users\WANGRU~1\AppData\Local\Temp\.xmake\241220\_A2E0B57780E54810854D8C178438BF70.json -Fobuild\.objs\main\windows\x64\release\src\test4.cpp.obj src\test4.cpp
281.000, 8.21%, 1, C:\Program Files\Microsoft Visual Studio\2022\Preview\VC\Tools\MSVC\14.41.33923\bin\HostX64\x64\cl.exe -c -nologo -O2 -std:c ++11 -YuD:\projects\personal\xmake\tests\projects\c++\precompiled_header\build\.gens\main\windows\x64\release\src\header.h -FID:\projects\personal\xmake\tests\projects\ c++\precompiled_header\build\.gens\main\windows\x64\release\src\header.h -Fpbuild\.objs\main\windows\x64\release\gens\src\cxx\header.h_v143.pch /EHsc -DNDEBUG /sourceDependencies C:\Users\WANGRU~1\AppData\Local\Temp\.xmake\241220\_D0C5BEEAC35845308DE9E2D1B39CF680.json -Fobuild\.objs\main\windows\x64\release\src\main.cpp.obj src\main.cpp
250.000, 7.31%, 1, C:\Program Files\Microsoft Visual Studio\2022\Preview\VC\Tools\MSVC\14.41.33923\bin\HostX64\x64\cl.exe -c -nologo -O2 -std:c ++11 -YuD:\projects\personal\xmake\tests\projects\c++\precompiled_header\build\.gens\main\windows\x64\release\src\header.h -FID:\projects\personal\xmake\tests\projects\ c++\precompiled_header\build\.gens\main\windows\x64\release\src\header.h -Fpbuild\.objs\main\windows\x64\release\gens\src\cxx\header.h_v143.pch /EHsc -DNDEBUG /sourceDependencies C:\Users\WANGRU~1\AppData\Local\Temp\.xmake\241220\_0C42EC1459ED4A308E71EB1E5BED8C30.json -Fobuild\.objs\main\windows\x64\release\src\test8.cpp.obj src\test8.cpp
188.000, 5.50%, 1, C:\Program Files\Microsoft Visual Studio\2022\Preview\VC\Tools\MSVC\14.41.33923\bin\HostX64\x64\cl.exe -c -nologo -O2 -std:c ++11 -YuD:\projects\personal\xmake\tests\projects\c++\precompiled_header\build\.gens\main\windows\x64\release\src\header.h -FID:\projects\personal\xmake\tests\projects\ c++\precompiled_header\build\.gens\main\windows\x64\release\src\header.h -Fpbuild\.objs\main\windows\x64\release\gens\src\cxx\header.h_v143.pch /EHsc -DNDEBUG /sourceDependencies C:\Users\WANGRU~1\AppData\Local\Temp\.xmake\241220\_9097E1A2BA804770845450087885AD80.json -Fobuild\.objs\main\windows\x64\release\src\test2.cpp.obj src\test2.cpp
187.000, 5.47%, 1, C:\Program Files\Microsoft Visual Studio\2022\Preview\VC\Tools\MSVC\14.41.33923\bin\HostX64\x64\cl.exe -c -nologo -O2 -std:c ++11 -YuD:\projects\personal\xmake\tests\projects\c++\precompiled_header\build\.gens\main\windows\x64\release\src\header.h -FID:\projects\personal\xmake\tests\projects\ c++\precompiled_header\build\.gens\main\windows\x64\release\src\header.h -Fpbuild\.objs\main\windows\x64\release\gens\src\cxx\header.h_v143.pch /EHsc -DNDEBUG /sourceDependencies C:\Users\WANGRU~1\AppData\Local\Temp\.xmake\241220\_38035DFE971D4440808FBD9F6E5DFF80.json -Fobuild\.objs\main\windows\x64\release\src\test5.cpp.obj src\test5.cpp
172.000, 5.03%, 1, C:\Program Files\Microsoft Visual Studio\2022\Preview\VC\Tools\MSVC\14.41.33923\bin\HostX64\x64\cl.exe -c -nologo -O2 -std:c ++11 -YuD:\projects\personal\xmake\tests\projects\c++\precompiled_header\build\.gens\main\windows\x64\release\src\header.h -FID:\projects\personal\xmake\tests\projects\ c++\precompiled_header\build\.gens\main\windows\x64\release\src\header.h -Fpbuild\.objs\main\windows\x64\release\gens\src\cxx\header.h_v143.pch /EHsc -DNDEBUG /sourceDependencies C:\Users\WANGRU~1\AppData\Local\Temp\.xmake\241220\_259420B7C3C341208A2469FA0D0D7940.json -Fobuild\.objs\main\windows\x64\release\test3.cpp.obj test3.cpp
172.000, 5.03%, 1, C:\Program Files\Microsoft Visual Studio\2022\Preview\VC\Tools\MSVC\14.41.33923\bin\HostX64\x64\cl.exe -c -nologo -O2 -std:c ++11 -YuD:\projects\personal\xmake\tests\projects\c++\precompiled_header\build\.gens\main\windows\x64\release\src\header.h -FID:\projects\personal\xmake\tests\projects\ c++\precompiled_header\build\.gens\main\windows\x64\release\src\header.h -Fpbuild\.objs\main\windows\x64\release\gens\src\cxx\header.h_v143.pch /EHsc -DNDEBUG /sourceDependencies C:\Users\WANGRU~1\AppData\Local\Temp\.xmake\241220\_4DC14EA4C43D404088BF55AE66DFB650.json -Fobuild\.objs\main\windows\x64\release\src\test.cpp.obj src\test.cpp
141.000, 4.12%, 1, C:\Program Files\Microsoft Visual Studio\2022\Preview\VC\Tools\MSVC\14.41.33923\bin\HostX64\x64\link.exe -nologo -dynamicbase -nxcompat -machine:x64 /opt:ref /opt:icf -out:build\windows\x64\release\main.exe build\.objs\main\windows\x64\release\src\test7.cpp.obj build\.objs\main\windows\x64\release\src\main .cpp.obj build\.objs\main\windows\x64\release\src\test.cpp.obj build\.objs\main\windows\x64\release\src\test2.cpp.obj build\.objs\main\windows\x64\release\src\test4.cpp.obj build\.objs\main\windows\x64 \release\src\test5.cpp.obj build\.objs\main\windows\x64\release\src\test6.cpp.obj build\.objs\main\windows\x64\release\src\test8.cpp.obj build\.objs\main\windows\x64 \release\test3.cpp.obj build\.objs\main\windows\x64\release\src\test.c.obj build\.objs\main\windows\x64\release\gens\src\cxx\header.h_v143.pch.obj
140.000, 4.09%, 1, C:\Program Files\Microsoft Visual Studio\2022\Preview\VC\Tools\MSVC\14.41.33923\bin\HostX64\x64\cl.exe -c -nologo -O2 -std:c ++11 -YuD:\projects\personal\xmake\tests\projects\c++\precompiled_header\build\.gens\main\windows\x64\release\src\header.h -FID:\projects\personal\xmake\tests\projects\ c++\precompiled_header\build\.gens\main\windows\x64\release\src\header.h -Fpbuild\.objs\main\windows\x64\release\gens\src\cxx\header.h_v143.pch /EHsc -DNDEBUG /sourceDependencies C:\Users\WANGRU~1\AppData\Local\Temp\.xmake\241220\_07DB9DF1F81945608ED613C2051C1870.json -Fobuild\.objs\main\windows\x64\release\src\test6.cpp.obj src\test6.cpp
140.000, 4.09%, 1, C:\Program Files\Microsoft Visual Studio\2022\Preview\VC\Tools\MSVC\14.41.33923\bin\HostX64\x64\cl.exe -c -nologo -O2 /EHsc -DNDEBUG /sourceDependencies C:\Users\WANGRU~1\AppData\Local\Temp\.xmake\241220\_0E4990E10BDE41708A99EC5BB64D20F0.json -Fobuild\.objs\main\windows\x64\release\src\test.c.obj src\test.c

test7.cpp without adding /Y- before

578.000, 12.98%, 1, C:\Program Files\Microsoft Visual Studio\2022\Preview\VC\Tools\MSVC\14.41.33923\bin\HostX64\x64\cl.exe -c -Yc -nologo -O2 -std :c++11 -FID:\projects\personal\xmake\tests\projects\c++\precompiled_header\build\.gens\main\windows\x64\release\src\header.h /EHsc -DNDEBUG /sourceDependencies C:\Users\WANGRU~1\AppData\Local\Temp\.xmake\241220\_3B76BE9739AF486080497EE6D0B261C0.json -TP -Fpbuild\.objs\main\windows\x64\release\gens\src\cxx\header.h_v143.pch -Fobuild\.objs\main\windows\x64\release\gens\src\cxx\header.h_v143.pch.obj build\.gens\main\windows\x64\release\src\header.h
407.000, 9.14%, 1, C:\Program Files\Microsoft Visual Studio\2022\Preview\VC\Tools\MSVC\14.41.33923\bin\HostX64\x64\cl.exe -c -nologo -O2 -std:c ++11 -YuD:\projects\personal\xmake\tests\projects\c++\precompiled_header\build\.gens\main\windows\x64\release\src\header.h -FID:\projects\personal\xmake\tests\projects\ c++\precompiled_header\build\.gens\main\windows\x64\release\src\header.h -Fpbuild\.objs\main\windows\x64\release\gens\src\cxx\header.h_v143.pch /EHsc -DNDEBUG /sourceDependencies C:\Users\WANGRU~1\AppData\Local\Temp\.xmake\241220\_298E8986E61D4A3083BB5FC1DBA79850.json -Fobuild\.objs\main\windows\x64\release\src\test4.cpp.obj src\test4.cpp
360.000, 8.08%, 1, C:\Program Files\Microsoft Visual Studio\2022\Preview\VC\Tools\MSVC\14.41.33923\bin\HostX64\x64\cl.exe -c -nologo /sourceDependencies C:\Users\WANGRU~1\AppData\Local\Temp\.xmake\241220\_BA00A7243D5E4C5080F3318D0169DF70.json -nologo -FoC:\Users\WANGRU~1\AppData\Local\Temp\.xmake\241220\_D549FF6D684C4F708A2F29E6147FE8E0 C:\Users\WANGRU~1\AppData\Local\Temp\.xmake\241220\_2A70BC855C6B47118314FA08E23BEC9B.c
344.000, 7.72%, 1, C:\Program Files\Microsoft Visual Studio\2022\Preview\VC\Tools\MSVC\14.41.33923\bin\HostX64\x64\cl.exe -c -nologo -O2 -std:c ++11 -YuD:\projects\personal\xmake\tests\projects\c++\precompiled_header\build\.gens\main\windows\x64\release\src\header.h -FID:\projects\personal\xmake\tests\projects\ c++\precompiled_header\build\.gens\main\windows\x64\release\src\header.h -Fpbuild\.objs\main\windows\x64\release\gens\src\cxx\header.h_v143.pch /EHsc -DNDEBUG /sourceDependencies C:\Users\WANGRU~1\AppData\Local\Temp\.xmake\241220\_101B4CFBFAB44B1085F7CC6ECC15B150.json -Fobuild\.objs\main\windows\x64\release\src\test5.cpp.obj src\test5.cpp
344.000, 7.72%, 1, C:\Program Files\Microsoft Visual Studio\2022\Preview\VC\Tools\MSVC\14.41.33923\bin\HostX64\x64\cl.exe -c -nologo -O2 -std:c ++11 -YuD:\projects\personal\xmake\tests\projects\c++\precompiled_header\build\.gens\main\windows\x64\release\src\header.h -FID:\projects\personal\xmake\tests\projects\ c++\precompiled_header\build\.gens\main\windows\x64\release\src\header.h -Fpbuild\.objs\main\windows\x64\release\gens\src\cxx\header.h_v143.pch /EHsc -DNDEBUG /sourceDependencies C:\Users\WANGRU~1\AppData\Local\Temp\.xmake\241220\_FFC797C49D6F4A508F1D7BF6D4AEC6C0.json -Fobuild\.objs\main\windows\x64\release\src\test2.cpp.obj src\test2.cpp
313.000, 7.03%, 1, C:\Program Files\Microsoft Visual Studio\2022\Preview\VC\Tools\MSVC\14.41.33923\bin\HostX64\x64\cl.exe -c -nologo -O2 -std:c ++11 -YuD:\projects\personal\xmake\tests\projects\c++\precompiled_header\build\.gens\main\windows\x64\release\src\header.h -FID:\projects\personal\xmake\tests\projects\ c++\precompiled_header\build\.gens\main\windows\x64\release\src\header.h -Fpbuild\.objs\main\windows\x64\release\gens\src\cxx\header.h_v143.pch /EHsc -DNDEBUG /sourceDependencies C:\Users\WANGRU~1\AppData\Local\Temp\.xmake\241220\_8C24AFC639054E3082F1430B3C96B680.json -Fobuild\.objs\main\windows\x64\release\src\main.cpp.obj src\main.cpp
312.000, 7.00%, 1, C:\Program Files\Microsoft Visual Studio\2022\Preview\VC\Tools\MSVC\14.41.33923\bin\HostX64\x64\cl.exe -c -FoC:\Users\WANGRU~1\AppData\Local\Temp\.xmake\241220\_83F3C06D084249708F2029E4A97B5B90.obj C:\Users\WANGRU~1\AppData\Local\Temp\.xmake\241220\_43BC133B2E03456084D41BE8340226A0.c
266.000, 5.97%, 2, where.exe nim.exe
249.000, 5.59%, 5, C:\Program Files\Microsoft Visual Studio\2022\Preview\VC\Tools\MSVC\14.41.33923\bin\HostX64\x64\cl.exe
235.000, 5.28%, 1, C:\Program Files\Microsoft Visual Studio\2022\Preview\VC\Tools\MSVC\14.41.33923\bin\HostX64\x64\cl.exe -c -nologo -O2 -std:c ++11 -YuD:\projects\personal\xmake\tests\projects\c++\precompiled_header\build\.gens\main\windows\x64\release\src\header.h -FID:\projects\personal\xmake\tests\projects\ c++\precompiled_header\build\.gens\main\windows\x64\release\src\header.h -Fpbuild\.objs\main\windows\x64\release\gens\src\cxx\header.h_v143.pch /EHsc -DNDEBUG /sourceDependencies C:\Users\WANGRU~1\AppData\Local\Temp\.xmake\241220\_1267EC2E4C9E4B308779107BB6CFCC90.json -Fobuild\.objs\main\windows\x64\release\src\test.cpp.obj src\test.cpp
157.000, 3.52%, 1, C:\Program Files\Microsoft Visual Studio\2022\Preview\VC\Tools\MSVC\14.41.33923\bin\HostX64\x64\cl.exe -c -nologo -O2 -std:c ++11 -YuD:\projects\personal\xmake\tests\projects\c++\precompiled_header\build\.gens\main\windows\x64\release\src\header.h -FID:\projects\personal\xmake\tests\projects\ c++\precompiled_header\build\.gens\main\windows\x64\release\src\header.h -Fpbuild\.objs\main\windows\x64\release\gens\src\cxx\header.h_v143.pch /EHsc -DNDEBUG /sourceDependencies C:\Users\WANGRU~1\AppData\Local\Temp\.xmake\241220\_4ED9DD472F564C108A48CE77C99E8E20.json -Fobuild\.objs\main\windows\x64\release\src\test8.cpp.obj src\test8.cpp
156.000, 3.50%, 1, C:\Program Files\Microsoft Visual Studio\2022\Preview\VC\Tools\MSVC\14.41.33923\bin\HostX64\x64\cl.exe -c -nologo -O2 -std:c ++11 -YuD:\projects\personal\xmake\tests\projects\c++\precompiled_header\build\.gens\main\windows\x64\release\src\header.h -FID:\projects\personal\xmake\tests\projects\ c++\precompiled_header\build\.gens\main\windows\x64\release\src\header.h -Fpbuild\.objs\main\windows\x64\release\gens\src\cxx\header.h_v143.pch /EHsc -DNDEBUG /sourceDependencies C:\Users\WANGRU~1\AppData\Local\Temp\.xmake\241220\_599A9C829DB049108497DFE01C676690.json -Fobuild\.objs\main\windows\x64\release\test3.cpp.obj test3.cpp
141.000, 3.17%, 1, C:\Program Files\Microsoft Visual Studio\2022\Preview\VC\Tools\MSVC\14.41.33923\bin\HostX64\x64\cl.exe -c -nologo -O2 -std:c ++11 -YuD:\projects\personal\xmake\tests\projects\c++\precompiled_header\build\.gens\main\windows\x64\release\src\header.h -FID:\projects\personal\xmake\tests\projects\ c++\precompiled_header\build\.gens\main\windows\x64\release\src\header.h -Fpbuild\.objs\main\windows\x64\release\gens\src\cxx\header.h_v143.pch /EHsc -DNDEBUG /sourceDependencies C:\Users\WANGRU~1\AppData\Local\Temp\.xmake\241220\_55189E9126D34E60856FF340F1BAAFB0.json -Fobuild\.objs\main\windows\x64\release\src\test6.cpp.obj src\test6.cpp
140.000, 3.14%, 1, C:\Program Files\Microsoft Visual Studio\2022\Preview\VC\Tools\MSVC\14.41.33923\bin\HostX64\x64\cl.exe -c -nologo -O2 -std:c ++11 -YuD:\projects\personal\xmake\tests\projects\c++\precompiled_header\build\.gens\main\windows\x64\release\src\header.h -FID:\projects\personal\xmake\tests\projects\ c++\precompiled_header\build\.gens\main\windows\x64\release\src\header.h -Fpbuild\.objs\main\windows\x64\release\gens\src\cxx\header.h_v143.pch /EHsc -DNDEBUG /sourceDependencies C:\Users\WANGRU~1\AppData\Local\Temp\.xmake\241220\_35803D00EF344E508F406994297EEFB0.json -Fobuild\.objs\main\windows\x64\release\src\test7.cpp.obj src\test7.cpp
140.000, 3.14%, 1, C:\Program Files\Microsoft Visual Studio\2022\Preview\VC\Tools\MSVC\14.41.33923\bin\HostX64\x64\link.exe -nologo -dynamicbase -nxcompat -machine:x64 /opt:ref /opt:icf -out:build\windows\x64\release\main.exe build\.objs\main\windows\x64\release\src\main.cpp.obj build\.objs\main\windows\x64\release\src\test .cpp.obj build\.objs\main\windows\x64\release\src\test2.cpp.obj build\.objs\main\windows\x64\release\src\test4.cpp.obj build\.objs\main\windows\x64\release\src\test5.cpp.obj build\.objs\main\windows\x64 \release\src\test6.cpp.obj build\.objs\main\windows\x64\release\src\test7.cpp.obj build\.objs\main\windows\x64\release\src\test8.cpp.obj build\.objs\main\windows\x64 \release\test3.cpp.obj build\.objs\main\windows\x64\release\src\test.c.obj build\.objs\main\windows\x64\release\gens\src\cxx\header.h_v143.pch.obj
140.000, 3.14%, 1, C:\Program Files\Microsoft Visual Studio\2022\Preview\VC\Tools\MSVC\14.41.33923\bin\HostX64\x64\cl.exe -c -nologo -O2 /EHsc -DNDEBUG /sourceDependencies C:\Users\WANGRU~1\AppData\Local\Temp\.xmake\241220\_A6DD26D14F004160855BC537EAE811A0.json -Fobuild\.objs\main\windows\x64\release\src\test.c.obj src\test.c
94.000, 2.11%, 1, C:\Program Files\Microsoft Visual Studio\2022\Preview\VC\Tools\MSVC\14.41.33923\bin\HostX64\x64\cl.exe -c -nologo /sourceDependencies C:\Users\WANGRU~1\AppData\Local\Temp\.xmake\241220\_B098962D255D492080CC2BAE33A7D830.json -nologo -FoC:\Users\WANGRU~1\AppData\Local\Temp\.xmake\241220\_D0AAB00193A14800882620E8A1026540 C:\Users\WANGRU~1\AppData\Local\Temp\.xmake\241220\_2A70BC855C6B47118314FA08E23BEC9B.cpp
47.000, 1.06%, 1, C:\Program Files\Microsoft Visual Studio\2022\Preview\VC\Tools\MSVC\14.41.33923\bin\HostX64\x64\link.exe -lib -out:C:\Users\WANGRU~1\AppData\Local\Temp\.xmake\241220\_B0FCE914DA564420868A4C368BDD0340.exe C:\Users\WANGRU~1\AppData\Local\Temp\.xmake\241220\_83F3C06D084249708F2029E4A97B5B90.obj

result

657.000, 19.20%, 1, C:\Program Files\Microsoft Visual Studio\2022\Preview\VC\Tools\MSVC\14.41.33923\bin\HostX64\x64\cl.exe -c -nologo -O2 -std: c++11 -YuD:\projects\personal\xmake\tests\projects\c++\precompiled_header\build.gens\main\windows\x64\release\src\header.h -FID:\projects\personal\xmake\tests\projects\ c++\precompiled_header\build.gens\main\windows\x64\release\src\header.h -Fpbuild.objs\main\windows\x64\release\gens\src\cxx\header.h_v143.pch /EHsc -DNDEBUG /Y- /sourceDependencies C:\Users\WANGRU~1\AppData\Local\Temp.xmake\241220_1E184F2B5F404C408C47C48AFC7A5690.json -Fobuild.objs\main\windows\x64\release\src\test7.cpp.obj src\test7.cpp

It can be seen that after add_files("src/test7.cpp", {cxflags = "/Y-"}), the compilation of test7.cpp is obviously ranked top2, accounting for 19.2% of the total time, second only to header.h preprocesses the compilation time of the header file. Before adding it, the compilation time of each cpp is evenly distributed.

Therefore, with data verification and confirmation, the current configuration will take effect.

@Issues-translate-bot
Copy link

Bot detected the issue body's language is not English, translate it automatically.


After converting to sln, I checked the corresponding property page of cpp and found that the precompiled header was still used, and the /Y- option was not found in the corresponding command line. The obvious stagnation and slowdown you said may just be a feeling, and it may need to be verified.

Do not use generate sln for verification, that is not supported

@fengjinfuyl fengjinfuyl reopened this Dec 23, 2024
@fengjinfuyl
Copy link
Author

我之前是通过转换成sln后,查看cpp对应属性页,发现还是使用预编译头,且对应的命令行中没找到/Y-选项。你所说明显停滞变慢了可能只是感觉,可能还需要验证下。

不要用 生成 sln 来验证,那个不支持

实测加入了/Y-后,预编译头还是起效了,

add_rules("mode.debug", "mode.release")
set_languages("c++17")
target("pchtest")
    set_kind("binary")
    add_files("src/main.cpp",{force={cxflags="/Y-"}})
    set_pcxxheader("src/pch.h")
// main.cpp
#include <iostream>

#ifdef PCH_TEST
const int a = 0;
#else
const int a = 1;
#endif

int main(int argc, char **argv) {
  std::cout << "a  is " << a << std::endl;
  return 0;
}
#ifndef PCH_H
#define PCH_H

#define PCH_TEST

#endif

下述生成命令中/Y-已经加入

"C:\\Program Files\\Microsoft Visual Studio\\2022\\Enterprise\\VC\\Tools\\MSVC\\14.42.34433\\bin\\HostX64\\x64\\cl.exe" -c -nologo -Zi -FS -Fdbuild\windows\x64\debug\compile.pchtest.pdb -Od -std:c++17 /EHsc -YuE:\Repo\pchtest\build\.gens\pchtest\windows\x64\debug\src\pch.h -FIE:\Repo\pchtest\build\.gens\pchtest\windows\x64\debug\src\pch.h -Fpbuild\.objs\pchtest\windows\x64\debug\gens\src\cxx\pch.h_v143.pch /Y- -Fobuild\.objs\pchtest\windows\x64\debug\src\main.cpp.obj src\main.cpp

然而打印结果,a总为0
image

@Issues-translate-bot
Copy link

Bot detected the issue body's language is not English, translate it automatically.


After converting to sln, I checked the corresponding property page of cpp and found that the precompiled header was still used, and the /Y- option was not found in the corresponding command line. The obvious stagnation and slowdown you said may just be a feeling, and it may need to be verified.

Do not use generate sln for verification, that is not supported

Actual testing shows that after adding /Y-, the precompiled header still works.

add_rules("mode.debug", "mode.release")
set_languages("c++17")
target("pchtest")
    set_kind("binary")
    add_files("src/main.cpp",{force={cxflags="/Y-"}})
    set_pcxxheader("src/pch.h")
// main.cpp
#include <iostream>

#ifdef PCH_TEST
const int a = 0;
#else
const int a = 1;
#endif

int main(int argc, char **argv) {
  std::cout << "a is " << a << std::endl;
  return 0;
}
#ifndef PCH_H
#define PCH_H

#define PCH_TEST

#endif

In the following generation command, /Y- has been added

"C:\\Program Files\\Microsoft Visual Studio\\2022\\Enterprise\\VC\\Tools\\MSVC\\14.42.34433\\bin\\HostX64\\x64\\cl.exe" -c - nologo -Zi -FS -Fdbuild\windows\x64\debug\compile.pchtest.pdb -Od -std:c++17 /EHsc -YuE:\Repo\pchtest\build\.gens\pchtest\windows\x64\debug\src\pch.h -FIE:\Repo\pchtest\build\.gens\pchtest\ windows\x64\debug\src\pch.h -Fpbuild\.objs\pchtest\windows\x64\debug\gens\src\cxx\pch.h_v143.pch /Y- -Fobuild\.objs\pchtest\windows\x64\debug\src\main.cpp.obj src \main.cpp

However, when printing the result, a is always 0
image

@waruqi
Copy link
Member

waruqi commented Dec 24, 2024

/Y- 只是禁止预编译。。force include 还是取消不掉的,不编译预编译头。。但还是会 force include src/pch.h ,你改了 pch.h ,就肯定还是会获取到改动后的 macros value

但预编译确实应该已经禁用了。

@Issues-translate-bot
Copy link

Bot detected the issue body's language is not English, translate it automatically.


Adding /Y- just disables precompilation. . Force include still cannot be canceled and the precompiled header will not be compiled. . But it will still force include src/pch.h. If you change pch.h, you will definitely still get the modified macros value.

But precompilation should indeed be disabled.

@fengjinfuyl
Copy link
Author

fengjinfuyl commented Dec 24, 2024 via email

@waruqi
Copy link
Member

waruqi commented Dec 24, 2024

取消不了,除非你不设置预编译

@Issues-translate-bot
Copy link

Bot detected the issue body's language is not English, translate it automatically.


Cannot be canceled unless you do not set precompilation

@fengjinfuyl
Copy link
Author

fengjinfuyl commented Dec 25, 2024 via email

@waruqi waruqi removed this from the v2.9.8 milestone Dec 25, 2024
@waruqi
Copy link
Member

waruqi commented Dec 25, 2024

短时间内不考虑,没空支持,等后面有空了再说

@Issues-translate-bot
Copy link

Bot detected the issue body's language is not English, translate it automatically.


I won’t consider it in the short term. I don’t have time to support it. I’ll talk about it later when I have time.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants