[bug] --profile:build is not inferred
See original GitHub issueDescription
tl;dr
It looks like conan does not handle a conan create
with a --profile:host
and without a --profile:build
. For instance :
conan create . --profile:host android-ndk18b
- Expected behavior : conan infers a
--profile:build
from a system auto-detect like it would do if not profile was defined at all - Actual behavior : conan uses the
--profile:host
value like a normal--profile
(see Issue section below)
Context
To perform a cross compilation, one should provide at least 2 profiles : --profile:build
and --profile:host
.
In this issue, I will take one of my cross compilation use cases where I build an Android NDK package. This package has 2 build dependencies : m4 and doxygen. Those dependencies are defined in the conanfile build_requires
attribute.
Let’s say I have a (host) conan profile called android-ndk18b
with this content :
[settings]
os=Android
os.api_level=24
arch=armv8
compiler=clang
compiler.version=7.0
compiler.libcxx=c++_shared
build_type=Release
and a (build) conan profile linux-gcc7
with this content :
[settings]
os=Linux
arch=x86_64
compiler=gcc
compiler.version=7
compiler.libcxx=libstdc++
build_type=Release
When I cross compile my project with conan, I use this command:
conan create . --profile:build linux-gcc7 --profile:host android-ndk18b
Which works fine.
Issue
I work in a team and I would like to share the conan command to build the project to my teammates. However, I don’t know what compiler they have on their computers. It could be gcc 7, gcc 9, clang 11, etc. Therefore, sharing the conan create
command with --profile:build linux-gcc7
might not work for everyone. This is the reason why I would like to remove --profile:build
from the conan create
command, so conan adapts according to the computer where the cross compilation runs.
Example
conan create . --profile:host android-ndk18b
Exporting package recipe
[...]
Configuration:
[settings]
arch=armv8
build_type=Release
compiler=clang
compiler.libcxx=c++_shared
compiler.version=7.0
os=Android
os.api_level=24
[build_requires]
[env]
[...]
Installing package: my_project/2.1.1@my_channel/stable
Requirements
my_project/2.1.1@my_channel/dev from local cache - Cache
Packages
my_project/2.1.1@my_channel/dev:5ab84d6acfe1f23c4fae0ab88f26e3a396351ac9 - Build
Build requirements
doxygen/1.8.20 from 'conancenter' - Downloaded
libuuid/1.0.3 from 'conancenter' - Downloaded
m4/1.4.18 from 'conancenter' - Downloaded
xapian-core/1.4.18 from 'conancenter' - Downloaded
zlib/1.2.11 from 'conancenter' - Downloaded
Build requirements packages
doxygen/1.8.20:25b8de3e2de97de92586a279d28c5cc5b2137ea6 - Missing
libuuid/1.0.3:3e0b9a7b5a1764b7bfcd6d3bafd879baefdcd54d - Missing
m4/1.4.18:4cd8a0226669e0be90b7c9a8fcdc9ee41453a7d3 - Missing
xapian-core/1.4.18:d13734a4513718e91b60d2cd4e8198de1993c1ef - Missing
zlib/1.2.11:3e0b9a7b5a1764b7bfcd6d3bafd879baefdcd54d - Missing
Cross-build from 'Linux:x86_64' to 'Android:armv8'
Installing (downloading, building) binaries...
ERROR: Missing binary: doxygen/1.8.20:25b8de3e2de97de92586a279d28c5cc5b2137ea6
ERROR: Missing binary: libuuid/1.0.3:3e0b9a7b5a1764b7bfcd6d3bafd879baefdcd54d
ERROR: Missing binary: m4/1.4.18:4cd8a0226669e0be90b7c9a8fcdc9ee41453a7d3
ERROR: Missing binary: xapian-core/1.4.18:d13734a4513718e91b60d2cd4e8198de1993c1ef
ERROR: Missing binary: zlib/1.2.11:3e0b9a7b5a1764b7bfcd6d3bafd879baefdcd54d
libuuid/1.0.3: WARN: Can't find a 'libuuid/1.0.3' package for the specified settings, options and dependencies:
- Settings: arch=armv8, build_type=Release, compiler=clang, compiler.version=7.0, os=Android, os.api_level=24
- Options: fPIC=True, shared=False
- Dependencies:
- Requirements:
- Package ID: 3e0b9a7b5a1764b7bfcd6d3bafd879baefdcd54d
ERROR: Missing prebuilt package for 'doxygen/1.8.20', 'libuuid/1.0.3', 'm4/1.4.18', 'xapian-core/1.4.18', 'zlib/1.2.11'
Use 'conan search libuuid/1.0.3 --table=table.html -r=remote' and open the table.html file to see available packages
Or try to build locally from sources with '--build=missing'
(non-working) workaround
I thought about using the default profile :
conan create . --profile:build default --profile:host android-ndk18b
But on some dev computers, the default profile is not up-to-date with what is installed on the computer. Some colleagues told me they end up having some errors related to missing settings. For instance:
ERROR: m4/1.4.18: 'settings.compiler' value not defined
Environment Details (include every applicable attribute)
- Operating System+version: Ubuntu 18.04
- Compiler+version: gcc 7 & Android NDK
- Conan version: 1.44.1
- Python version: 3.6.9
Steps to reproduce (Include if Applicable)
- Clone a cross compilation project that works with
conan create
& build/host profiles - Run
conan create
with a--profile:host
and without a--profile:build
Logs (Executed commands with output) (Include/Attach if Applicable)
Only --profile:host
-> ❌
Click here to expand
conan create . --profile:host android-ndk18b
Exporting package recipe
[...]
Configuration:
[settings]
arch=armv8
build_type=Release
compiler=clang
compiler.libcxx=c++_shared
compiler.version=7.0
os=Android
os.api_level=24
[build_requires]
[env]
[...]
Installing package: my_project/2.1.1@my_channel/stable
Requirements
my_project/2.1.1@my_channel/dev from local cache - Cache
Packages
my_project/2.1.1@my_channel/dev:5ab84d6acfe1f23c4fae0ab88f26e3a396351ac9 - Build
Build requirements
doxygen/1.8.20 from 'conancenter' - Downloaded
libuuid/1.0.3 from 'conancenter' - Downloaded
m4/1.4.18 from 'conancenter' - Downloaded
xapian-core/1.4.18 from 'conancenter' - Downloaded
zlib/1.2.11 from 'conancenter' - Downloaded
Build requirements packages
doxygen/1.8.20:25b8de3e2de97de92586a279d28c5cc5b2137ea6 - Missing
libuuid/1.0.3:3e0b9a7b5a1764b7bfcd6d3bafd879baefdcd54d - Missing
m4/1.4.18:4cd8a0226669e0be90b7c9a8fcdc9ee41453a7d3 - Missing
xapian-core/1.4.18:d13734a4513718e91b60d2cd4e8198de1993c1ef - Missing
zlib/1.2.11:3e0b9a7b5a1764b7bfcd6d3bafd879baefdcd54d - Missing
Cross-build from 'Linux:x86_64' to 'Android:armv8'
Installing (downloading, building) binaries...
ERROR: Missing binary: doxygen/1.8.20:25b8de3e2de97de92586a279d28c5cc5b2137ea6
ERROR: Missing binary: libuuid/1.0.3:3e0b9a7b5a1764b7bfcd6d3bafd879baefdcd54d
ERROR: Missing binary: m4/1.4.18:4cd8a0226669e0be90b7c9a8fcdc9ee41453a7d3
ERROR: Missing binary: xapian-core/1.4.18:d13734a4513718e91b60d2cd4e8198de1993c1ef
ERROR: Missing binary: zlib/1.2.11:3e0b9a7b5a1764b7bfcd6d3bafd879baefdcd54d
libuuid/1.0.3: WARN: Can't find a 'libuuid/1.0.3' package for the specified settings, options and dependencies:
- Settings: arch=armv8, build_type=Release, compiler=clang, compiler.version=7.0, os=Android, os.api_level=24
- Options: fPIC=True, shared=False
- Dependencies:
- Requirements:
- Package ID: 3e0b9a7b5a1764b7bfcd6d3bafd879baefdcd54d
ERROR: Missing prebuilt package for 'doxygen/1.8.20', 'libuuid/1.0.3', 'm4/1.4.18', 'xapian-core/1.4.18', 'zlib/1.2.11'
Use 'conan search libuuid/1.0.3 --table=table.html -r=remote' and open the table.html file to see available packages
Or try to build locally from sources with '--build=missing'
We notice that conan look for the Android/armv8 version of the build dependencies (m4 & doxygen). It looks like conan uses the --profile:host
settings for the build dependecies.
2 profiles -> ✔
Click here to expand
conan create . --profile:build linux-gcc7 --profile:host android-ndk18b
Exporting package recipe
[...]
Configuration (profile_host):
[settings]
arch=armv8
build_type=Release
compiler=clang
compiler.libcxx=c++_shared
compiler.version=7.0
os=Android
os.api_level=24
[options]
[build_requires]
[env]
Configuration (profile_build):
[settings]
arch=x86_64
build_type=Release
compiler=gcc
compiler.libcxx=libstdc++
compiler.version=7
os=Linux
[options]
[build_requires]
[env]
CC=gcc-7
CXX=g++-7
my_project/2.1.1@my_group: Forced build from source
Installing package: my_project/2.1.1@my_group
Requirements
my_project/2.1.1@my_group from local cache - Cache
Packages
my_project/2.1.1@my_group:5ab84d6acfe1f23c4fae0ab88f26e3a396351ac9 - Build
Build requirements
doxygen/1.8.20 from 'conancenter' - Cache
libuuid/1.0.3 from 'conancenter' - Cache
m4/1.4.18 from 'conancenter' - Cache
xapian-core/1.4.18 from 'conancenter' - Cache
zlib/1.2.11 from 'conancenter' - Cache
Build requirements packages
doxygen/1.8.20:e94378795f92fbf88bb8cef7f9c2f38c4ecf9126 - Download
libuuid/1.0.3:d50a0d523d98c15bb147b18fa7d203887c38be8b - Download
m4/1.4.18:24647d9fe8ec489125dfbae4b3ebefaf7581674c - Download
xapian-core/1.4.18:85b735212da33d132f60ee7b3fa0ffd9557960e0 - Download
zlib/1.2.11:d50a0d523d98c15bb147b18fa7d203887c38be8b - Download
Cross-build from 'Linux:x86_64' to 'Android:armv8'
Installing (downloading, building) binaries...
libuuid/1.0.3: Retrieving package d50a0d523d98c15bb147b18fa7d203887c38be8b from remote 'conancenter'
Downloading conanmanifest.txt completed [0.21k]
Downloading conaninfo.txt completed [0.38k]
Downloading conan_package.tgz completed [7.60k]
Decompressing conan_package.tgz completed [0.00k]
libuuid/1.0.3: Package installed d50a0d523d98c15bb147b18fa7d203887c38be8b
[...]
Conan looks for the gcc 7/x64 version of the build dependencies (m4 & doxygen), which is correct.
Issue Analytics
- State:
- Created 2 years ago
- Comments:5 (3 by maintainers)
Indeed, I just realized that the
--settings:build
arguments are added on top of the default profile. Therefore, the command I proposed does not make sense…I will stick with the
--profile:build default
option as you suggested and ask colleagues with uncomplete default profiles to remove~/.conan/profiles/default
(in order to re-generate it).No worries for the documentation, I understand you are busy with 2.0. Unfortunately I haven’t had enough time to try to port our tools to conan 2.0 yet. I look forward to doing so though.
Thanks again for your great efforts ! Conan is definitely a game changer in the C/C++ world.
Many thanks! 😄