-
Notifications
You must be signed in to change notification settings - Fork 1.8k
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
[entt] Tool check_min_cppstd already validates default 'cppstd' values #3840
Merged
Merged
Changes from 4 commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
a3fb476
simplify min cppstd check
jgsogo 4c369fe
use VisualStudio 15 as base reference
jgsogo 7ee396e
assume minor version satisfies
jgsogo f618a70
Update recipes/entt/3.x.x/conanfile.py
jgsogo 761799e
remove opinionated fixme, cast to int
jgsogo File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
Why this comment by the way? All CCI recipes requiring at least C++14 have this kind of pattern.
Do you mean that in future conan version, a profile without
compiler.cppstd=17
(or higher) won't be able to consume or build a library requiring at least C++17, so we won't be able to mix different standard in the dependency graph?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.
The C++ standard should be known by Conan in order to select the proper binary. Once we start to generate here binaries for stable C++ standards, recipes might look like the following:
So, a profile without
compiler.cppstd
will be suitable to consume this library if the default for the compiler is at least C++11, but only a profile with explicitcompiler.cppstd=17
orcompiler.cppstd=20
will be able to generate this library.Behind the scenes, Conan keeps the exception raises by the
check_min_cppstd
and only raise it if the command is trying to build the library, otherwise this package remains in the graph withpackage_id = INVALID
(that would be the output forconan info
command), and it will fall back to the compatible package if we need a binary to install.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.
With this implementation, you can mix binaries from different C++ standards because they are declared compatible not just because a hidden
CXX_STANDARD 17
in theCMakeLists.txt
was able to generate the binary. I think it is preferred to make it explicit.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.
And if default standard of a compiler version is lower than the minimum standard required by the library, but still supports enough features of this standard for this library? Will it work if standard is not explicitly set in profile?
Moreover, AFAIK
tools.check_min_cppstd(self, "17")
raises if standard is not set in profile, so it requires modifications in this function.What happen if a consumer tries to build from source with an unsupported compiler? Currently, it gracefully fails, while with this implementation it will fail at some point during build()
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.
We cannot handle this situation, if the recipe says
tools.check_min_cppstd(self, "17")
it will fail if the compiler doesn`t implement that standard (if it is declared stable). If it only needs some features that are available in previous versions, the recipe will need some handcrafted checks... but I would try to avoid them as much as possible (in my 🦄 world).No, it doesn't (https://github.com/conan-io/conan/blob/develop/conans/client/tools/settings.py#L5). You saying that is a symptom of the workaround we are using in the recipe to bypass the fact that ConanCenter is not trying any profile with C++14/17/20 support.
It will fail gracefully, have a look at the docs about
validate()
function: https://docs.conan.io/en/latest/reference/conanfile/methods.html?highlight=validate#validateThere 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.
Correct, but if
compiler.cppstd
is not set in profile,tools.check_min_cppstd
raises if default standard -as estimated by conan- is not sufficient.https://github.com/conan-io/conan/blob/61d75d945a0e16a56a320926789cff2d297ac76a/conans/client/tools/settings.py#L50
https://github.com/conan-io/conan/blob/61d75d945a0e16a56a320926789cff2d297ac76a/conans/client/build/cppstd_flags.py#L50
Currently,
tools.check_min_cppstd(self, 17)
raises with all versions of Visual Studio -even Visual Studio 2019- ifcompiler.cppstd
is not set.https://github.com/conan-io/conan/blob/61d75d945a0e16a56a320926789cff2d297ac76a/conans/client/build/cppstd_flags.py#L78
I believe that, if your first answer in the previous message was implemented as is in CCI recipes, it would break a lot of them (a lot of C++11 recipes work with gcc 4.9/5, while C++11 is not the default standard of those versions).
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.
If
compiler.cppstd
is not set in the profile it will fail to build, yes. And it is right because the recipe says C++17 is required and those compilers don't enable C++17 support by default. Activating the standard in theCMakeLists.txt
file is something to avoid, it is hiding changes in the ABI from the package manager.But, by adding the
compatible_packages
feature, Conan will be able to retrieve a compatible binary that was compiled with an explicitcompiler.cppstd
value when using a profile without it.As they are now, those recipes are wrong (because of c3i profiles), they are activating C++11 inside the
CMakeLists.txt
, and some of the header-only ones are activating it inside thetest_package/CMakeLists.txt
(if you add them to your graph, Conan retrieves a package and then your consumer fails to compile without further notice). If you modify those recipes as the draft in the first commit they will fail to build if you do not provide a compatible configuration in the profile (nothing hidden) but you still can consume them with a lower C++ standard if the API is compatible and the binary is available (it was compiled with a higher C++ standard).Maybe this requires a written example
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.
I strongly disagree.
It's not wrong to activate C++11/14/17 in CMakeLists.txt, it's what all C++11/14/17 libraries in the world do. I don't understand your point. It fails in test_package if C++ standard is not set, because conan doesn't provide a way (or if it does, nobody use it in CCI recipes) to easily propage this information in generators.
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.
I've written an example with a (opinionated) dramatization here: conan-io/examples#73. I know every library activates the C++ standard in the
CMakeLists.txt
but IMHO it is not the best place to do it. We can move this conversation there (or to another repository) with an example, it is easier for me to show what I want to show.I will remove the comment in this recipe as this is something we cannot fix right now, but I really think user experience and ConanCenter would benefit from that approach. Please have a look at the recipes in that PR. Thanks!
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.
Ok thanks, I'll take a look ;)