rust-lang / rust-lang/rust-bindgen

bindgen does not emit functions for wasm32-unknown-emscripten

Open
#1,941 1 comment 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
struct Test {
    int test;
};

void test(struct Test *test);
Bindgen Invocation
$ bindgen input.h  -o bindings.rs -- --target=wasm32-unknown-emscripten
Actual Results
/* automatically generated by rust-bindgen 0.56.0 */

#[repr(C)]
#[derive(Debug, Copy, Clone)]
pub struct Test {
    pub test: ::std::os::raw::c_int,
}
#[test]
fn bindgen_test_layout_Test() {
    assert_eq!(
        ::std::mem::size_of::<Test>(),
        4usize,
        concat!("Size of: ", stringify!(Test))
    );
    assert_eq!(
        ::std::mem::align_of::<Test>(),
        4usize,
        concat!("Alignment of ", stringify!(Test))
    );
    assert_eq!(
        unsafe { &(*(::std::ptr::null::<Test>())).test as *const _ as usize },
        0usize,
        concat!(
            "Offset of field: ",
            stringify!(Test),
            "::",
            stringify!(test)
        )
    );
}
Expected Results

Functions getting emitted

By the way, asmjs-unknown-emscripten target doesn't work at all:

thread 'main' panicked at 'libclang error; possible causes include:
- Invalid flag syntax
- Unrecognized flags
- Invalid flag arguments
- File I/O errors
- Host vs. target architecture mismatch
If you encounter an error missing from this list, please file an issue or a PR!

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 by reproducing the bindgen invocation with the shown input.h and the wasm32-unknown-emscripten target, then trace target-specific function generation. Done means the generated bindings include the declared test function; separately verify whether the asmjs-unknown-emscripten failure is in scope.

Written by the indexing model from the issue text.

Assessment

Tech stack
cpp, rust, wasm
Domain
compilers, devtools
Issue type
Bug
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.