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

[question] How to use MinGW as build profile on Windows? #16131

Open
1 task done
elvisdukaj opened this issue Apr 23, 2024 · 2 comments
Open
1 task done

[question] How to use MinGW as build profile on Windows? #16131

elvisdukaj opened this issue Apr 23, 2024 · 2 comments

Comments

@elvisdukaj
Copy link
Contributor

elvisdukaj commented Apr 23, 2024

What is your question?

It's already a full day and I think I am missing some very basic knowledge about conan.

What I want to achieve:

I am setting up a private conan-center-index and I am preparing the build environment. I would like to avoid installing Visual C++ as it's not needed. We are mainly targeting Android, and the host can be Windows, Linux or MacOS.
Some packages requires a native build (i.e. ninja, protobuf, grpc). I was thinking that I can use MinGW as build profile for buildiing the requirements. But I also would like to execute unit tests on Windows as well. So MinGW would be used both as host and build profile.
I don't want to install the toolchain on the host, conan has already a mingw-builds package and that's enough.

What I've tried:

I took the most naive approach:

mingw profile used for building the host packages:

Profile host:
[settings]
arch=x86_64
build_type=Release
compiler=gcc
compiler.cppstd=20
compiler.libcxx=libstdc++
compiler.version=12.2
os=Windows
[tool_requires]
*: mingw-builds/12.2.0
*: ninja/1.11.1
*: cmake/3.28.1
[conf]
tools.cmake.cmaketoolchain:generator=Ninja Multi-Config
tools.env.virtualenv:powershell=False

mingw_build used for building tool requirments:

Profile host:
[settings]
arch=x86_64
build_type=Release
compiler=gcc
compiler.cppstd=20
compiler.libcxx=libstdc++
compiler.version=12.2
os=Windows
[tool_requires]
*: mingw-builds/12.2.0
[conf]
tools.cmake.cmaketoolchain:generator=Ninja Multi-Config
tools.env.virtualenv:powershell=False

Now the issue is that conan is detecting a cycle/loop in the graph, indeed mingw-builds is there twice. How can I solve this problem? What options do I have? Do I need to a pre-installed toolchain?

How I would like to use the two profiles:

The tools should be built only with the build profile:

conan create recipes/ninja/all --version 1.11.1 -pr:h mingw12.2_build -pr:b mingw12.2_build

The packages should be built in a similar way:

conan create recipes/ninja/all --version 1.11.1 -pr:h mingw12.2 -pr:b mingw12.2_build

Would that be possible?

Have you read the CONTRIBUTING guide?

  • I've read the CONTRIBUTING guide
@elvisdukaj
Copy link
Contributor Author

It seems a bumpy road. I tried also to dupplicate the mingw-builds recipes, remove the 7z build dependency and use this profile for building but I have other issues while running the tests. the libstdc++.dll library is not found in the system.
Using MinGW as default toolchain seems problematic as the c++ standard library is not found during the run.

@memsharded
Copy link
Member

I am setting up a private conan-center-index and I am preparing the build environment.

Plese read https://blog.conan.io/2024/04/23/Introducing-local-recipes-index-remote.html, it might help

Some packages requires a native build (i.e. ninja, protobuf, grpc). I was thinking that I can use MinGW as build profile for buildiing the requirements. But I also would like to execute unit tests on Windows as well. So MinGW would be used both as host and build profile.

Support for ConanCenter recipes in conan-center-index for msvc compiler will be much better than for MinGW because ConanCenter only builds and test packages in Windows for msvc. So even if contributors submit patches to support MinGW, the support will be generally inferior. Probably it is not

Now the issue is that conan is detecting a cycle/loop in the graph, indeed mingw-builds is there twice. How can I solve this problem? What options do I have? Do I need to a pre-installed toolchain?

Yes, this is expected, if mingw is a build-require and there is a

[tool_requires]
*: mingw-builds/12.2.0

in the profile, it will try to add that tool-requires to all tool-requires, including itself, in an infinite loop.
You can define other patterns to break the loop, something like:

[tool_requires]
ninja/*: mingw-builds/12.2.0

If you need something more complex you can use jinja templates.

conan create recipes/ninja/all --version 1.11.1 -pr:h mingw12.2_build -pr:b mingw12.2_build

There are some UX improvements you can do here:

  • Use the same profile as "host" packages with:
    conan create recipes/ninja/all --version 1.11.1 -pr:h mingw12.2 -pr:b mingw12.2_build --build-require
    
  • Or use -pr:a mingw12.2_build to apply it to build and host profiles the same one

Using MinGW as default toolchain seems problematic as the c++ standard library is not found during the run.

This might be a recipe-related issue, more than a Conan one, trying with conan new templates first to triage issues is recommended.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants