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

Enforce minimum supported versions of GCC and Clang #10969

Merged
merged 2 commits into from May 1, 2023

Conversation

phire
Copy link
Member

@phire phire commented Aug 10, 2022

With the move to C++20, and various people wanting to clean up the codebase to use the fancy new features, many PRs have run into problems older versions of clang running on buildbots.

It would be very helpful to actually define and enforce a minimum version of Clang/GCC so that it's clear what C++20 features contributors are allowed to use. Additionally... enforcing it in cmake gives users clear feedback about what's wrong before they even start, instead of random compile errors.

We already have an explicit minimum required version of Visual Studio, so it's not too outrageous. And various implicit minimum requirements on other versions.

Why not feature detection?

That doesn't really answer the question of "what C++20 features are we allowed to use", contributors would have to remember to add feature detection when using new C++20 features, and we would end up implicitly dropping support for versions of compilers without realising it.

What versions?

I've chosen Clang 11 as a minimum because that's the version in the latest stable release of FreeBSD. And we have a FreeBSD builder (which currently all the way back on Clang 6, released March 2018, so no wonder it's been unhappy about new C++20 syntax). It's also the minimum for (partial) support of consteval.

And GCC 10 seems to be roughly equivalent. Also the minimum for consteval. Both were released in 2020.

@phire
Copy link
Member Author

phire commented Aug 10, 2022

@endrift are you happy updating the freebsd builder to FreeBSD 13.0 or 13.1?

Or should we do something different?

@endrift
Copy link
Contributor

endrift commented Aug 10, 2022

Yeah, lemme do that in a bit. Might be a little tricky but I'll try.

Contributing.md Outdated Show resolved Hide resolved
@phire
Copy link
Member Author

phire commented Aug 10, 2022

For the GCC version, there is an argument to be made that since we don't have a GCC 10.x builder, that we should skip over it and just require the GCC 11.x that our ubuntu uses.

I'm not sure how much extra distro compatibility GCC 10.x gains us.

  • Ubuntu's releases skips straight from gcc 9 to gcc 11
  • Debian's latest stable release is on gcc 10 (our Debian builders use clang)
  • Fedora is uses gcc 11 on their oldest still supported release.

@phire
Copy link
Member Author

phire commented Aug 10, 2022

FreeBSD apparently updated to Clang 13 with the 13.1 release and didn't mention it in their release notes. But I think we should stick with clang 11 and GCC 10 as our minimums for now (especially with stable Debian still on GCC 10)

The FreeBSD buildbot has been updated to 13.1

@phire phire changed the title [RFC] Enforce minimum supported versions of GCC and Clang Enforce minimum supported versions of GCC and Clang Aug 10, 2022
@OatmealDome
Copy link
Member

The latest steamrt used for games (version 1, 'scout') only has gcc-9, which is annoying. It might be possible to just install a newer gcc if we set up a steamrt build worker in the future.

This isn't something we have to worry about right now, anyway.

@phire
Copy link
Member Author

phire commented Aug 10, 2022

Compiler shouldn't be a huge issue. It's a runtime, not a build-time. We don't want to be restrained to the compiler version it uses anyway.

However.... that might put some strain on our minimum libstdc++ version. That's a way less fixable problem.
Even if we do nothing else, we might want to set up a builder targeting scout now so that we will get errors if people try to use c++20 library features that it doesn't support.

Contributing.md Outdated Show resolved Hide resolved
@Minty-Meeo
Copy link
Contributor

After the minimum GCC version is increased, I have seen a couple of comments around the codebase that can be addressed by this, such as in ShaderGenCommon.h:

  // The second template argument is needed to avoid compile errors from ambiguity with multiple
  // enums with the same number of members in GCC prior to 8.  See https://godbolt.org/z/xcKaW1seW
  // and https://godbolt.org/z/hz7Yqq1P5

@AdmiralCurtiss
Copy link
Contributor

So what's the status here?

@Minty-Meeo
Copy link
Contributor

GCC 11 begins GCC's (partial) support for modules. Whether Dolphin Emulator should or should not begin using modules yet is open for debate. I personally want to begin experimenting with modules in the Common namespace in the near future.

@Zopolis4
Copy link
Contributor

I think GCC 12 is what I'd need for #11057, not sure about clang.

@Minty-Meeo
Copy link
Contributor

Oh dang, you beat me to it! Well best of luck to you, then.

@phire
Copy link
Member Author

phire commented Sep 13, 2022

Personally, I'm a little uneasy about pushing to gcc 12. Debian stable is only shipping with gcc 10.

@Zopolis4
Copy link
Contributor

Zopolis4 commented Sep 18, 2022

I suppose we can merge this PR as is, then I can raise the minimum required versions in #11057.

@OatmealDome
Copy link
Member

OatmealDome commented Sep 22, 2022

FYI, Valve has given us access to the ability to use a newer steam-runtime ("sniper", based on Debian 11), so Linux builds for Steam are no longer a problem.

CMakeLists.txt Outdated Show resolved Hide resolved
@AdmiralCurtiss
Copy link
Contributor

I'll ask again, what's the hold up here?

@Minty-Meeo
Copy link
Contributor

I think there is a desire for a Steam Deck buildbot. Also, Android's buildbot still has an outdated stdlib, lacking <concepts> last I checked and also std::bit_cast (though it is not alone in that second one). I would also appreciate an update on this.

@OatmealDome
Copy link
Member

The Steam Linux runtime is no longer a blocker for this. We've been given access by Valve to a newer version that is based off Debian 11.

@JosJuice
Copy link
Member

Also, Android's buildbot still has an outdated stdlib, lacking last I checked and also std::bit_cast (though it is not alone in that second one).

The Android buildbot automatically fetches whatever SDK version is specified in the dolphin git repo. Though I suspect that not even the latest Android SDK has a recent enough stdlib for this...

@Minty-Meeo
Copy link
Contributor

It is pretty simple to create a "Future" header for std::bit_cast thanks to how old the compiler built-in is for the three major compilers. See: #11153. This has also been how I worked around <concepts> being MIA for Android. IMO, this is the way forward until every supported platform gets up to speed with C++20.

@Minty-Meeo
Copy link
Contributor

What is the prerequisite or milestone this PR is waiting on? Are we using C++20 or not? I'm sorry if this has already been answered in the IRC; I do not have anything set up to see what has been said while I am away.

@CasualPokePlayer
Copy link
Contributor

CasualPokePlayer commented Feb 19, 2023

Under the current Dolphin master (45b55f7), it seems GCC 10 or Clang 12 (or Apple Clang 13, as reported by Dentomologist on IRC) is required to build Dolphin. GCC 10 got required since 02a967f and Clang 12 (/Apple Clang 13) got required since 154cb4f (Clang 11 and back get unhappy about the template deduction here).

CMakeLists.txt Outdated Show resolved Hide resolved
CMakeLists.txt Outdated

# Enforce minimium compiler versions that support the c++20 features we use
set (GCC_min_version 10)
set (Clang_min_version 11)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As I noted here, Dolphin ends up requiring a newer Clang than this, due to 154cb4f. See "Class types in non-type template parameters" in https://en.cppreference.com/w/cpp/compiler_support.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok, I've bumped it to Clang 12 (Apple Clang 13)

We already have a minimum required version of MSVC
@phire
Copy link
Member Author

phire commented Feb 23, 2023

Ok, I think I've addressed all review feedback.

set (Clang_min_version 12)
set (AppleClang_min_version 13.0.0)
set (min_xcode_version "13.0") # corrosponding xcode version for AppleClang_min_version
set (MSVC_min_version 14.32)
Copy link
Contributor

@shuffle2 shuffle2 Feb 26, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i'd rather just keep this in pch.h (for msvc) so it's not needed to be updated in multiple places. these values are already not in sync with pch.h

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmm... but the inverse also results in having versioning for different compilers split over different places.

I guess we can move it back when we deprecate the visual studio solutions.

@OatmealDome
Copy link
Member

What's the status on this?

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