-
Notifications
You must be signed in to change notification settings - Fork 543
Visual C/C++ compiler support #506
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
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks. So far this looks like small enough changes that we could live for a while longer without a proper compiler abstraction.
I still haven't received any reaction to my questions in #447 (comment) regarding the way forward for ccache on Windows, though. If I just merge this pull request, the state will still be "1. Keep the status quo" (from #447's description). What is your view on that?
cristianadam
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks. So far this looks like small enough changes that we could live for a while longer without a proper compiler frontend abstraction.
I still haven't received any reaction to my questions in #447 (comment) regarding the way forward for ccache on Windows, though. If I just merge this pull request, the state will still be "1. Keep the status quo" (from #447's description). What is your view on that?
Yes, that would be "1. Keep the status quo", and I'll have one less commit in my fork.
At the moment I only run the unittests to test the binaries. But I could add the bash test suite. It should work for all GitHub runners since bash is present on all of them.
[Knowledge level: 5 minutes of DuckDuckGoing.] Do I understand correctly that the above means that
Similarly: Should
Does this mean to write a parser similar to |
|
We are also using ccache for our Linux builds and we do need a solution for MSVC. I've been experimenting for some days now with the similar python based clcache and they also don't support /Yc and /Zi or /ZI. We haven't been using precompiled headers so far, but I switched a group of larger projects from /Zi to /Z7 and I didn't feel any disadvantage so far, so I think it is probably the easiest option to add /Zi, /ZI and /Yc into the TOO_HARD list for a first initial MSVC support. |
|
@cristianadam: Are you still interested in working on this? |
Yes. I will be having some time to work on this next week. |
|
Supporting |
|
As suggested by @jrosdahl I created a pull request cristianadam#1 to suggest updating that branch instead of the pull request running in parallel to this one. The pull request essentially forward-ports the changes from this branch to the current ccache master branch. In addition to that some trivial reformatting is taking place to make the clang-format test happy. |
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
We used to do this on Travis and CodeBuild, let's also port this to GitHub actions. For any CMake builds, ccache will be used automatically if available (as of d953327). For Visual Studio, we'd need ccache/ccache#506 to be merged to use ccache.
We used to do this on Travis and CodeBuild, let's also port this to GitHub actions. For any CMake builds, ccache will be used automatically if available (as of d953327). For Visual Studio, we'd need ccache/ccache#506 to be merged to use ccache. On Ubuntu runners, the build time of a rebuild without source code changes is down to 2 minutes (from 20 minutes).
We used to do this on Travis and CodeBuild, let's also port this to GitHub actions. For any CMake builds, ccache will be used automatically if available (as of d953327). For Visual Studio, we'd need ccache/ccache#506 to be merged to use ccache. On Ubuntu runners and OSX runners, the build time of a rebuild without source code changes is down to under one minute (from 20 minutes).
We used to do this on Travis and CodeBuild, let's also port this to GitHub actions. For any CMake builds, ccache will be used automatically if available (as of d953327). For Visual Studio, we'd need ccache/ccache#506 to be merged to use ccache. On Ubuntu runners and OSX runners, the build time of a rebuild without source code changes is down to under one minute (from 20 minutes).
Updated ccache#506 to current
|
What exactly is still missing for this feature to be integrated? |
|
I've updated the MR on top of the 4.4 release. I've added In order to use ccache with To use is with CMake projects you need to have in your if (MSVC)
foreach(config DEBUG RELWITHDEBINFO)
foreach(lang C CXX)
set(flags_var "CMAKE_${lang}_FLAGS_${config}")
string(REPLACE "/Zi" "/Z7" ${flags_var} "${${flags_var}}")
endforeach()
endforeach()
endif()Now it works with CMake and Ninja generator in Next week I'll be away from keyboard, but when I come back I'll have a look at the missing items. |
If I decide to merge MSVC support before #956, I think you can leave the current PR mostly as is and then we'll apply follow-up fixes separately. |
|
@jrosdahl wrote:
It was not meant to be harsh. With 'genarally' I wanted to say that with the msvc build the cached outputs always create two newlines, not only when cl is used. |
The important stuff (A level support code) comes with a test suite, so this PR breaking anything else is unlikely, and if it does then that's primarily responsibility of that existing test suite. As for this PR not having tests, well, that's why it's B level, and it can change (and it's more likely to change if it's not made hard by hold this to the same standards as the existing A level code). Going from no MSVC support to MSVC support that maybe doesn't work in some cases is no regression. And in case you misssed it in #447 , I've built pretty much the entire LibreOffice including its bunch of 3rd-party libraries with PR plus my fixes on top.
I thought the idea of B level was that you do not have to maintain support for it. Otherwise what's the point of the B level if there's no actual difference?
MSVS has a community edition that is no less free than nvcc or icc. And you can test this on Linux too if you really want to, either clang-cl works anywhere where clang does (although it may need MS SDK headers, https://jake-shadle.github.io/xwin/) or apparently it's possible to use MSVC with Wine (https://github.com/mstorsjo/msvc-wine).
#956 may make some things cleaner, but it's not blocking for this. 'wc -l src/cache/*' is ~15kLOC and MSVC support is what, 300 out of that maybe? As for messiness, this PR has 8 compiler type checks and my latest source 13, and they are usually simple if blocks. For comparison, master has already ~20 compile_type checks. So it's not like this PR makes it way worse.
You're the maintainer. I just hope you do realize that both asking people to take care of something and making it hard at the same time doesn't really work.
Works for me. @cristianadam @rvogg : The only two actually unresolved issues in this PR are the @ file support (and even that is IMO hardly a blocker). Does either of you have (plans for) a follow-up commit to handle that? |
This MR support @file with the CMake's "NMakefile Generator", and in my test it compiled fine. I haven't tested arguments with spaces, the only example I can think of would be a directory with spaces in it, source fiels with spaces are not very common. I see this as a bug fix for later, than a requirement of having this MR accepted. I can have a look at this case, sure. |
That is ok for me, I've already prepared the changes: cristianadam#3, but I can also make a new pull request here. |
llunak
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As far as I can tell all the pointed out problems here have been fixed in #954 and cristianadam#3 , so from the technical side of things this PR should be ready.
I picked only the compiler commits from: ccache#162 The following commits I've adapted to the latest ccache C++ code: 375fe24: Add compiler_is_msvc() and MSVC specific option table. 7e01763: Add handling of /Fo option (replaces -o, but shall have no space) 0c5cd25: Manage /E, /c equivalence. -g is gcc only. -O or /O is msvc only. 4f61b59: MSVC send part of the error/warning messages to STDOUT, so concat wit… 64449d6: use common code for gcc an cl response files.
|
@llunak wrote:
Please don't try to trivialize my concerns like this. That is very demotivating for me.
It's exactly like this PR makes it worse, but only a bit. Yes, just adding a little more messiness just adds a little more messiness, but you can't keep doing that over and over again even if each addition just makes things slightly messier. |
|
I'll merge this after 4.5 is released, which I hope to be able to do in a couple of days. |
Sorry. I didn't know 4.5 was meant to be out soon, so your comments here made it look to me like you were planning to postpone this PR for a long time after some rewrites that could possibly lead to all this needing to be rewritten all over again.
I think it might make sense to keep a list of things needed for MSVC support, such as adding tests for this, so that we can sort all that out and not step on each others toes. I don't know where it'd be a good place to keep it, separate issues, wiki page or something else? |
|
Thanks. |
Thank you! |
|
Congrats on the merge. Will this be upgrading MSVC to a B on the supported compilers page? |
Yes (as already indicated on said page). |
|
I would very much like to see this |
|
qmake is using something like this for precompiled headers: And cmake this: |
|
The thing is that msvc's pch model is different from gcc's (better actually). They use a dummy source file and also produce an .obj file with code and debug info in addition to the pch file. |
|
This is not good news if it is as you write, if msvc creates .obj for PCH in a different format than gcc so it means a new or customized caching logic will have to be created which doesn't exist now, which means more work. Build cache for dev. is really missing on msvc I have searched and didn't find anything working correctly. |
|
gcc doesn't produce code, only a .pch. Clang can be made to generate an .obj cause they need that for clang++ -x c++-header header.h -o header.pch -fpch-codegen -fpch-debuginfo
clang++ -c header.pch -o shared.o |
|
Thank you for this. This cuts the github action time for our Windows CI more than in half in a 'perfect hit rate' situation, from a typical runtime of ~1:15 to about 25 minutes (15 minutes fixed cost to execute tests, 1 hour of setup + build time down to 10 minutes). Many PRs don't change any c++ code so will see maximum benefit from this. That even includes folding a separate job into the same job to reuse build artifacts, so freeing up a whole runner slot per PR. |
I picked only the compiler commits from: #162
The following commits I've adapted to the latest ccache C++ code:
375fe24: Add compiler_is_msvc() and MSVC specific option table.
7e01763: Add handling of /Fo option (replaces -o, but shall have no
space)
0c5cd25: Manage /E, /c equivalence. -g is gcc only. -O or /O is msvc
only.
4f61b59: MSVC send part of the error/warning messages to STDOUT, so
concat wit…
64449d6: use common code for gcc an cl response files.
I have tested this with CMake using the Ninja generator in Release mode. It seems to work good enough for having it in GitHub actions for Qt Creator.
/Z7flag)Fixes: #431