[bug] Cross compiling with dual profile breaks with fPIC
See original GitHub issueI’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']
Issue Analytics
- State:
- Created 3 years ago
- Comments:11 (2 by maintainers)
Top Results From Across the Web
Full Text Bug Listing - Gentoo's Bugzilla - Gentoo Linux
This accidentally works when compiling natively but breaks when cross-compiling. The solution is to force libxml2.so to be linked as a C++ library....
Read more >Compiling Python 3.7.3 from source and getting all sorts of ...
So I am trying to compile python 3.7.3 on debian 9.9, got all the libraries installed and previously I was getting an uuid...
Read more >Optimize Options (Using the GNU Compiler ...
Compiling multiple files at once to a single output file mode allows the compiler ... By default, GCC emits an error message when...
Read more >How to Build a GCC Cross-Compiler
2 /configure --prefix=/opt/cross --target=aarch64-linux --enable-languages=c,c++ --disable-multilib $ make -j4 all-gcc $ make install-gcc $ cd ..
Read more >distcc frequently asked questions
For example, on each volunteer machine, build an x86-linux cross compiler and (this is important) install it as "i386-redhat-linux-gcc-3.2.2" or something ...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found

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.