-
Notifications
You must be signed in to change notification settings - Fork 1.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[package] protobuf/3.17.1: Builds protoc installer for wrong architecture when cross compiling #6005
Comments
You can use protobuf as both, a |
@ericriff Thanks for the reply. Do you have an example? I am not sure how to correctly implement your idea. Not sure how to specify in my conanfile to use our x86-64 arch protoc. |
@ericriff This situation is a Canadian Cross. So we ended up following this. We created both ARM and x86-64 profiles. Our ARM profile also used a Yocto SDK toolchain so we included the necessary ENV VARS for that in the profile. Then installed using the Conan experimental feature:
|
I'm seeing this same issue. Could someone provide some insight into how this is intended to work when cross-compiling with the CMakeDeps generator? conanfile.py: class MyConan(ConanFile):
settings = "os", "compiler", "build_type", "arch"
generators = "CMakeToolchain", "CMakeDeps"
requires = "protobuf/3.19.1"
tool_requires = "protobuf/3.19.1" CMakeLists.txt: cmake_minimum_required(VERSION 3.18)
project (MyProject)
find_package(protobuf REQUIRED)
add_library(my_target my_proto.proto)
target_link_libraries(my_target protobuf::protobuf)
protobuf_generate_cpp(PROTO_SRCS PROTO_HDRS TARGET my_target)
protobuf_generate(LANGUAGE cpp TARGET my_target PROTOS my_proto.proto) If I build this, CMake tries to execute the host platform's protoc binary when building: $ conan install .. --profile linux-armv8 --profile:build linux-x64
$ cmake .. -G Ninja -DCMAKE_TOOLCHAIN_FILE=conan_toolchain.cmake
$ cmake --build .
...
/bin/sh: 1: /home/username/.conan/data/protobuf/3.19.1/_/_/package/e59c9b7d983a28031f7cda229595ac22e2116e8b/bin/protoc: Exec format error |
If I add the following, it finds the correct protoc binary in the build context, and everything is fine: def generate(self):
cmake = CMakeDeps(self)
cmake.build_context_activated = ["protobuf"]
cmake.build_context_suffix = {"protobuf": "_BUILD"}
cmake.generate()
toolchain = CMakeToolchain(self)
toolchain.generate() CMakeLists.txt: ...
find_package(protobuf_BUILD REQUIRED)
find_package(protobuf REQUIRED)
... Is this the best way to do this?
Although this works, it feels a lot more awkward than it should be. Am I missing something? |
Hi. Just wanted to mention I've successfully cross compiled A proof of building can be seen here.
with docker image Running
directly is also possible, but it won't run the The docker image by itself is not enough as it is, the reason it works now is because the I'm not sure if the last message from @MikeyH84 is the same as my gist, but it might be very similar. |
I have it resolved using his comment for a build that supports cross compile to an RPi 4.
The way to confirm this is to look for PROTOBUF_PROTOC_EXECUTABLE in the CMakeCache.txt and verify it points to the build version. NOTE: If you change the conanfile you will need to remove your build folder for it to work correctly. |
I ressolved the cross-compile issue by manually pointing to the correct Protoc binary in the build context like so:
I didn't do anything special with the install/build/create commands. I did use the newer Conan build/host profiles for the build contexts. An example would look like the following:
Note handling |
I did not need to do anything extra in the CMake files with my configuration above. I use |
We still need that, but we using Conan 1.59.0. A lot of the build/host context issues got sorted with the 2.0 migration |
Just confirming that this works. No need to set |
Package and Environment Details (include every applicable attribute)
Requires package:
protobuf/3.17.1
Conan profile (output of
conan profile show default
orconan profile show <profile>
if custom profile is in use)Steps to reproduce (Include if Applicable)
Attempt to cross compile on build machine to host platform.
Logs (Include/Attach if Applicable)
Currently our recipes require dependencies:
These work no problem, but are deprecated (sunset). We attempted to move to the Conan centre, switching to protobuf/3.17.1, but now experiencing cross compilation issues.
The protoc compiler gets built for ARM architecture (our host platform) but the build system architecture is x86-64 Linux. Resulting in error:
Not sure the reason why the libraries got combined back into a single Conan recipe. Maybe we are missing something? Some additional options perhaps?
But essentially we would like either additional options exposed in the recipe for cross compilation or the libraries to be split again and function in a similar manner to how they were at version 3.9.1.
Possible Hack
We hacked a local copy of the recipe to point to an already pre-existing x86-64 Linux build of the protobuf library (containing the protoc tool). However, we do not want to modify/maintain our own custom version of the recipe. This also adds unwanted dependencies in the CI/CD and local builds. eg. x86-64 Linux version must already exist in the systems local Conan cache with matching protocol versions.
We can host the deprecated libraries ourselves, but we would like future support.
Thank you for your time :)
The text was updated successfully, but these errors were encountered: