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

[check] CMake, as a tool-only package, doesn't need compiler or build_type settings #3153

Closed
wants to merge 5 commits into from

Conversation

jgsogo
Copy link
Contributor

@jgsogo jgsogo commented Oct 9, 2020

Specify library name and version: cmake/all

Packages that act only as tools (do not contain libraries or they are not currently used) can remove compiler and build_type settings and generate less packages. C3i generates the profiles in order taking into account some rules: Release builds first (minimize problem with VS redistributables), older compilers first (avoid issue with docker images and glibc).

Let's double-check if the promise fulfills.

@SpaceIm
Copy link
Contributor

SpaceIm commented Oct 9, 2020

Could it be worth opening an issue listing all "tools only" packages and their current settings? It's not really consistent currently.

@conan-center-bot
Copy link
Collaborator

All green in build 1 (78a0187371c828fc4d093d703b434c0e4274fe03)! 😊

@jgsogo
Copy link
Contributor Author

jgsogo commented Oct 9, 2020

Having a look to profiles:

Linux (package-ID: 3be0335ecbcae34c1eca15767d4672128da755cf)

[settings]
arch=x86_64
arch_build=x86_64
build_type=Release
compiler=gcc
compiler.libcxx=libstdc++
compiler.version=4.9
os=Linux
os_build=Linux

MacOS (package-ID: 7472a0907e34e17166c741496858d22be213d903)

[settings]
arch=x86_64
arch_build=x86_64
build_type=Release
compiler=apple-clang
compiler.libcxx=libc++
compiler.version=9.1
os=Macos
os_build=Macos

Windows (package-ID: ca33edce272a279b24f87dc0d4cf5bbdcffbc187)

[settings]
arch=x86_64
arch_build=x86_64
build_type=Release
compiler=Visual Studio
compiler.runtime=MT
compiler.version=14
os=Windows
os_build=Windows

These packages, when used as build-requires, should have max-compatibility. They should work on any docker image we are using in the CI.

... and it only took 2 hours to build 🙄

ping @uilianries @SSE4 @danimtb

danimtb
danimtb previously approved these changes Oct 9, 2020
uilianries
uilianries previously approved these changes Oct 9, 2020
Copy link
Member

@uilianries uilianries left a comment

Choose a reason for hiding this comment

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

LGTM

@Croydon
Copy link
Contributor

Croydon commented Oct 9, 2020

Interesting situation: Does the bot merge PRs which passed all checks but are still marked as drafts or does it check the status before?

LGTM too

@jgsogo
Copy link
Contributor Author

jgsogo commented Oct 9, 2020

Interesting situation: Does the bot merge PRs which passed all checks but are still marked as drafts or does it check the status before?

It only considers those not in draft mode.

Croydon
Croydon previously approved these changes Oct 9, 2020
@madebr
Copy link
Contributor

madebr commented Oct 9, 2020

This is not correct.
Compare the following logs:

Compare the calls to cmake.build().

cmake --build C:\J\w\cci_PR-3153\.conan\data\cmake\3.16.2\_\_\build\ca33edce272a279b24f87dc0d4cf5bbdcffbc187

versus

C:\J\w\cci_PR-3109@5\.conan\data\cmake\3.18.2\_\_\build\6cc50b139b9c3d27b3e9042d5f5372d327b3a9f7 --config Release -- /m:1 /verbosity:minimal

We need to keep compiler/build_type in settings, because otherwise we depend on the default of compilers/cmake script.

Imho we should tag tools-only recipes and only build Release+MT configurations for them instead of butchering the recipe.

@jgsogo
Copy link
Contributor Author

jgsogo commented Oct 9, 2020

Yes, we need full settings: os, arch, compiler and build_type, and then remove compiler and build_type from the package_id. Why? We want to generate fewer packages in C3i and it also demonstrates how Conan works with it. Keep all the settings is needed too so the consumer can force a build for other configurations if desired.

@madebr
Copy link
Contributor

madebr commented Oct 9, 2020

@jgsogo
I would combine #2813 with this.
It is sometimes useful to have both a release and debug version of a package available.

Using #2813, you can tell c3i to only build certain configurations.

@jgsogo jgsogo dismissed stale reviews from Croydon, uilianries, and danimtb via e77551b October 10, 2020 11:19
@conan-center-bot
Copy link
Collaborator

All green in build 2 (e77551bac3de4edf8ffcdd12f5d491bde9032759)! 😊

@jgsogo
Copy link
Contributor Author

jgsogo commented Oct 13, 2020

After #2941, to consider build_type in package ID

@conan-center-bot
Copy link
Collaborator

All green in build 3 (e77551bac3de4edf8ffcdd12f5d491bde9032759)! 😊

@Croydon
Copy link
Contributor

Croydon commented Oct 13, 2020

