Skip to content

Improve troubleshooting experience #1456

New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Open
vchekan opened this issue Nov 30, 2018 · 5 comments
Open

Improve troubleshooting experience #1456

vchekan opened this issue Nov 30, 2018 · 5 comments

Comments

@vchekan
Copy link

vchekan commented Nov 30, 2018

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.
@vchekan vchekan changed the title Improve troubleshooting experiance Improve troubleshooting experience Nov 30, 2018
@emilio
Copy link
Contributor

emilio commented Dec 2, 2018

Yeah, I agree this is unfortunate. The right fix is fixing libclang so that we can get a diagnostic of why the translation unit creation failed.

But we should be able to detect at least a few common cases I guess.

The annoying bit of just using split_whitespace in clang_arg is that it would effectively break any kind of path with whitespace, which aren't common I guess, but are a possibility.

@pvdrz
Copy link
Contributor

pvdrz commented Sep 8, 2022

what about adding a bindgen option to do this: --cpp? we already modify clang_args anyway?

@kulp
Copy link
Member

kulp commented Sep 9, 2022

what about adding a bindgen option to do this: --cpp? we already modify clang_args anyway?

Personally I really think "cpp" should always mean "the C preprocessor" and not "C++", but I probably lost that battle.

I personally could imagine --cxx as a reasonable affordance for this papercut.

@pvdrz
Copy link
Contributor

pvdrz commented Sep 9, 2022

yeah --cxx works for me.

@pvdrz pvdrz mentioned this issue Sep 9, 2022
@kulp
Copy link
Member

kulp commented Sep 24, 2022

This issue probably overlaps #1855.

# for free to join this conversation on GitHub. Already have an account? # to comment
Projects
None yet
Development

No branches or pull requests

4 participants