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
Update to Catch2 v2.13.7 #1898
Update to Catch2 v2.13.7 #1898
Conversation
This new Catch.h file has about 6000 more lines of code. It appears that one of the jobs is choking on this. One way to reduce file size is to replace the single header version of Catch2 with the project itself so we can use its include(FetchContent)
FetchContent_Declare(Catch2
GIT_REPOSITORY "https://github.com/catchorg/Catch2.git"
GIT_TAG v2.13.7)
FetchContent_MakeAvailable(Catch2) |
4745fa2
to
0ae124f
Compare
There's also the option to add -bigobj (or /bigobj for MSVC) |
Incidentally, have you measured compile times before and after the Catch2 update? |
Here's some build time data from my M1 MacBook Pro. I'm using Makefiles as the build system. Only debug builds since I don't want optimizer speed being factored in. All build products are wiped between runs. Timing done with As of these tests, my branch is commit 0ae124f and the master branch is at commit db38696. I'm configuring the project with:
I just had the idea to bisect this problem and found that the problem begins with d0ebdc8 which happens to affect how CMake handles macOS architectures. I agree that Pawel's commit is the correct thing to do. I suppose it had a knock-on effect of breaking how we build that old version of Catch2. I still think updating Catch2 is the right course of action. |
I'm not 100% certain, but the "effect" is that before you might have been building for x64 and now are building for arm64 or even both architectures. What if you explicitly set the OSX architecture in both cases to the same architecture? Either way, the potential discussion that comes from these comparisons are only helpful in a limited way, because slightly longer build times should not be the deciding factor of whether to upgrade the testing framework or not... 😉 |
Counter-proposal: maybe we should consider doctest instead, it seems to be extremely lightweight on compilation times. Catch2 seems overkill for our testing needs. I have used both in the past and found myself preferring doctest because of its faster compilation. |
@ChrisThrasher Thanks a lot! 🙂
The difference is not slight, but huge (build time increased by 40% and 125%). But let's ask ourselves this way: what does this new version offer for us? I don't want to be always the skeptic, but upgrading with such a considerable disadvantage should be double-checked. It will also affect CI negatively. Maybe it's possible to disable features we don't need or something? |
@eXpl0it3r I tried the following configuration but the build still failed on master for the same reason as before. I also tried
@Bromeon we don't yet know that. Because the master branch fails to compile on M1 Macs with tests enabled, its build necessarily returns sooner than if all targets got built. I'm sure compilation time has increased, but we have no reliable metrics for by how much. Besides, we're talking about tests, not the core library's compilation time increasing.
The fact that it lets more developers build and run tests is quite valuable in my opinion. The prevalence of ARM Macs will only increase as Intel Macs get phased out. I believe the oldest Catch2 release we can use is v2.12.4 which means sticking to our 1.x release of Catch2 has limited long-term viability. |
I would be happy to merge this PR to restore testing on M1 macs, and then create a PR to replace Catch2 with doctest for much faster compilation times |
Catch2 version 3 is around the corner which changes their header-only library model into a more conventional library with many .cpp files. This drastically reduces compile times by allowing much of Catch2 to be compiled in parallel and also not have to be recompiled when your test code changes since the new headers will be much smaller. v3 has been in the works for a few years so I'm hopeful it lands in early 2022 so we can take advantage of it soon. |
...or we could take advantage of doctest today :) |
I can compile the master branch with tests if I crosscompile to x86_64 which I am now learning is a thing I can do. The unit tests will still run. I suppose Rosetta 2 is taking care of the translation for me but I digress. Here are updated compile time stats now with both builds actually completing and succeeding. This time I will subtract the time to run unit tests since I don't want those factoring in.
We're looking at ~10% compile time increases when tests are enabled. These marginal increases are not to be ignored, but I don't think this increase is big enough to warrant sticking to Catch 1.x. |
FYI, I'm looking into the macOS x86_64 (Intel) build failure. Might just need some update... For MinGW, we might consider adding |
While outside the scope of this PR, I wanted to share one way we could entirely remove Catch2's sources from SFML. I've had a lot of success using FetchContent to download CMake projects and add them to the build tree. FetchContent gives us access to a project's CMake target that we can link against instead of relying on their single-header distribution. This may alleviate our MSVC Because Catch2 is a non-transitive dependency and because it's only downloaded when tests are explicitly enabled, it's safe to add this dependency on a network connection without breaking anyone's workflow. It won't even require we raise the minimum CMake requirement project-wide. |
@eXpl0it3r Looks like the issue is with macOS 10.11 not yet supporting C++17's https://github.com/catchorg/Catch2/blob/v2.13.7/docs/configuration.md#c17-toggles Maybe we enable this for all builds to appease the macOS 10.11 build? I'm not sure if El Capitan is viable to support if its C++17 support is limited. I wonder if we'll run into more similar issues as C++17 is used more pervasively. |
0ae124f
to
c3dab64
Compare
I personally, I have nothing against FetchContent, especially if it's limited to the test only and would prevent us from adding additional compiler flags.
Well, that's the fun about it. The Mac Mini is actually already running Big Sur... |
d21d33c
to
6bfed1d
Compare
I think, I've figured out why macOS is failing, because we set the minimum SDK version to 10.11 in the Buildbot Script: https://github.com/SFML/SFML-Buildbot/blob/master/buildfactories.py#L57 Will check tomorrow to get this updated. |
6bfed1d
to
183260b
Compare
29e3e97
to
d37f5cd
Compare
I'm glad you liked those extra commits! I added those changes into this branch. Now, the first commit removes the extra compilations of CatchMain.cpp and the second adds FetchContent to grab Catch2 v2.13.7. I removed the diffs that modified catch.hpp so that there wouldn't be tens of thousands of extra lines changed in this PR just to get to the same result. Now that file simply gets removed instead of modified. |
As you wish. I could also just merge #1916 before this PR, then you can merge |
We do have small atomic changes in the form of two small, atomic commits. I can't think of any sensible way to divide these 2 commits into more granular atomic changes. Putting both in one PR speeds things up by not making us wait so long for more pipelines to be approved and run. You're always welcome to cherry pick the first commit into the trunk branch though. |
If you re-open #1916 I'll be able to review and approve it -- our workflow doesn't really endorse merging directly into |
a66d54d
to
acaf668
Compare
Looks like we still need |
Can you try to add the linker (or compiler?) option |
acaf668
to
968b933
Compare
Are all CI config settings stored within the repo or are there some CI jobs whose configuration is not version controlled? |
968b933
to
4bbc1ea
Compare
This wouldn't be a change to the CI config, because it would affect any/all MinGW installations, thus it would need to be in SFML's CMake for the test build. Let's first see however, how the FetchContent part works out. 🙂 |
4bbc1ea
to
10adeae
Compare
The key benefit here is that now we're linking against their CMake target which makes it easy to change how we depend on Catch2. We can switch from FetchContent to FindPackage to a git submodule and never have to change our code because we're depending on Catch2 in the most flexible way possible.
c39ea69
to
38b3d9d
Compare
The MinGW builds succeeded! A Window job was failing on an OpenGL example. I saw Vittorio fixed that so I rebased this branch to include that commit. I expect the whole pipeline to pass after this. |
We finally have a successful CI pipeline! |
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.
Finally the CI passes 🎉
Thanks for the continued effort in getting the CI to accept the change! 😄 |
Description
Update to the latest release of Catch2, version 2.13.7. Downloaded from here. The previous version was Catch v1.12.2 from May 2018 so this is a fairly big leap into the present.
This PR is related to the issue #1897
Tasks
How to test this PR?
Build tests before and after with macOS to observe the compilation error being fixed.