rust-lang / rust-lang/rust-bindgen
c++ constexpr breaks with Mac OS native clang
Nobody has claimed this yet.
- Dominant language
- Rust
- Stars
- 5.3k
- Forks
- 829
- Avg merge
- 1d 1h
- Merged PRs (30d)
- 15
Description
The native Clang (Apple clang version 12.0.0 (clang-1200.0.32.28)) on Macs (Mac OS 10.15.7 anyway), seems to break bindgen's support for c++ header files. c header files seem fine. In particular, it seems to break the constexpr keyword.
$ echo 'constexpr int test = 1;' > test.hpp
$ bindgen --version
bindgen 0.56.0
$ bindgen test.hpp
test.hpp:1:1: error: unknown type name 'constexpr'
test.hpp:1:1: error: unknown type name 'constexpr', err: true
thread 'main' panicked at 'Unable to generate bindings: ()', /Users/ccouzens/.cargo/registry/src/github.com-1ecc6299db9ec823/bindgen-0.56.0/src/main.rs:54:36
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
$ PATH="/usr/local/opt/llvm/bin:$PATH" bindgen test.hpp
/* automatically generated by rust-bindgen 0.56.0 */
pub const test: ::std::os::raw::c_int = 1;
$ clang --version
Apple clang version 12.0.0 (clang-1200.0.32.28)
Target: x86_64-apple-darwin19.6.0
Thread model: posix
InstalledDir: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin
$ PATH="/usr/local/opt/llvm/bin:$PATH" clang --version
clang version 11.0.0
Target: x86_64-apple-darwin19.6.0
Thread model: posix
InstalledDir: /usr/local/opt/llvm/bin
Clang 12 hasn't yet been released. So it's odd that it's the version Apple is shipping. And it's not reasonable for bindgen to support a prerelease version.
I wanted to raise an issue:
- To help other people seeing this problem.
- To help the bindgen team prepare for clang 12 (if that's possible and reasonable)
- So that I (or someone else) can upgrade documentation such as requirements and the main readme.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Reproduce the failure with the Apple clang and bindgen commands shown, then compare it with the Homebrew LLVM invocation. Review the linked requirements page and main README to determine whether the result calls for compatibility work or documentation; done requires an agreed resolution for Apple clang 12 behavior.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- cpp, rust
- Domain
- compilers, devtools
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 28/100