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

remove -Zi from MSVC compiler options #3291

Merged
merged 1 commit into from
Mar 16, 2021
Merged

Conversation

Be-ing
Copy link
Contributor

@Be-ing Be-ing commented Feb 26, 2021

This is incompatible with compiler caches such as sccache and
clcache. If a project including Google Test specifies /Z7 instead,
building fails with:

sccache C:\PROGRA~2\MICROS~1\2019\ENTERP~1\VC\Tools\MSVC\1428~1.293\bin\Hostx64\x64\cl.exe  /nologo /TP -D__SSE2__ -D__SSE__ -I..\lib\googletest-1.10.x\googlemock\include -I..\lib\googletest-1.10.x\googlemock -I..\lib\googletest-1.10.x\googletest\include -I..\lib\googletest-1.10.x\googletest /DWIN32 /D_WINDOWS /W4 /GR  /MD /Z7 /O2 /Ob1 /DNDEBUG -GS -W4 -WX -wd4251 -wd4275 -nologo -J -Zi -D_UNICODE -DUNICODE -DWIN32 -D_WIN32 -DSTRICT -DWIN32_LEAN_AND_MEAN -wd4702 -DGTEST_HAS_PTHREAD=0 -EHsc -D_HAS_EXCEPTIONS=1  /Gy /showIncludes /Folib\googletest-1.10.x\googlemock\CMakeFiles\gmock_main.dir\src\gmock-all.cc.obj /Fdbin\gmock_main.pdb /FS -c ..\lib\googletest-1.10.x\googlemock\src\gmock-all.cc
FAILED: lib/googletest-1.10.x/googlemock/CMakeFiles/gmock_main.dir/src/gmock-all.cc.obj
..\lib\googletest-1.10.x\googletest\src\gtest-all.cc: fatal error C1041: cannot open program database 'D:\a\mixxx\mixxx\build\bin\gmock_main.pdb'; if multiple CL.EXE write to the same .PDB file, please use /FS
cl : Command line warning D9025 : overriding '/Z7' with '/Zi'

This is incompatible with compiler caches such as sccache and
clcache. If a project including Google Test specifies /Z7 instead,
building fails with:

sccache C:\PROGRA~2\MICROS~1\2019\ENTERP~1\VC\Tools\MSVC\1428~1.293\bin\Hostx64\x64\cl.exe  /nologo /TP -D__SSE2__ -D__SSE__ -I..\lib\googletest-1.10.x\googlemock\include -I..\lib\googletest-1.10.x\googlemock -I..\lib\googletest-1.10.x\googletest\include -I..\lib\googletest-1.10.x\googletest /DWIN32 /D_WINDOWS /W4 /GR  /MD /Z7 /O2 /Ob1 /DNDEBUG -GS -W4 -WX -wd4251 -wd4275 -nologo -J -Zi -D_UNICODE -DUNICODE -DWIN32 -D_WIN32 -DSTRICT -DWIN32_LEAN_AND_MEAN -wd4702 -DGTEST_HAS_PTHREAD=0 -EHsc -D_HAS_EXCEPTIONS=1  /Gy /showIncludes /Folib\googletest-1.10.x\googlemock\CMakeFiles\gmock_main.dir\src\gmock-all.cc.obj /Fdbin\gmock_main.pdb /FS -c ..\lib\googletest-1.10.x\googlemock\src\gmock-all.cc
FAILED: lib/googletest-1.10.x/googlemock/CMakeFiles/gmock_main.dir/src/gmock-all.cc.obj
..\lib\googletest-1.10.x\googletest\src\gtest-all.cc: fatal error C1041: cannot open program database 'D:\a\mixxx\mixxx\build\bin\gmock_main.pdb'; if multiple CL.EXE write to the same .PDB file, please use /FS
cl : Command line warning D9025 : overriding '/Z7' with '/Zi'
@google-cla
Copy link

google-cla bot commented Feb 26, 2021

Thanks for your pull request. It looks like this may be your first contribution to a Google open source project (if not, look below for help). Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA).

📝 Please visit https://cla.developers.google.com/ to sign.

Once you've signed (or fixed any issues), please reply here with @googlebot I signed it! and we'll verify it.


What to do if you already signed the CLA

Individual signers
Corporate signers

ℹ️ Googlers: Go here for more info.

@google-cla google-cla bot added the cla: no label Feb 26, 2021
@Be-ing
Copy link
Contributor Author

Be-ing commented Feb 26, 2021

@googlebot I signed it!

@google-cla google-cla bot added cla: yes and removed cla: no labels Feb 26, 2021
Be-ing added a commit to Be-ing/mixxx that referenced this pull request Feb 26, 2021
Be-ing added a commit to Be-ing/mixxx that referenced this pull request Feb 26, 2021
Be-ing added a commit to Be-ing/mixxx that referenced this pull request Feb 26, 2021
Be-ing added a commit to Be-ing/mixxx that referenced this pull request Feb 26, 2021
@pmisik
Copy link

pmisik commented Feb 26, 2021

For most Windows people it may look weird why not use default -Zi and use -Z7 rather.
-Zi cause that symbols - pdb are generated during link stage by mspdbsrv.exe service started on demand.
If you compile single project it is worth optimization Microsoft done.
When you are CI guy building hunderts projects in parallel you'll face very frequent crashes of mspdbsrv due to out of memory (especially in cases using Default VCToolsets -settings).
-Z7 cause compiler generates symbols data into .obj (objs are bigger) and linker just merge them. In optimal cases (you don't need link masm [not having support for /Z7] you should be able avoid interaction of mspdbsrv).
This will improve builds reliability.

Disclaimer:
I don't use cmake. So I'm not sure change is ok.
I work in team use msbuild intensively.
I just added comment why request is really worth to consider.
If you build in parallel on NUMA machines -Z7 may improve throughput as it has opportunity eliminate FSB saturation.

@Be-ing
Copy link
Contributor Author

Be-ing commented Feb 26, 2021

I don't think a project designed to be built into other projects should be setting any choice of how the debugging info is handled.

@Be-ing
Copy link
Contributor Author

Be-ing commented Feb 26, 2021

For me the pros and cons of /Zi versus /Z7 are pretty much irrelevant. /Zi doesn't work with compiler caches, therefore I can't use it.

@derekmauro derekmauro self-assigned this Mar 1, 2021
@asoffer asoffer merged commit b7d472f into google:master Mar 16, 2021
@Be-ing Be-ing deleted the remove_zi_msvc branch March 16, 2021 14:37
@Be-ing
Copy link
Contributor Author

Be-ing commented Mar 16, 2021

Thank you for merging.

compnerd added a commit to compnerd/swift-build that referenced this pull request Nov 10, 2023
With sccache enabled, we cannot use `/Zi` as it causes weird
interactions for `mspdbsrv`
(c.f. google/googletest#3291).
hyp pushed a commit to hyp/swift-build that referenced this pull request Dec 20, 2023
With sccache enabled, we cannot use `/Zi` as it causes weird
interactions for `mspdbsrv`
(c.f. google/googletest#3291).
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants