conan: [bug] Cross compiling with dual profile breaks with fPIC
I’m unable to use almost any package when cross compiling from Windows to Android.
It seems like the
def config_options(self):
if self.settings.os == "Windows":
del self.options.fPIC
pattern that is used in almost all recipes breaks when I try use the new --profile:host/--profile:build
logic to cross compile on Windows…
As a work around I tried to replace the config_options
logic with:
def package_id(self):
if self.settings.os == "Windows":
del self.info.options.fPIC
and it seems to work. It feels like a hack though.
I first create an issue in CCI (https://github.com/conan-io/conan-center-index/issues/4483) but I think it actually belongs here.
Environment Details (include every applicable attribute)
- Operating System+version: Windows 10
- Compiler+version: Visual Studio 16/Android Clang 11
- Conan version: conan 1.33.1
- Python version: Python 3.7.8
Conan profile
Configuration (profile_host):
[settings]
arch=armv8
build_type=Release
compiler=clang
compiler.libcxx=libc++
compiler.version=11
os=Android
os.api_level=22
[options]
[build_requires]
*: android-ndk/r22
[env]
Configuration (profile_build):
[settings]
arch=x86_64
arch_build=x86_64
build_type=Release
compiler=Visual Studio
compiler.runtime=MD
compiler.version=16
os=Windows
os_build=Windows
[options]
[build_requires]
[env]
Steps to reproduce (Include if Applicable)
Minimal example:
from conans import ConanFile
class fooConan(ConanFile):
name = "foo"
generators = "cmake", "cmake_find_package_multi"
settings = "os", "arch", "compiler", "build_type"
requires = (
"protobuf/3.13.0", # to get Android libprotobuf
)
build_requires = (
"protobuf/3.13.0", # to get Windows proto.exe
)
run:
conan create . version@dirac/testing \
--profile:host android-ndk-r20-api-21-arm64-v8a-clang-libcxx.txt \
--profile:build default \
--build=outdated
You get the error:
ERROR: protobuf/3.13.0: option 'fPIC' doesn't exist
Possible options are ['shared', 'with_zlib', 'lite']
Having either or of requires
and build_requires
works.
Logs (Include/Attach if Applicable)
Click to expand log
[HOOK - attribute_checker.py] pre_export(): WARN: Conanfile doesn't have 'url'. It is recommended to add it as attribute
[HOOK - attribute_checker.py] pre_export(): WARN: Conanfile doesn't have 'license'. It is recommended to add it as attribute
[HOOK - attribute_checker.py] pre_export(): WARN: Conanfile doesn't have 'description'. It is recommended to add it as attribute
Exporting package recipe
foo/version@dirac/testing: The stored package has not changed
foo/version@dirac/testing: Exported revision: fb9a654636e5e59257bc4d6b6fffaa74
Configuration (profile_host):
[settings]
arch=armv8
build_type=Release
compiler=clang
compiler.libcxx=libc++
compiler.version=11
os=Android
os.api_level=22
[options]
[build_requires]
*: android-ndk/r22
[env]
Configuration (profile_build):
[settings]
arch=x86_64
arch_build=x86_64
build_type=Release
compiler=Visual Studio
compiler.runtime=MD
compiler.version=16
os=Windows
os_build=Windows
[options]
[build_requires]
[env]
android-ndk/r22: Package is up to date
ERROR: protobuf/3.13.0: option 'fPIC' doesn't exist
Possible options are ['shared', 'with_zlib', 'lite']
About this issue
- Original URL
- State: closed
- Created 3 years ago
- Comments: 15 (5 by maintainers)
We have decided to move forward with https://github.com/conan-io/conan/pull/12905, and it has been merged for 1.58. This will unblock the issue, conditioned to using
build
profile, as that is a feature “under development”, so hopefully this will not be such a big risk. Thanks everyone for the feedback.Sounds similar to my issue: https://github.com/conan-io/conan-center-index/issues/4013 (and this one, names lockfiles but related to building a graph when same package is in build and ordinary requirement: https://github.com/conan-io/conan/issues/8335)
Hi @anton-dirac, Thanks a lot for reporting, I have been able to reproduce the issue. Looks like the options of the host context are being propagated to the protobuf that is as build_requires in the build context making the build fail. I will mark this as a bug and we will try to understand what’s happening there and what can we do to solve it.