rust-lang / rust-lang/rust-bindgen

Improve troubleshooting experience

Open
#1,456 5 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

enhancement help wanted
Dominant language
Rust
Stars
5.3k
Forks
829
Avg merge
1d 1h
Merged PRs (30d)
15

Description

Bindgen documentation says to add -x c++ to parse c++ headers, so I've done what seems to be logical: .clang_arg("-x c++"). This caused quite unhelpful error:

--- stderr
thread 'main' panicked at 'libclang error; possible causes include:
- Invalid flag syntax
- Unrecognized flags
- Invalid flag arguments
- File I/O errors
If you encounter an error missing from this list, please file an issue or a PR!', libcore\option.rs:960:5

I've manually checked that clang takes this param without problem. So, it is bindgen doing something strange to this param. Unfortunately the exact clang command line is not shown in output, thus leaving me unable to troubleshoot. Googling did help to answer the mystery with advice to do .clang_arg("-x").clang_arg("c++"). but it should be documented.

Expected changes:

  1. Document in clang_arg (and clang_args?) that space separated arguments must be set in individual calls.
  2. Is it possible for clang_arg to behave with the principle of least surprise and work with spaces as expected?
  3. Amend tutorial's C++ section and provide code snippet how to add c++ support.
  4. Print clang command line to output so people could troubleshoot problems like this one.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the clang_arg and clang_args entry points and the tutorial's C++ section mentioned in the issue. Check how space-separated arguments are currently handled and where the clang command line is reported. Done means the argument behavior or documentation is clarified, the tutorial includes a working C++ example, and troubleshooting output is improved if feasible.

Written by the indexing model from the issue text.

Assessment

Tech stack
cpp, rust
Domain
developer-experience, documentation, tooling
Issue type
Feature
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.