rust-lang / rust-bindgen

Automatically generates Rust FFI bindings to C (and some C++) libraries.
https://rust-lang.github.io/rust-bindgen/
BSD 3-Clause "New" or "Revised" License
4.45k stars 694 forks source link

layout tests failing for Octave bindings on Linux #1682

Open ctaggart opened 4 years ago

ctaggart commented 4 years ago

There are 7 layout tests failing for my Octave bindings on Linux. https://github.com/ctaggart/octh/issues/38

failures:
    root::__bindgen_test_layout_base_list_open0_regexp_match_element_close0_instantiation
    root::octave::bindgen_test_layout_diary_buf
    root::octave::bindgen_test_layout_diary_stream
    root::octave::bindgen_test_layout_output_system
    root::octave::bindgen_test_layout_pager_buf
    root::octave::bindgen_test_layout_pager_stream
    root::octave::bindgen_test_layout_regexp_match_data

test result: FAILED. 362 passed; 7 failed; 0 ignored; 0 measured; 0 filtered out

I'm not sure if it is released by diary_stream was also mentioned in #1051.

Input C/C++ Header

I've been reducing it for the the last couple of weeks on a small VM in Azure. Unfortunately, it may take 3 more months to reduce down completely at the current rate. It is at 2210 lines. I'm committing progress of the creduce here https://github.com/ctaggart/octh/pull/41:

https://github.com/ctaggart/octh/blob/octh38/__bindgen.ii

Bindgen Invocation

creduce ./issue/octh38.sh __bindgen.ii

https://github.com/ctaggart/octh/blob/octh38/issue/octh38.sh

#!/bin/bash
# time creduce ./issue/octh38.sh __bindgen.ii

cp $HOME/github/octh/Cargo.toml .
cp $HOME/github/octh/build.rs .
mkdir src
cp $HOME/github/octh/src/lib.rs src
cp $HOME/github/octh/src/octhelp.cc src
cp $HOME/github/octh/src/octhelp.h src
BINDGEN_HEADER="__bindgen.ii" cargo test \
2>&1 \
| grep "thread 'root::octave::bindgen_test_layout_output_system' panicked at 'assertion failed:"

https://github.com/ctaggart/octh/blob/octh38/build.rs#L16-L29

    let mut builder = bindgen::Builder::default()
        .header(header)
        .clang_arg("-v") // verbose
        .clang_arg("-x") // -x c++
        .clang_arg("c++")
        .clang_arg("-std=gnu++11")
        .enable_cxx_namespaces()
        .whitelist_type("octave.*")
        .whitelist_function("octave.*")
        .opaque_type("octave.refcount")
        .use_core()
        .opaque_type("std::.*");
emilio commented 4 years ago

Sorry for the massive lag here. I can try to creduce on my desktop a bit more if I find the time. Sometimes creduce seems to get stuck and skipping some passes help substantially.

ctaggart commented 4 years ago

Great! I just pushed the latest https://github.com/ctaggart/octh/blob/octh38/__bindgen.ii from the Azure VM running creduce. It is down to 1819 lines.