rust-lang / rust-lang/rust-bindgen

Very strange cwd-dependent behavior

Open
#2,187 7 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

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

Description

Input C/C++ Header

I'm sorry, I have absolutely no idea how to go about minimizing this. (However, the linked headers have no system dependencies, at least.)

Bindgen Invocation

In this repo:

/crates/fmod-studio-sys>     bindgen inc/fmod_studio.h -o bindings.rs --no-prepend-enum-name \
    --blocklist-file inc/fmod.h \
    --blocklist-file inc/fmod_codec.h \
    --blocklist-file inc/fmod_common.h \
    --blocklist-file inc/fmod_dsp.h \
    --blocklist-file inc/fmod_dsp_effects.h \
    --blocklist-file inc/fmod_errors.h \
    --blocklist-file inc/fmod_output.h

/crates/fmod-studio-sys/inc> bindgen     fmod_studio.h -o bindings.rs --no-prepend-enum-name \
    --blocklist-file     fmod.h \
    --blocklist-file     fmod_codec.h \
    --blocklist-file     fmod_common.h \
    --blocklist-file     fmod_dsp.h \
    --blocklist-file     fmod_dsp_effects.h \
    --blocklist-file     fmod_errors.h \
    --blocklist-file     fmod_output.h
Expected Results

These two invocations would generate identical or nearly identical results.

Actual Results

The invocation from /crates/fmod-studio-sys uses old rust-target idioms (e.g. __BindgenUnionField instead of union) and does not include the definitions from the blocklisted files.

The invocation from /crates/fmod-studio-sys/inc uses current rust-target idioms (e.g. union instead of __BindgenUnionField) and includes the definitions from the blocklisted files.

--dump-preprocessed-input shows the only preprocessed input difference as the line directives' filenames. Something spooky is going on.

> bindgen --version
bindgen 0.59.2

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 both bindgen 0.59.2 invocations for inc/fmod_studio.h, including the listed --blocklist-file headers, from the two working directories. Compare --dump-preprocessed-input and generated bindings.rs; done means explaining the cwd-dependent differences and making both invocations produce identical or nearly identical results.

Written by the indexing model from the issue text.

Assessment

Tech stack
c, cpp, rust
Domain
compilers, tooling
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.