rust-bindgen panics with libclang error when compiling cocoabind as C++20
Categories
(Toolkit :: Crash Reporting, task)
Tracking
()
| Tracking | Status | |
|---|---|---|
| firefox140 | --- | fixed |
People
(Reporter: cpeterson, Assigned: cpeterson)
References
Details
Attachments
(1 file)
cocoabind parses Cocoa.h with -x objective-c and bindgen/libclang rejects -std=gnu++## (and -std=c++##) as incompatible with Objective-C.
thread 'main' panicked at third_party/rust/bindgen/ir/context.rs:559:15:
libclang error; possible causes include:
- Invalid flag syntax
- Unrecognized flags
- Invalid flag arguments
- File I/O errors
- Host vs. target architecture mismatch
If you encounter an error missing from this list, please file an issue or a PR!
stack backtrace:
0: rust_begin_unwind
at /rustc/05f9846f893b09a1be1fc8560e33fc3c815cfecb/library/std/src/panicking.rs:695:5
1: core::panicking::panic_fmt
at /rustc/05f9846f893b09a1be1fc8560e33fc3c815cfecb/library/core/src/panicking.rs:75:14
2: core::panicking::panic_display
at /rustc/05f9846f893b09a1be1fc8560e33fc3c815cfecb/library/core/src/panicking.rs:261:5
3: core::option::expect_failed
at /rustc/05f9846f893b09a1be1fc8560e33fc3c815cfecb/library/core/src/option.rs:2024:5
4: core::option::Option<T>::expect
at /Users/chris/.rustup/toolchains/stable-aarch64-apple-darwin/lib/rustlib/src/rust/library/core/src/option.rs:933:21
5: bindgen::ir::context::BindgenContext::new
at ./third_party/rust/bindgen/ir/context.rs:553:13
6: bindgen::Bindings::generate
at ./third_party/rust/bindgen/lib.rs:896:27
7: bindgen::Builder::generate
at ./third_party/rust/bindgen/lib.rs:349:9
8: build_script_build::main
at ./toolkit/crashreporter/client/cocoabind/build.rs:64:20
9: core::ops::function::FnOnce::call_once
at /Users/chris/.rustup/toolchains/stable-aarch64-apple-darwin/lib/rustlib/src/rust/library/core/src/ops/function.rs:250:5
| Assignee | ||
Comment 1•11 months ago
|
||
My C++20 patches started hitting this error when bug 1950258 added BINDGEN_SYSTEM_FLAGS to bindgen's CFLAGS. This isn't a C++20 specific problem: bindgen also complains about the flags -std=c++17 -x objective-c, but toolchain.configure doesn't add -std=c++17 because C++17 is clang's default C++ version.
I tried to fix this error by changing cocoabind's -x objective-c to -x objective-c++, but the Cocoa header files' NS_OPTIONS macro expands to different code when compiled as C or C++ and the C++ version hits some known bindgen issues parsing unnamed enums. Emilio suggested that filtering out BINDGEN_SYSTEM_FLAGS' incompatible C++ flags might be simpler than going further down a bindgen rabbit hole.
Comment 2•11 months ago
|
||
I agree, my first thought was it'd be easiest to filter out the incompatible flags.
| Assignee | ||
Comment 3•10 months ago
|
||
cocoabind parses Cocoa.h with "-x objective-c" and bindgen/libclang rejects "-std=gnu++##" as incompatible with Objective-C, so ignore BINDGEN_SYSTEM_FLAGS' -std=gnu++## flag.
Updated•10 months ago
|
Description
•