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
Use always build and host contexts and profiles #23
Conversation
May i suggest to introduce separate default profiles then for build and host. Developers always cross-compiling (embedded) would use this so that there is no need to specify a profile when building for the default target platform. |
So one UC for the flag |
There is already setting default_profile. I guess it feels natural to split it into 2. |
Furthermore, I propose to also provide an additional env var such as |
@petermbauer @ytimenkov @Da-LiFe I initially was thinking about having both a So I think that @ytimenkov suggestion of providing Regarding |
It is not very clear what you mean with the It is possible that we might introduce a more explicit definition like |
I think this is somewhat similar to code generators (like protobuf with generator running in build context and library being linked in host context), but slightly different: there is a library and a runner (for example), but library is linked into test code and shouldn't really affect the package id. However I'm not sure if it's too different: test framework library could be a private host requirement and runner a build one. Although running tests in such way with cross-compiled code is tricky. IIRC there were examples which included emulators as build requirement. |
Yes, that is the idea. The
That is the case that would be supported, even if not easy or very common, we were reported in the past of people doing this, so we want to have a model for it. |
We are not using the default profile in our setup, because our devs do not have a default platform. We are leveraging the fact that our machines have set the profile to use in the shell env already since ages. The env is called However, I'm not sure how we would be able to map the |
@memsharded And so we did in our Conan 1.X packages, so yeah we'll need something like a |
Yes, the training is defined for single "everything is host" context. When the build/host profiles are used now in Conan 1.X, it is necessary to define that def build_requirements(self):
self.build_requires("gtest/1.1.1", force_host_context=True) This can be tested right now, just passing a
The above idea of Please let me know if this makes sense. |
|
I am strongly in favour of this proposal. However, it's important for the model to also support use cases described in this bug report - notably that the tool, used in the build context, may provide some modules/scripts/whatever to be used in the host context. |
Absolutely yes. We are iterating on CMakeDeps to provide a better experience, including providing build modules for the build context (that are used to build a package in the "host" context, but that run in the build context, as they belong to a build-requires in the build context). We will evolve that in Conan 1.X next releases. |
I see, yes, that means that |
Doesn't In the absence of default build profile we have a convention to have a profile named "local" which should contain all build machine-specific settings. It may just include other named profile if there's a suitable one. |
Yes, but if I understood @Da-LiFe that would still require to execute some In any case, we are talking here about a relative minor UX thing, iiuc, it doesn't alter the core of the proposal. |
My question is just about clarification. As we never use the default profile (instead having very specific profiles, stored in a git repo, for various desktop OSs), and we don't cross compile, can I confirm that the intent is that
will set both host and build profiles to 'customprofile'? i.e. unchanged behaviour from 1.x. Asking as I was concerned by the statement
if we only specify the one --profile argument. |
Yep, there are 2 possibilities:
I can see pros and cons for both:
At the moment, it seemed a bit more natural to use something closer to the current behavior (now in Conan 1.X, if you specify for example Whatever the default is, we could implement a conf item that will opt-in into the other behavior as default. I am fine with either, whatever the majority wants, my only concern is that we might not get enough attention from the tribe to this specific comment, and creating a whole new proposal for this seems a bit overkill. But lets try here:
|
I like
Because in a lot of cases, they're going to be the same, and it's less typing. There are also other places where one option defaults to another, so this is a pattern that's already there. As in
For us, |
This, please. If we are going to make this behavior the new normal, then I feel we need to be able to specify different defaults for the host and build contexts. We are actually currently in the process of trying to move away from simply doing As another side note, this is unlikely to change but calling them host and build really confuses many people on my team. In our minds, host is the current computer we are compiling on and not the cross compiled target we are compiling for. A name like |
Even if not cross compiling I would like to have build_type==release always for build profile and debug for host (or at least vary). Would be unpleasant surprise to get non-optimized tool or even compiler. And build profile is not what I'd like to specify on the command line or change often. |
What ever you decide to use, please do not implement a conf item that will opt-in into the other behavior. |
Yes, this will be possible, you will be able to configure different defaults for build and host context, this was agreed above.
I agree with that, and I found it myself a bit counter intuitive when I first saw it. But we were pushed by the community to adopt this convention, because it is the GNU one: https://www.gnu.org/software/automake/manual/html_node/Cross_002dCompilation.html |
Ok, that could make sense, lets try to come up with a default and try to respect and go with it without defining an alternate configuration, (unless later it becomes a big pain for a big amount of users). |
This would be the behavior that you achieve with the first proposal THIS IS IMPORTANT, TRIBE, the second approach will by default put build-requires in the build context in the |
Thanks for considering my question in #23 (comment). Sorry if it's turned into more of a problem to solve though. As a related aside, and putting it out there for discussion, it has occurred to me (long before this discussion), that as we never use the default profile, whether it would be possible to put Conan in a mode to never create a default profile. If all profile switches were omitted, then it would be an error in that mode. (This is a problem we have now, devs forgetting to set the profile, and seeing different behaviour to others who do set it.) It may not work for everyone reading the above comments, but I think I'd be happy if Conan had that mode (which we would enable), and would thus say always use the same profile for both host and build if only one was specified. (Obviously, you can still be explicit with both profiles.) If the mode wasn't enabled (the default Conan behaviour perhaps?), then specifying only one profile, the build profile would map to the default profile. |
ACK this. I usually intentionally create an incomplete default profile so if conan ends up using it, it just fails fast.
This too, it would also be really nice to have a good way for IDE things like Qt creator kit or CMake presets to provide the new separated build/host profiles (could be support in cmake-conan for getting them out of the CMake cache variables, or in conan itself for environment variables - conan has |
We are distributing some common optimization profiles to our devs, e.g.
When using |
+1 for this from my side as well.
I solved this by putting explicit invocation of |
@ansutremel , we tried that solution as well, but it didn't work for us, as we are often cross-building and our cross-build profiles rely on We are currently not able to use build and host profiles in Conan 1.X due to this issue. |
This is very interested feedback! Indeed we have thought of NEVER creating a default profile, and if users don't provide just raise: "HEY YOU NEED TO CREATE A DEFAULT PROFILE". It was done this way to try to ease the live of onboarding people, newbies, etc., but we are now more about being super-explicit in everything, and having a default profile auto-generated that magically tries to guess your configuration doesn't really help the users, I think it is better if we make this step explicit. This is probably another UX big enough change to submit it to the Tribe as a separate issue, lets do it. |
I've upvoted the PR, as I see the benefits on making it clearer for cross compilation. |
Maybe it's worth providing a special hook for I assume that then one don't want to have a default profile there is a central configuration. But for open source projects out may be valuable to have default profile generated. Having per project overrides makes it less attractive and more complex to start working on something. |
The problem with such a hook, is that you need to install it too, and once you are doing it, it is easy to do whatever you want with the default profile.
Yes, sure, this has been our default so far. But it is also true that open source users are also been biten by the default |
This PR is being approved and merged, 46 upvotes, no downvotes. |
Thinking of it a bit more I think it's a good idea. For example with "please-don't-use-default-profile" setting people may have troubles figuring out what to do. Also if I'm striving for "Just works (tm)" for ordinary developers. So if your environment has customized settings / profiles then it's the same |
Use always, for all install/create commands both the "build" and the "host" profiles,
being the "build" one the configuration for the current building machine, and "host" the configuration
for the system in which the final built application will run.
If one or both of the build and host profiles is not specified, the "default" one will be used.
These commands will be equivalent and do the same:
The behavior is currently available in Conan 1.X, as opt-in (specifying
--profile:build
), the proposal is to make this the standard behavior, having always both build and host contexts.