Fix cross compilation of binding-generator - #720
Conversation
There was a problem hiding this comment.
Pull request overview
This PR adjusts how the binding generator discovers Clang’s default C/C++ include search paths so cross-compilation header parsing won’t accidentally pick up host system include directories.
Changes:
- Pass
-nostdlibinctoclang_sys::support::Clang::find(...)when collectingcpp_search_paths, to prevent host standard library include paths from being captured and later forwarded into the libclang parse.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
|
This breaks the CI unfortunately, with errors indicating being unable to include system headers, e.g.: |
|
I have no idea why the ubuntu 22.04 build breaks As the include paths compared to ubuntu 24.04 are identical beside the version number, I suspect the LLVM-14 installation is somehow borked. For Mac the include paths look good I don't have a Mac so I don't know where the |
|
Can you please try rebasing on the current |
Pass -nostdlibinc to clang so that host path will not be included, as they
will break compilation with target SDK toolchain:
=== Using OpenCV headers from: /opt/sdk/dev/sysroots/armv8a-tq-linux/usr/include/opencv4
=== Clang: clang version 22.1.8
=== Clang command line args: [
"-isystem/opt/sdk/dev/sysroots/x86_64-tqsdk-linux/usr/lib/clang/22/include",
"-isystem/usr/local/include",
"-isystem/usr/include",
[...]
5d66fcd to
b86cb1e
Compare
|
Okay, something is wrong with that GitHub container. Looking at Going on. I've tried to replicate the situation locally using podman. Here is what I got: Dockerfilepodman-compose.ymlversion: "3.9"
services:
opencv-rust-ubuntu2204:
build:
context: .
dockerfile: Dockerfile
container_name: opencv-rust-ubuntu2204
working_dir: /workspace
volumes:
- /home/alex/Dokumente/programmieren/rust/opencv-rust:/workspace:Z
- cargo-registry:/root/.cargo/registry
- cargo-git:/root/.cargo/git
- target:/workspace/target
- build-cache:/root/build
environment:
OPENCV_VERSION: "4.5.4"
tty: true
stdin_open: true
command: >
bash -lc "
ci/install.sh &&
ci/script.sh
"
volumes:
cargo-registry:
cargo-git:
target:
build-cache:Starting with
and everything compiles smoothly. I don't know what kind of ubuntu container is used here. But IMHO it is somehow borked. |
|
I think this is a dead end. This isn't the right way to fix it. Meanwhile I've found a way to properly detect the SDK include paths. I have to set Sorry for the noise |
|
I would say this is the correct way to go, your setup seems quite unique, so using some local-only overrides will be a faster way forward than trying to find a generic solution. |
Pass -nostdlibinc to clang so that host path will not be included, as they will break compilation with target SDK toolchain:
=== Using OpenCV headers from: /opt/sdk/dev/sysroots/armv8a-tq-linux/usr/include/opencv4
=== Clang: clang version 22.1.8
=== Clang command line args: [
"-isystem/opt/sdk/dev/sysroots/x86_64-tqsdk-linux/usr/lib/clang/22/include",
"-isystem/usr/local/include",
"-isystem/usr/include",
[...]
Please also consider adding this as a fix to 0.99.1. Currently build breaks on master for systems with both openvc5 and opencv4 installed, but the project requiring opencv4.