Just to explain my change in the other PR: I was thinking that excluding the compiler is rather uncontroversial for an installer package like CMake

As @madebr mentioned there might be cases where it would be annoying to exclude the build_type, like switching often between debug and release

When I sometimes used Clion it was often configured to compile both build_types in this case Conan would compile/overwrite the package all the time I guess

@jgsogo
Copy link
Contributor Author

jgsogo commented Oct 13, 2020

We agree (inside the team) that installers shouldn't include compiler or build_type in the packageID, but for sure we didn't take into account every possible scenario. I've opened this PR and it is in draft mode exactly for that purpose, to know what you think about these changes.

Removing settings from the package_id() won't affect the generation/build workflow, Conan will generate the proper binary taking into account all the configuration provided. It only affects the consuming flow of packages: information about compiler and build_type is removed, you cannot know which exact binary you are using (you can use properties to get that information).

@madebr I would like to know the scenario where you need (and cannot generate it yourself) the Debug build of CMake or any other tool. Thanks!

@madebr
Copy link
Contributor

madebr commented Oct 17, 2020

My resistance comes from these old cmake issues:

By only removing compiler and build_type in package_id, we leave the possibility of building + publishing a cmake package with debug runtime, DLL runtime and with a version that is possibly not installed.

So I propose the following:

settings = "os", "arch", "compiler", "build_type"
def configure(self):
    if self.settings.compiler == "Visual Studio" and self.setting.compiler.runtime != "MT":
        raise ConanInvalidConfiguration("CMake only supports MT to limit configurations")
    if self.settings.build_type != "Release":
        raise ConanInvalidConfiguration("CMake only supports Release build_type to limit configurations")
def package_id(self):
    del self.info.settings.compiler
    del self.info.settings.build_type

@jgsogo
Copy link
Contributor Author

jgsogo commented Oct 20, 2020

My resistance comes from these old cmake issues:

By only removing compiler and build_type in package_id, we leave the possibility of building + publishing a cmake package with debug runtime, DLL runtime and with a version that is possibly not installed.

I understand your concerns, but this is something that won't happen in CCI. We ensure a fixed order for the profiles and we know which ones are going to be uploaded. I totally understand this is something that can accidentally happen somewhere else if users do not pay enough attention, but in any production environment this should be controlled: order of profiles and jobs that can upload packages to the remotes.


So I propose the following:

settings = "os", "arch", "compiler", "build_type"
def configure(self):
    if self.settings.compiler == "Visual Studio" and self.setting.compiler.runtime != "MT":
        raise ConanInvalidConfiguration("CMake only supports MT to limit configurations")
    if self.settings.build_type != "Release":
        raise ConanInvalidConfiguration("CMake only supports Release build_type to limit configurations")
def package_id(self):
    del self.info.settings.compiler
    del self.info.settings.build_type

I see a problem here, we can't raise ConanInvalidConfiguration exceptions if we know the recipe works and the package builds for that configuration. Some user might want to compile using those settings.

@madebr
Copy link
Contributor

madebr commented Oct 21, 2020

I understand your concerns, but this is something that won't happen in CCI. We ensure a fixed order for the profiles and we know which ones are going to be uploaded. I totally understand this is something that can accidentally happen somewhere else if users do not pay enough attention, but in any production environment this should be controlled: order of profiles and jobs that can upload packages to the remotes.

This mixing of c3i build policy/operational management and recipe properties is what I'm feeling uneasy about.
This will work fine most of the cases but not when doing e.g.

conan create .... -s build_type=Debug -s compiler="Visual Studio" -s compiler.runtime=MDd --build all
conan upload ...

Such an upload can happen accidentally. I'm just forecasting an issues some conan users will face.

So I propose the following:

settings = "os", "arch", "compiler", "build_type"
def configure(self):
    if self.settings.compiler == "Visual Studio" and self.setting.compiler.runtime != "MT":
        raise ConanInvalidConfiguration("CMake only supports MT to limit configurations")
    if self.settings.build_type != "Release":
        raise ConanInvalidConfiguration("CMake only supports Release build_type to limit configurations")
def package_id(self):
    del self.info.settings.compiler
    del self.info.settings.build_type

I see a problem here, we can't raise ConanInvalidConfiguration exceptions if we know the recipe works and the package builds for that configuration. Some user might want to compile using those settings.

Indeed, this is not a good approach.
It shows that there is no solution with the current set of tools.
See my (crazy) comment at #2813 (comment).

@jgsogo
Copy link
Contributor Author

jgsogo commented Oct 22, 2020

:D

@jgsogo jgsogo closed this Oct 22, 2020
@jgsogo jgsogo deleted the cmake/installer branch October 22, 2020 14:28
@conan-center-bot
Copy link
Collaborator

config.yml syntax error in build 4:

No changes detected in this pull request: []|

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.

7 participants