-
Notifications
You must be signed in to change notification settings - Fork 3.7k
Cmake cross-compilation uses native sysroot #6901
New issue
Have a question about this project? Si 8000 gn 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
Comments
@loblik Can you specify |
Then cmake fails with But this is not what I want. If someone wants to use this project in real life deployments, they probably have to also manage CVEs and licence compliance. The last thing you want, is a project secretly pulling something from somewhere and putting that in your product, without your build system knowing it (no CVE scanning, no version in SBOM). For this reason in some build systems (like bitbake from Yocto), the compile step is executed in sandbox with no access to network. So suggested We already have protobuf in our system, as other components are using it too. I want to use that version. I believe |
@loblik Help check my fix |
No, it does not seem to fix it. The problem seems to be in the way set(ONNX_PROTOC_EXECUTABLE ${Protobuf_PROTOC_EXECUTABLE})
get_filename_component(_PROTOBUF_INSTALL_PREFIX
${Protobuf_PROTOC_EXECUTABLE} DIRECTORY)
get_filename_component(_PROTOBUF_INSTALL_PREFIX
${_PROTOBUF_INSTALL_PREFIX}/.. REALPATH) It seems the cmake code assumes, the Do we really need to do these install prefix tricks? Can't we just rely on |
It depends on the Protobuf module of your CMake version. They are needed to help CMake 3.18 find the lib. For higher versions, there may be some fixes that they can be removed. |
Cmake mixes target and native sysroot when cross-compiling
Bug description
I'm building ONNX using Yocto/OE toolchain. Project builds fine, but during linking phase I get the following error:
This happens because ONNX's CMakeList makes linker to look for libraries inside native-sysroot, where protobuf host compiler is located. This causes an error as linker is mixing host (x86_64) and target (aarch64) objects.
I verified this by hacking CMakeLists.txt (see bellow).
System information
Reproduction instructions
This is a Yocto recipe I use to compile ONNX. It's pretty standard, it just fetches the ONNX from repository, sets up the build environment, installs dependencies and runs cmake with target toolchain.
Expected behavior
I would expect the project to just compile without extra tweaks or patches.
Notes
In the end I was able to link it by making this hack:
Both
find_package()
andfind_program()
which I used seems pretty standard to me. So can't they be in "default path", so even people using well-behaving toolchains can compile the project without issues?The text was updated successfully, but these errors were encountered: