conan-io / conan

Conan - The open-source C and C++ package manager
https://conan.io
MIT License
8.13k stars 968 forks source link

[bug] The build=missing flag is not respected for the build_requires of the host system #7421

Closed anagno closed 4 years ago

anagno commented 4 years ago

Hello Everyone,

I tried the new cross-building model (thanks for the great work!), but I think I found a bug (or I have not understood the documentation on how to use the new model). The bug is that the --build=missing flag is not respected for the build_requires of the host system.

Here is my use case:

I have a library that I would like to cross-build in Emscripten. So I defined my build profile:

[settings]
os=Linux
os_build=Linux
arch=x86_64
arch_build=x86_64
cppstd=17
compiler=gcc
compiler.version=7
compiler.libcxx=libstdc++11
build_type=Release

[options]
[build_requires]
[env]

and I defined my host profile:

[settings]
os=Emscripten
arch=x86
build_type=Release
cppstd=17
compiler=clang
compiler.version=11
compiler.libcxx=libstdc++11

[options]
boost:without_graph=True
`
` (many more options that are not relevant)
`
GaMa:libxml2=False

[build_requires]
cmake/3.17.3
emsdk_installer/1.39.13@bincrafters/stable

# It is required because we also have some tools in the source 
# code that produces their new code.
expat/2.2.9

[env]

The problem arises with the expat/2.2.9 dependency (which does not have pre-build binaries. Only the recipe for producing the binaries). This dependency is used to produce some source code, that will be used in the generation of the final library (so we also need the native binaries to use them on the build system). At the same time it is also a dependency in the produced library (https://github.com/anagno/gama/blob/master/conanfile.py). So it also has to be cross-compiled for the host system. Currently when I try (in a clean system) to build the library, conan is complaining for the missing prebuild binary of expat (although it is listed in the build_requires)

If I force the installation of the native binaries (conan install Expat/2.2.9@pix4d/stable --build=missing;), then everything works.

Is it something that is expected or am I using the new model wrong?

Kind regards,

Vasileios

Possible related issues:

Environment Details (include every applicable attribute)

Steps to reproduce (Include if Applicable)

Logs (Executed commands with output) (Include/Attach if Applicable)

I have logs from the travis-ci. Let me know if you need links to them

anagno commented 4 years ago

I think I found the mistake :)

If I remove the build_requires expat/2.2.9 from the profile and I add it in the recipe it seems to work:

   def build_requirements(self):

      if tools.cross_building(self.settings):
         self.build_requires("expat/2.2.9")

And it is logical since this is not a build_requires for building in the host, but a build_requires of the library to be cross build. Sorry for opening early the report :)

memsharded commented 4 years ago

Hi @anagno

It seems (https://github.com/conan-io/conan/issues/7423) that you are starting to try the new cross-build model. Please let us know if the --build=missing would work in that case, in theory it should be building 2 different binaries, one in each context. Do not hesitate to re-open or open a new question for it. Thanks!