rust-lang / rust-lang/rust-bindgen

passing -print-search-dirs causes panic with no helpful message

Open
#1,957 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

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

Description

I was trying to follow from where bindgen was pulling headers. I was suggested to pass the -print-search-dirs clang flag.
Unfortunately, this simply caused bindgen to panic, with a very generic error message. The backtrace also did not yield anything useful. This was on a Windows 10 system with LLVM 11 installed, and bindgen 0.56.0.

Bindgen Invocation
$ bindgen wrapper.h -- -print-search-dirs
Actual Results

Apologies for the screenshots, cannot copy-paste from a VM.

image

image

Backtrace on Linux, where the same thing happens:

   0: rust_begin_unwind
             at /rustc/7eac88abb2e57e752f3302f02be5f3ce3d7adfb4/library/std/src/panicking.rs:483
   1: core::panicking::panic_fmt
             at /rustc/7eac88abb2e57e752f3302f02be5f3ce3d7adfb4/library/core/src/panicking.rs:85
   2: core::option::expect_failed
             at /rustc/7eac88abb2e57e752f3302f02be5f3ce3d7adfb4/library/core/src/option.rs:1226
   3: bindgen::ir::context::BindgenContext::new
   4: bindgen::Builder::generate
   5: std::panicking::try
   6: bindgen::main

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

Reproduce the panic with bindgen wrapper.h -- -print-search-dirs, on a setup using clang if available. Start at bindgen::ir::context::BindgenContext::new and follow the call from bindgen::Builder::generate; done means this invocation reports a useful error instead of panicking.

Written by the indexing model from the issue text.

Assessment

Tech stack
rust
Domain
compilers
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
42/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.