-
Notifications
You must be signed in to change notification settings - Fork 981
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
All information about 'build' and 'host' environment in the 'host' environment #7120
Comments
Yes, it is.
Meson works (roughly) this way:
There are no separate stages in meson for If you exclude any targets on step 1., then they can't be used on step 2., not as a meson target anyway: user will have to rewrite their project to work with excluded targets as external dependencies (and that will require them to add a lot of boiler-plate code and needless You can't exclude any targets on step 2.: if you build any target, it will also trigger the build of all it's dependencies (of course, you can build the dependee without the depender, but that's irrelevant to this issue).
Meson is written in Python, but it's language is not Python and it's not a Python module. See meson FAQ for more info.
I don't have enough information on this. So, no comments :P
This is a standard scenario for meson and is not discouraged or deprecated. It's recommended in the same way as let's say
I would say that it's on package maintainer to pack only relevant stuff (so pack only binaries that are intended for the supplied profile and not just every random crap that you've built). I mean it's possible to violate this rule even now, with the current conan approach - nothing prevents the user from stuffing all non-related binaries in the resulting package. So, meson packages should be treated the same way: "we give you information about the build system and target profile, give us binaries for this profile". To publish tools built with PS: I have to mention that I'm just a casual(?) meson user and not a meson developer =) |
Upstream meson dev here, @TheQwertiest asked me to chime in.
This is exactly the case, we support building targets for the build machine specifically to use those targets as part of the compilation process for the host machine. While we don't actively stop anyone from installing build machine targets, that is a really ugly thing to do, and we don't give you any nice helpers for that. Here is an example of what I mean that I wrote. We compile this transpiler that reads a project specific DSL and spits out C code, that is then compiled for the host machine. The transpiler isn't installed, it's just part of the build process to produce binaries that will be installed. Hopefully that helps. |
Absolutely
This requires a lot of patching and is maintainer heavy.
Requiring a toolchain for build and host is a common requirement. Not only used for building compiler utils.
This is a flex specific question. In this case, it is possible to re-use a flex for the build system to build a flex for the host system. Yesterday, I took a look at packaging openjdk, and it also requires a build and host compiler.
See @TheQwertiest : it's up to the packager to not include any artifacts built for the build system in the package. This is also the case now.
The current situation is a workaround and has met its limits. Is this issue a good place to submit a recipe as an example of usage of a dream crossbuilding conan API? |
@madebr , AFAIK meson allows at most for three toolchains - |
@TheQwertiest |
Actually, you only get two distinct tool chains, one for the build machine and one for the host machine. The target machine is only relevant when building a compiler, the target is the machine that the built compiler will compile for. ala you can build gcc that runs on aarch64 (host) on x86_64 (build) that creates binaries for riscv (target). What we do support is the ability to mix all supported languages. You want to build a project with C, C++, D, java, C#, and rust? sure we can do that. |
this is not something new. it's not even specific to meson or CMake or autotools. I believe such intermediate executable shouldn't affect on package id. for instance, native in contrast, I guess target is a bit different story, as it applies mostly to cross-compilers, but I believe it should always affect on package id. e.g. x86 GCC with ARM target will contain x86 executables (GCC, G++, etc.) and ARM libraries (libgcc, libatomic, etc.). |
This issue is directly linked to the following feature request: #7091 |
FYI "target" should probably be removed from meson There is just build and host |
Qt6 is another use case where it is kind of required to bundle both host and build binaries in the cross built package since all the users of Qt also needs its host binaries to be able to cross build. Qt5 actually seems to have done this internally which worked out fine. I tried putting Qt itself as a build requirement, as in #10332 and #5018 but it becomes extremely messy which options are applied to what, and since the consumer conanfile also needs it as a build req I ended up building 3 versions of qt (default options that applies only to the direct build req etc). If there was a build step that ran on the host when using 2 build profiles I could make the Qt recipe just build itself twice when cross building and then package the tools from the host as well in package(). |
Closing as outdated/solved in Conan 2, please create new tickets if necessary against Conan 2.X, thanks for the feedback. |
Reality bites. We agree that packages should contain binaries only for one architecture, so the proposed model by Conan with the host and the build contexts, theoretically, would be enough for every use case.
But there are out there some packages like
flex
(westes/flex#78) or build systems like Meson where there is a common practice: to build artifacts for the build context before building the artifacts for the host context (in the same project, one single Meson run). Usually, we refer to them as multi-stage, or they require some bootstrapping,...One solution would be always to divide the package, but this is not always possible/desired (?). So I'm opening this issue to discuss about this topic. cc/ @thkowa @TheQwertiest @SSE4
Where are we now (only new model using two profiles):
During the
build()
method the environment is populated with the environment variables defined in theprofile:host
, and the environment variables coming from the build context (those defined by the packages, and those needed for tools to run: PATH, DYLD_LIBRARY_PATH,...). But in the host context you cannot reproduce the context you have during while building packages in the build context, even though you have access tosettings_build
, you cannot access the environment that was defined in theprofile:build
orenvironment:build
.The helper
self.run("....", run_environment=True)
is noop when using two profiles.I would say that this covers most of the cross-building scenarios out there...
flex, cmake, gcc (?),...
These packages have a first stage which is a native compilation and a second stage that compiles the final product. Current Conan model is valid for this scenario, although the implementation I can imagine is not as straightforward as I'd like it to be.
For example, if flex requires
stage1flex
to run in the build context and theflex
is the final library itself (for the host context) something like this would work:(pseudocode)
The problem here: depending on the context the package has generated only the library
flex
or the toolstage1flex
as well. This circumstance has to be encoded into the package ID, so we would need an option just for this:One big advantage of this approach is that
stage1flex
is generated only once if several packages require this same tool.Meson
The problem with Meson is with monolithic projects where you cannot choose to build only the cross part, every execution needs to compile the native stage and then the cross stage.
Question: Is this a requirement? Can we add an
if
into the Meson project definition to choose the part to build? It's Python, it should be possible.If we can choose the stage to compile from the project, then the same approach I presented for the
flex
recipe should work for any Meson project too: first it will run the native compilation with all the needed settings, then it will run the cross-compilation with the tools from the first stage in the PATH.If not,
I have more questions than answers, and I would need to run some POCs to prove the pseudocode presented here and other alternatives. Any feedback and opinions are more than welcome. This is something to think about, the answer is far in the future.
Thanks!
The text was updated successfully, but these errors were encountered: