Skip to content

Fix cross compilation of binding-generator#720

Open
AlexanderStein wants to merge 1 commit into
twistedfall:masterfrom
AlexanderStein:fix-cross-compile-isystem
Open

Fix cross compilation of binding-generator#720
AlexanderStein wants to merge 1 commit into
twistedfall:masterfrom
AlexanderStein:fix-cross-compile-isystem

Conversation

@AlexanderStein

Copy link
Copy Markdown

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.

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",
  [...]

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 -nostdlibinc to clang_sys::support::Clang::find(...) when collecting cpp_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.

@twistedfall

Copy link
Copy Markdown
Owner

This breaks the CI unfortunately, with errors indicating being unable to include system headers, e.g.:

  ===    /Users/runner/work/opencv-rust/opencv-rust/src_cpp/ocvrs_common.hpp:4:10: fatal error: 'memory' file not found

@AlexanderStein

Copy link
Copy Markdown
Author

I have no idea why the ubuntu 22.04 build breaks

[opencv 0.99.0] ===    /../lib/gcc/x86_64-linux-gnu/12/../../../../include/c++/12/cstdint:47:11: error: no member named 'int8_t' in the global namespace
[opencv 0.99.0] ===    /../lib/gcc/x86_64-linux-gnu/12/../../../../include/c++/12/cstdint:48:11: error: no member named 'int16_t' in the global namespace
[opencv 0.99.0] ===    /../lib/gcc/x86_64-linux-gnu/12/../../../../include/c++/12/cstdint:49:11: error: no member named 'int32_t' in the global namespace
[opencv 0.99.0] ===    /../lib/gcc/x86_64-linux-gnu/12/../../../../include/c++/12/cstdint:50:11: error: no member named 'int64_t' in the global namespace
[...]

As the include paths compared to ubuntu 24.04 are identical beside the version number, I suspect the LLVM-14 installation is somehow borked.
BTW: Why is clang-15 used with LLVM-14?

For Mac the include paths look good

  === Clang command line args: [
      "-isystem/Applications/Xcode_16.4.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/clang/17/include",
      "-I/Users/runner/build/opencv/opencv-4.13.0-build",
      "-F/Users/runner/build/opencv/opencv-4.13.0-build",
      "-I/Users/runner/work/opencv-rust/opencv-rust/src_cpp",
      "-F/Users/runner/work/opencv-rust/opencv-rust/src_cpp",
      "-DOCVRS_PARSING_HEADERS",
      "-includeocvrs_common.hpp",
      "-std=c++17",
  ]

I don't have a Mac so I don't know where the memory header actually is located. How can we debug/proceed here?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants