Header search path failure on 1.8.2 (works in 1.8.1) related to clang executable search order changes
I'm using autocxx to generate some bindings to a C++ library. autocxx enables the runtime feature of this crate unconditionally, something which will hopefully be improved.
As of this change, released in 1.8.2, my bindings always fail to generate unless I set CLANG_PATH=$(which clang) to override the above search order, because the bundled libclang fails to find some macOS system headers.
$ cargo update --precise 1.8.1 clang-sys
$ cargo check
...
Finished `dev` profile [unoptimized + debuginfo] target(s) in 1m 02s
$ cargo update --precise 1.8.2 clang-sys
$ cargo check
...
process didn't exit successfully: `/Users/.../build-script-build` (exit status: 1)
--- stderr
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/clang/15.0.0/include/inttypes.h:21:15: fatal error: 'inttypes.h' file not found
I'm not sure if this is something to be fixed here or not, as I don't fully understand why the bundled libclang doesn't work. But I suspect this problem affects others on macOS too.
I'm encountered same issue on MacOS
` $ cargo update --precise 1.8.2 clang-sys $ cargo build ...
--- stderr wrapper.h:1:10: fatal error: 'sys/param.h' file not found ... Unable to generate bindings: ClangDiagnostic("wrapper.h:1:10: fatal error: 'sys/param.h' file not found\n") `
Looks like include headers that were previously found are no longer in the search path, which is breaking things on GHA too. For those looking for a hotfix:
echo BINDGEN_EXTRA_CLANG_ARGS_aarch64-apple-darwin="-I/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include" >> $GITHUB_ENV
I have the same issue.
error: failed to run custom build command for `timelib v0.3.4`
Caused by:
process didn't exit successfully: `/Users/user/Source/my-api-rust/target/llvm-cov-target/debug/build/timelib-9d2eb476496a3c91/build-script-build` (exit status: 101)
--- stderr
shim/../ext/timelib/timelib.h:37:10: fatal error: 'stdlib.h' file not found
thread 'main' panicked at /Users/user/.cargo/registry/src/index.crates.io-6f17d22bba15001f/timelib-0.3.4/build.rs:29:10:
failed to run bindgen: ClangDiagnostic("shim/../ext/timelib/timelib.h:37:10: fatal error: 'stdlib.h' file not found\n")
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
error: command `/Users/user/.rustup/toolchains/stable-x86_64-apple-darwin/bin/cargo test --no-run --message-format json-render-diagnostics --target-dir /Users/user/Source/my-api-rust/target/llvm-cov-target` exited with code 101
error: process didn't exit successfully: `/Users/user/.rustup/toolchains/stable-x86_64-apple-darwin/bin/cargo nextest run --manifest-path /Users/user/Source/my-api-rust/Cargo.toml --target-dir /Users/user/Source/my-api-rust/target/llvm-cov-target` (exit status: 101)
One day I'll learn my lesson and stop trying to make this crate better...
I've yanked v1.8.2 and will release the non-broken changes later.
Thanks for the quick action @KyleMayes !
Hopefully, it doesn't dissuade you from improving the crate...
P.S. You may want to remove 1.8.2 from releases too...
Even with clang-sys v1.8.1 I seem to see the same problem