[bug] MesonToolchain incurrectly sets c and cpp values when no compiler is specified
Describe the bug
Since 84a34554785e15d633b129de29ae98600ac5fe3e, when cross compiling, when no compiler has been specified in the host profile, MesonToolchain incorrectly sets the following values in the conan_meson_cross.ini file:
[binaries]
c = ''
cpp = ''
If the values are unset in the Conan profile, they should not be set as empty strings in conan_meson_cross.ini. Rather they should be omitted entirely as they were before 86d1ed6e0332d5f1dbf0a5a6dd351a2cd0f5e950.
How to reproduce it
No response
Hi @jhol
Thanks for your feedback
when cross compiling, when no compiler has been specified in the host profile
I am not sure if I understand this. If you are cross-compiling, then there is a compiler, and the compiler must be specified in the host profile settings. What I am missing?
Hi @jhol
Thanks for your feedback
when cross compiling, when no compiler has been specified in the host profile
I am not sure if I understand this. If you are cross-compiling, then there is a compiler, and the compiler must be specified in the host profile settings. What I am missing?
Hi @memsharded . Thanks for your review. I am tracking down this issue with Meson bare-metal building. At your suggestion, I wrote a test case to highlight the issue I was trying to resolve in my previous PR.
In so doing, I discovered 3 things:
-
I wrote a test case copying heavily from test cases in
test/functional/toolchains/meson/test_cross_compilation.py. This test case worked properly when applied to Conan 2.3.1 with no compilers set. However, since 84a34554785e15d633b129de29ae98600ac5fe3e, thecandcppfields are always set in theconan_meson_cross.inifile even if the string is empty. I understand your point that this is a bad profile configuration. What compilers would you suggest test case should set? Is there a test case I can copy from? Regardless, I still think the behaviour since 84a34554785e15d633b129de29ae98600ac5fe3e is less desirable. -
My original problem with
MesonToolchainnot properly handlingos=Nonewas caused by my Conan recipe excludingosfrom thesettingslist. ArguablyMesonToolchainshould fail gracefully whenos=None, but an easy solution is to addosback into the Conan recipe settings. -
There is one issue still to resolve which is that a mapping for
os=baremetalshould be added to_meson_system_map.
All these issues I have now addressed in !16904
The issue is that we don't have a cross-compiler in CI in Linux (or other platform).
It might be possible and makes sense to try to fake it, and use the native "gcc" even if we specify a cross-compilation with os=baremetal. The recommended approach for this configuration is:
- It is impossible that Conan knows the cross-compiler in a Linux machine that will have the native
gccinstalled (the majority) - It is then needed some explicit configuration of the cross-compiler
- This can be provided in 2 different ways:
- Using the
tools.build:compiler_executables, which can work for all build systems, even those that do not listen to CC/CXX env-vars, this can be defined in the[conf]section of the profile - Using the
CCandCXXenvironment variables (like defining them in the[buildenv]section of the profile
- Using the
With this info, the MesonToolchain will not have a blank compiler
With this info, the MesonToolchain will not have a blank compiler
This is good enough to solve my immediate problem. However, I do think the errors/warnings could be improved.