Open vithalsm opened 1 year ago
Hi @vithalsm
Thanks for your comments.
It would be necessary to narrow the scope, and have something reproducible, with real code, that we can all reproduce and agree on the behavior. I suggest starting with the conan new autotools_lib -d name=pkg -d version=0.1
template, as I understand that we are talking mostly about autotools, and then we want to check the AutotoolsToolchain
behavior.
Then, it would be necessary to clearly define the profiles. If both build and host have the same os
and arch
why would it be considered cross-building? It is not fully clear what are the configurations of compilers and build. You comment about a os.vendor
new setting, can you please elaborate a bit further about this new setting? What would be the values for it to define in the settings.yml
file for all Conan users? If you can also detail the exact triplet
that you are providing in the profile, that is also useful information.
Hi @memsharded thanks for the response. Here are the details on build/host (target) profiles, highlighting the differences.
======== Input profiles ======== Profile host: [settings] arch=x86_64 build_type=Release compiler=gcc compiler.libc=glibc compiler.libc.version=2.34 compiler.libcxx=libstdc++ compiler.version=10.3 os=Linux os.version=4.14.188 [conf] tools.build:sysroot=/usr/bandol-sysroot tools.build:skip_test=True tools.cmake.cmake_layout:build_folder_vars=['settings.os.platform'] tools.gnu:host_triplet=x86_64-aruba-linux-gnu [buildenv] ...
Profile build: [settings] arch=x86_64 build_type=Release compiler=gcc compiler.cppstd=gnu14 compiler.libc=glibc compiler.libc.version=2.31 compiler.libcxx=libstdc++11 compiler.version=9 os=Linux os.platform=native os.version=5.15 [conf] tools.cmake.cmake_layout:build_folder_vars=['settings.os.platform']
How I solved it?? By setting the triplet in the profile: [conf] tools.gnu:host_triplet=x86_64-xxxx-linux-gnu
In the above triplet, 'xxxx' is the vendor field which is being ignored when conan generates the triplets. config.guess auto generates this based on arch/os like.. 'pc', 'unknown' etc.
So, instead of setting the complete triplet, if optional profile variable 'os.vendor' can be introduced and used to construct the triplet, existing conan code to detect the cross compilation would work fine.
os.vendor can have default of 'unknown' unless overridden by the profile.
Environment details
Steps to reproduce
Setup: Build machine os/arch - Linux/ x86_64 Host machine os/arch - Linux/ x86_64 Let other config settings in conan profile like libc, compiler version be different.
Now, when the project conan receipe adds libs, say libev for example as dependency and exepects it to be built with host tool chains and also detect it as 'cross compilation', build for libev (in this example) fails. Reason, '--host' is not passed to configure script (conanbuild.sh).
There are quite a few tickets raised here and have varying solutions. Mostly requires, forking 'libev' source code and making changes to its recipe to manually update with options like '--host'. But, problem here is not with libev alone, but many.
Further investigating, found that, AutotoolsToolChain() which generates the 'configure command with options', doesn't detect it to be 'cross-compiling' as it compares arch/os of build and hosts. Ignores 'vendor' option.
Yes, 'vendor' option can be optional, but needs to be internally calculated as like config.guess does and compared. Even, API to generate triplet misses the 'vendor' field.
However, setting tools.gnu:host_triplet under [conf] section in conan profile solves the problem, as it properly generates the triplet.
Instead of setting complete triplet at profile, can consider setting 'os.vendor' in conan profile and gen_triplet API of auto tool chain can use same and also in comparison to check whether being cross compiled (just generating triplet n comparing may suffice).
This should globally solve the problems that are being hit in multiple cases.
Logs
No response