Skip to content

Bindgen tries to generate bindings for methods even with --ignore-methods #826

New issue

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

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

Already on GitHub? Sign in to your account

Closed
upsuper opened this issue Jul 18, 2017 · 3 comments
Closed
Labels

Comments

@upsuper
Copy link
Contributor

upsuper commented Jul 18, 2017

Input C/C++ Header

struct Foo {
  void test();
};

Bindgen Invocation

$ bindgen input.hpp --ignore-methods -- --target=i686-pc-win32

Actual Results

thread 'main' panicked at 'Invalid or unknown abi 4 for function "_bindgen_ty_id_2" FunctionSig { return_type: ItemId(6), argument_types: [(Some("this"), ItemId(4))], is_variadic: false, abi: Unknown(4) }', /Users/upsuper/.cargo-target/debug/build/bindgen-96ad8d9060ae5f67/out/codegen.rs:5987
stack backtrace:
   0: std::sys::imp::backtrace::tracing::imp::unwind_backtrace
   1: std::panicking::default_hook::{{closure}}
   2: std::panicking::default_hook
   3: std::panicking::rust_panic_with_hook
   4: std::panicking::begin_panic
   5: std::panicking::begin_panic_fmt
   6: <bindgen::ir::function::FunctionSig as bindgen::codegen::TryToRustTy>::try_to_rust_ty
   7: bindgen::codegen::utils::rust_fndecl_from_signature
   8: <bindgen::ir::function::Function as bindgen::codegen::CodeGenerator>::codegen
   9: <bindgen::ir::item::Item as bindgen::codegen::CodeGenerator>::codegen
  10: <bindgen::ir::module::Module as bindgen::codegen::CodeGenerator>::codegen::{{closure}}
  11: <bindgen::ir::module::Module as bindgen::codegen::CodeGenerator>::codegen
  12: <bindgen::ir::item::Item as bindgen::codegen::CodeGenerator>::codegen
  13: bindgen::codegen::codegen::{{closure}}
  14: bindgen::ir::context::BindgenContext::gen
  15: bindgen::codegen::codegen
  16: bindgen::Bindings::generate
  17: bindgen::Builder::generate
  18: bindgen::main::{{closure}}
  19: std::panicking::try::do_call
  20: __rust_maybe_catch_panic
  21: std::panicking::try
  22: std::panic::catch_unwind
  23: bindgen::main
  24: __rust_maybe_catch_panic
  25: std::rt::lang_start
  26: main

Expected Results

This panics when the target is win32 because we don't support thiscall, while for other platforms, it doesn't panic, but it still generates a binding function for the method.

RUST_LOG=bindgen Output

INFO:bindgen: Clang Version: clang version 4.0.0 (tags/RELEASE_400/final)
WARN:bindgen: Using clang (4, 0), expected (3, 9)
DEBUG:bindgen::ir::context: BindgenContext::add_item(Item { id: ItemId(0), local_id: Cell { value: None }, next_child_local_id: Cell { value: 1 }, canonical_name_cache: RefCell { value: None }, comment: None, annotations: Annotations { opaque: false, hide: false, use_instead_of: None, disallow_copy: false, private_fields: None, accessor_kind: None, constify_enum_variant: false }, parent_id: ItemId(0), kind: Module(Module { name: Some("root"), kind: Normal, children: {} }), detect_derive_debug_cycle: Cell { value: false }, detect_derive_copy_cycle: Cell { value: false } }, declaration: None, loc: None
DEBUG:bindgen::ir::item: Item::from_ty_with_id: ItemId(1)
	ty = Type(Foo, kind: Record, cconv: 100, decl: Cursor(Foo kind: StructDecl, loc: test.hpp:1:8, usr: Some("c:@S@Foo")), canon: Cursor(Foo kind: StructDecl, loc: test.hpp:1:8, usr: Some("c:@S@Foo"))),
	location = Cursor(Foo kind: StructDecl, loc: test.hpp:1:8, usr: Some("c:@S@Foo"))
DEBUG:bindgen::ir::context: builtin_or_resolved_ty: Type(Foo, kind: Record, cconv: 100, decl: Cursor(Foo kind: StructDecl, loc: test.hpp:1:8, usr: Some("c:@S@Foo")), canon: Cursor(Foo kind: StructDecl, loc: test.hpp:1:8, usr: Some("c:@S@Foo"))), Some(Cursor(Foo kind: StructDecl, loc: test.hpp:1:8, usr: Some("c:@S@Foo"))), None
DEBUG:bindgen::ir::context: Not resolved, maybe builtin?
DEBUG:bindgen::ir::context: builtin_or_resolved_ty: Type(Foo, kind: Record, cconv: 100, decl: Cursor(Foo kind: StructDecl, loc: test.hpp:1:8, usr: Some("c:@S@Foo")), canon: Cursor(Foo kind: StructDecl, loc: test.hpp:1:8, usr: Some("c:@S@Foo"))), Some(Cursor(Foo kind: StructDecl, loc: test.hpp:1:8, usr: Some("c:@S@Foo"))), None
DEBUG:bindgen::ir::context: Not resolved, maybe builtin?
DEBUG:bindgen::ir::ty: from_clang_ty: ItemId(1), ty: Type(Foo, kind: Record, cconv: 100, decl: Cursor(Foo kind: StructDecl, loc: test.hpp:1:8, usr: Some("c:@S@Foo")), canon: Cursor(Foo kind: StructDecl, loc: test.hpp:1:8, usr: Some("c:@S@Foo"))), loc: Cursor(Foo kind: StructDecl, loc: test.hpp:1:8, usr: Some("c:@S@Foo"))
DEBUG:bindgen::ir::ty: currently_parsed_types: [PartialType { decl: Cursor(Foo kind: StructDecl, loc: test.hpp:1:8, usr: Some("c:@S@Foo")), id: ItemId(1) }]
DEBUG:bindgen::ir::comp: CompInfo::from_ty(Struct, Cursor(Foo kind: StructDecl, loc: test.hpp:1:8, usr: Some("c:@S@Foo")))
DEBUG:bindgen::ir::function: Function::parse(Cursor(test kind: CXXMethod, loc: test.hpp:2:8, usr: Some("c:@S@Foo@F@test#")), Type(void () __attribute__((thiscall)), kind: FunctionProto, cconv: 4, decl: Cursor( kind: NoDeclFound, loc: builtin definitions, usr: None), canon: Cursor( kind: NoDeclFound, loc: builtin definitions, usr: None)))
DEBUG:bindgen::ir::item: Item::from_ty_with_id: ItemId(2)
	ty = Type(void () __attribute__((thiscall)), kind: FunctionProto, cconv: 4, decl: Cursor( kind: NoDeclFound, loc: builtin definitions, usr: None), canon: Cursor( kind: NoDeclFound, loc: builtin definitions, usr: None)),
	location = Cursor(test kind: CXXMethod, loc: test.hpp:2:8, usr: Some("c:@S@Foo@F@test#"))
DEBUG:bindgen::ir::context: builtin_or_resolved_ty: Type(void () __attribute__((thiscall)), kind: FunctionProto, cconv: 4, decl: Cursor( kind: NoDeclFound, loc: builtin definitions, usr: None), canon: Cursor( kind: NoDeclFound, loc: builtin definitions, usr: None)), Some(Cursor(test kind: CXXMethod, loc: test.hpp:2:8, usr: Some("c:@S@Foo@F@test#"))), None
DEBUG:bindgen::ir::context: Not resolved, maybe builtin?
DEBUG:bindgen::ir::context: builtin_or_resolved_ty: Type(void () __attribute__((thiscall)), kind: FunctionProto, cconv: 4, decl: Cursor( kind: NoDeclFound, loc: builtin definitions, usr: None), canon: Cursor( kind: NoDeclFound, loc: builtin definitions, usr: None)), Some(Cursor(test kind: CXXMethod, loc: test.hpp:2:8, usr: Some("c:@S@Foo@F@test#"))), None
DEBUG:bindgen::ir::context: Not resolved, maybe builtin?
DEBUG:bindgen::ir::ty: from_clang_ty: ItemId(2), ty: Type(void () __attribute__((thiscall)), kind: FunctionProto, cconv: 4, decl: Cursor( kind: NoDeclFound, loc: builtin definitions, usr: None), canon: Cursor( kind: NoDeclFound, loc: builtin definitions, usr: None)), loc: Cursor(test kind: CXXMethod, loc: test.hpp:2:8, usr: Some("c:@S@Foo@F@test#"))
DEBUG:bindgen::ir::ty: currently_parsed_types: [PartialType { decl: Cursor(Foo kind: StructDecl, loc: test.hpp:1:8, usr: Some("c:@S@Foo")), id: ItemId(1) }]
DEBUG:bindgen::ir::function: FunctionSig::from_ty Type(void () __attribute__((thiscall)), kind: FunctionProto, cconv: 4, decl: Cursor( kind: NoDeclFound, loc: builtin definitions, usr: None), canon: Cursor( kind: NoDeclFound, loc: builtin definitions, usr: None)) Cursor(test kind: CXXMethod, loc: test.hpp:2:8, usr: Some("c:@S@Foo@F@test#"))
DEBUG:bindgen::ir::item: Item::from_ty_with_id: ItemId(3)
	ty = Type(Foo, kind: Record, cconv: 100, decl: Cursor(Foo kind: StructDecl, loc: test.hpp:1:8, usr: Some("c:@S@Foo")), canon: Cursor(Foo kind: StructDecl, loc: test.hpp:1:8, usr: Some("c:@S@Foo"))),
	location = Cursor(Foo kind: StructDecl, loc: test.hpp:1:8, usr: Some("c:@S@Foo"))
DEBUG:bindgen::ir::context: builtin_or_resolved_ty: Type(Foo, kind: Record, cconv: 100, decl: Cursor(Foo kind: StructDecl, loc: test.hpp:1:8, usr: Some("c:@S@Foo")), canon: Cursor(Foo kind: StructDecl, loc: test.hpp:1:8, usr: Some("c:@S@Foo"))), Some(Cursor(Foo kind: StructDecl, loc: test.hpp:1:8, usr: Some("c:@S@Foo"))), None
DEBUG:bindgen::ir::context: Not resolved, maybe builtin?
DEBUG:bindgen::ir::item: Avoiding recursion parsing type: Type(Foo, kind: Record, cconv: 100, decl: Cursor(Foo kind: StructDecl, loc: test.hpp:1:8, usr: Some("c:@S@Foo")), canon: Cursor(Foo kind: StructDecl, loc: test.hpp:1:8, usr: Some("c:@S@Foo")))
DEBUG:bindgen::ir::context: BindgenContext::add_item(Item { id: ItemId(4), local_id: Cell { value: None }, next_child_local_id: Cell { value: 1 }, canonical_name_cache: RefCell { value: None }, comment: None, annotations: Annotations { opaque: false, hide: false, use_instead_of: None, disallow_copy: false, private_fields: None, accessor_kind: None, constify_enum_variant: false }, parent_id: ItemId(0), kind: Type(Type { name: None, layout: None, kind: Pointer(ItemId(1)), is_const: false }), detect_derive_debug_cycle: Cell { value: false }, detect_derive_copy_cycle: Cell { value: false } }, declaration: None, loc: None
DEBUG:bindgen::ir::context: add_item_to_module: adding ItemId(4) as child of parent module ItemId(0)
DEBUG:bindgen::ir::item: from_ty_or_ref_with_id: ItemId(5) Type(void, kind: Void, cconv: 100, decl: Cursor( kind: NoDeclFound, loc: builtin definitions, usr: None), canon: Cursor( kind: NoDeclFound, loc: builtin definitions, usr: None)), Cursor(test kind: CXXMethod, loc: test.hpp:2:8, usr: Some("c:@S@Foo@F@test#")), None
DEBUG:bindgen::ir::context: builtin_or_resolved_ty: Type(void, kind: Void, cconv: 100, decl: Cursor( kind: NoDeclFound, loc: builtin definitions, usr: None), canon: Cursor( kind: NoDeclFound, loc: builtin definitions, usr: None)), Some(Cursor(test kind: CXXMethod, loc: test.hpp:2:8, usr: Some("c:@S@Foo@F@test#"))), None
DEBUG:bindgen::ir::context: Not resolved, maybe builtin?
DEBUG:bindgen::ir::context: add_builtin_item: item = Item { id: ItemId(6), local_id: Cell { value: None }, next_child_local_id: Cell { value: 1 }, canonical_name_cache: RefCell { value: None }, comment: None, annotations: Annotations { opaque: false, hide: false, use_instead_of: None, disallow_copy: false, private_fields: None, accessor_kind: None, constify_enum_variant: false }, parent_id: ItemId(0), kind: Type(Type { name: Some("void"), layout: None, kind: Void, is_const: false }), detect_derive_debug_cycle: Cell { value: false }, detect_derive_copy_cycle: Cell { value: false } }
DEBUG:bindgen::ir::context: add_item_to_module: adding ItemId(6) as child of parent module ItemId(0)
DEBUG:bindgen::ir::item: ItemId(6) already resolved: Cursor(test kind: CXXMethod, loc: test.hpp:2:8, usr: Some("c:@S@Foo@F@test#"))
WARN:bindgen::ir::function: Unknown calling convention: 4
DEBUG:bindgen::ir::context: BindgenContext::add_item(Item { id: ItemId(2), local_id: Cell { value: None }, next_child_local_id: Cell { value: 1 }, canonical_name_cache: RefCell { value: None }, comment: None, annotations: Annotations { opaque: false, hide: false, use_instead_of: None, disallow_copy: false, private_fields: None, accessor_kind: None, constify_enum_variant: false }, parent_id: ItemId(0), kind: Type(Type { name: None, layout: Some(Layout { size: 1, align: 4, packed: false }), kind: Function(FunctionSig { return_type: ItemId(6), argument_types: [(Some("this"), ItemId(4))], is_variadic: false, abi: Unknown(4) }), is_const: false }), detect_derive_debug_cycle: Cell { value: false }, detect_derive_copy_cycle: Cell { value: false } }, declaration: Some(Cursor( kind: NoDeclFound, loc: builtin definitions, usr: None)), loc: Some(Cursor(test kind: CXXMethod, loc: test.hpp:2:8, usr: Some("c:@S@Foo@F@test#")))
DEBUG:bindgen::ir::context: add_item_to_module: adding ItemId(2) as child of parent module ItemId(0)
DEBUG:bindgen::ir::context: Invalid declaration Cursor( kind: NoDeclFound, loc: builtin definitions, usr: None) found for type Type { name: None, layout: Some(Layout { size: 1, align: 4, packed: false }), kind: Function(FunctionSig { return_type: ItemId(6), argument_types: [(Some("this"), ItemId(4))], is_variadic: false, abi: Unknown(4) }), is_const: false }
DEBUG:bindgen::ir::context: BindgenContext::add_item(Item { id: ItemId(7), local_id: Cell { value: None }, next_child_local_id: Cell { value: 1 }, canonical_name_cache: RefCell { value: None }, comment: None, annotations: Annotations { opaque: false, hide: false, use_instead_of: None, disallow_copy: false, private_fields: None, accessor_kind: None, constify_enum_variant: false }, parent_id: ItemId(1), kind: Function(Function { name: "test", mangled_name: Some("\u{1}?test@Foo@@QAEXXZ"), signature: ItemId(2), comment: None }), detect_derive_debug_cycle: Cell { value: false }, detect_derive_copy_cycle: Cell { value: false } }, declaration: Some(Cursor(test kind: CXXMethod, loc: test.hpp:2:8, usr: Some("c:@S@Foo@F@test#"))), loc: Some(Cursor(test kind: CXXMethod, loc: test.hpp:2:8, usr: Some("c:@S@Foo@F@test#")))
DEBUG:bindgen::ir::context: add_item_to_module: adding ItemId(7) as child of current module ItemId(0)
DEBUG:bindgen::ir::context: BindgenContext::add_item(Item { id: ItemId(1), local_id: Cell { value: None }, next_child_local_id: Cell { value: 1 }, canonical_name_cache: RefCell { value: None }, comment: None, annotations: Annotations { opaque: false, hide: false, use_instead_of: None, disallow_copy: false, private_fields: None, accessor_kind: None, constify_enum_variant: false }, parent_id: ItemId(0), kind: Type(Type { name: Some("Foo"), layout: Some(Layout { size: 1, align: 1, packed: false }), kind: Comp(CompInfo { kind: Struct, fields: BeforeComputingBitfieldUnits([]), template_params: [], methods: [Method { kind: Normal, signature: ItemId(7), is_const: false }], constructors: [], destructor: None, base_members: [], inner_types: [], inner_vars: [], has_vtable: false, has_destructor: false, has_nonempty_base: false, has_non_type_template_params: false, packed: false, found_unknown_attr: false, detect_derive_debug_cycle: Cell { value: false }, detect_derive_default_cycle: Cell { value: false }, detect_has_destructor_cycle: Cell { value: false }, is_forward_declaration: false }), is_const: false }), detect_derive_debug_cycle: Cell { value: false }, detect_derive_copy_cycle: Cell { value: false } }, declaration: Some(Cursor(Foo kind: StructDecl, loc: test.hpp:1:8, usr: Some("c:@S@Foo"))), loc: Some(Cursor(Foo kind: StructDecl, loc: test.hpp:1:8, usr: Some("c:@S@Foo")))
DEBUG:bindgen::ir::context: add_item_to_module: adding ItemId(1) as child of parent module ItemId(0)
DEBUG:bindgen::ir::context: No replacements to process
TRACE:bindgen::ir::named: constrain ItemId(2)
TRACE:bindgen::ir::named:   initially, used set is {}
TRACE:bindgen::ir::named:     other item: join with successors' usage
TRACE:bindgen::ir::named:       union with ItemId(6)'s usage: []
TRACE:bindgen::ir::named:       union with ItemId(4)'s usage: []
TRACE:bindgen::ir::named:   finally, used set is {}
TRACE:bindgen::ir::named: constrain ItemId(7)
TRACE:bindgen::ir::named:   initially, used set is {}
TRACE:bindgen::ir::named:     other item: join with successors' usage
TRACE:bindgen::ir::named:   finally, used set is {}
TRACE:bindgen::ir::named: constrain ItemId(6)
TRACE:bindgen::ir::named:   initially, used set is {}
TRACE:bindgen::ir::named:     other item: join with successors' usage
TRACE:bindgen::ir::named:   finally, used set is {}
TRACE:bindgen::ir::named: constrain ItemId(1)
TRACE:bindgen::ir::named:   initially, used set is {}
TRACE:bindgen::ir::named:     other item: join with successors' usage
TRACE:bindgen::ir::named:   finally, used set is {}
TRACE:bindgen::ir::named: constrain ItemId(4)
TRACE:bindgen::ir::named:   initially, used set is {}
TRACE:bindgen::ir::named:     other item: join with successors' usage
TRACE:bindgen::ir::named:       union with ItemId(1)'s usage: []
TRACE:bindgen::ir::named:   finally, used set is {}
TRACE:bindgen::ir::named: constrain ItemId(4)
TRACE:bindgen::ir::named:   initially, used set is {}
TRACE:bindgen::ir::named:     other item: join with successors' usage
TRACE:bindgen::ir::named:       union with ItemId(1)'s usage: []
TRACE:bindgen::ir::named:   finally, used set is {}
TRACE:bindgen::ir::named: constrain ItemId(6)
TRACE:bindgen::ir::named:   initially, used set is {}
TRACE:bindgen::ir::named:     other item: join with successors' usage
TRACE:bindgen::ir::named:   finally, used set is {}
TRACE:bindgen::ir::named: constrain ItemId(2)
TRACE:bindgen::ir::named:   initially, used set is {}
TRACE:bindgen::ir::named:     other item: join with successors' usage
TRACE:bindgen::ir::named:       union with ItemId(6)'s usage: []
TRACE:bindgen::ir::named:       union with ItemId(4)'s usage: []
TRACE:bindgen::ir::named:   finally, used set is {}
TRACE:bindgen::ir::named: constrain ItemId(7)
TRACE:bindgen::ir::named:   initially, used set is {}
TRACE:bindgen::ir::named:     other item: join with successors' usage
TRACE:bindgen::ir::named:   finally, used set is {}
TRACE:bindgen::ir::named: constrain ItemId(1)
TRACE:bindgen::ir::named:   initially, used set is {}
TRACE:bindgen::ir::named:     other item: join with successors' usage
TRACE:bindgen::ir::named:   finally, used set is {}
TRACE:bindgen::ir::named: constrain ItemId(0)
TRACE:bindgen::ir::named:   initially, used set is {}
TRACE:bindgen::ir::named:     other item: join with successors' usage
TRACE:bindgen::ir::named:   finally, used set is {}
DEBUG:bindgen::codegen: codegen: BindgenOptions { hidden_types: RegexSet { items: [], set: Some(RegexSet([])) }, opaque_types: RegexSet { items: [], set: Some(RegexSet([])) }, whitelisted_types: RegexSet { items: [], set: Some(RegexSet([])) }, whitelisted_functions: RegexSet { items: [], set: Some(RegexSet([])) }, whitelisted_vars: RegexSet { items: [], set: Some(RegexSet([])) }, bitfield_enums: RegexSet { items: [], set: Some(RegexSet([])) }, constified_enums: RegexSet { items: [], set: Some(RegexSet([])) }, constified_enum_modules: RegexSet { items: [], set: Some(RegexSet([])) }, builtins: false, links: [], emit_ast: false, emit_ir: false, emit_ir_graphviz: None, enable_cxx_namespaces: false, disable_name_namespacing: false, layout_tests: true, derive_debug: true, derive_default: false, unstable_rust: false, use_core: false, ctypes_prefix: None, namespaced_constants: true, msvc_mangling: false, convert_floats: true, raw_lines: [], clang_args: ["--target=i686-pc-win32", "test.hpp"], input_header: Some("test.hpp"), input_unsaved_files: [], dummy_uses: None, parse_callbacks: None, codegen_config: CodegenConfig { functions: true, types: true, vars: true, methods: false, constructors: true, destructors: true }, conservative_inline_namespaces: false, generate_comments: true, generate_inline_functions: false, whitelist_recursively: true, objc_extern_crate: false, enable_mangling: true, prepend_enum_name: true }
DEBUG:bindgen::codegen: <Item as CodeGenerator>::codegen: self = Item { id: ItemId(0), local_id: Cell { value: None }, next_child_local_id: Cell { value: 1 }, canonical_name_cache: RefCell { value: None }, comment: None, annotations: Annotations { opaque: false, hide: false, use_instead_of: None, disallow_copy: false, private_fields: None, accessor_kind: None, constify_enum_variant: false }, parent_id: ItemId(0), kind: Module(Module { name: Some("root"), kind: Normal, children: {ItemId(1), ItemId(2), ItemId(4), ItemId(6), ItemId(7)} }), detect_derive_debug_cycle: Cell { value: false }, detect_derive_copy_cycle: Cell { value: false } }
DEBUG:bindgen::codegen: <Module as CodeGenerator>::codegen: item = Item { id: ItemId(0), local_id: Cell { value: None }, next_child_local_id: Cell { value: 1 }, canonical_name_cache: RefCell { value: None }, comment: None, annotations: Annotations { opaque: false, hide: false, use_instead_of: None, disallow_copy: false, private_fields: None, accessor_kind: None, constify_enum_variant: false }, parent_id: ItemId(0), kind: Module(Module { name: Some("root"), kind: Normal, children: {ItemId(1), ItemId(2), ItemId(4), ItemId(6), ItemId(7)} }), detect_derive_debug_cycle: Cell { value: false }, detect_derive_copy_cycle: Cell { value: false } }
DEBUG:bindgen::codegen: <Item as CodeGenerator>::codegen: self = Item { id: ItemId(1), local_id: Cell { value: None }, next_child_local_id: Cell { value: 1 }, canonical_name_cache: RefCell { value: None }, comment: None, annotations: Annotations { opaque: false, hide: false, use_instead_of: None, disallow_copy: false, private_fields: None, accessor_kind: None, constify_enum_variant: false }, parent_id: ItemId(0), kind: Type(Type { name: Some("Foo"), layout: Some(Layout { size: 1, align: 1, packed: false }), kind: Comp(CompInfo { kind: Struct, fields: AfterComputingBitfieldUnits([]), template_params: [], methods: [Method { kind: Normal, signature: ItemId(7), is_const: false }], constructors: [], destructor: None, base_members: [], inner_types: [], inner_vars: [], has_vtable: false, has_destructor: false, has_nonempty_base: false, has_non_type_template_params: false, packed: false, found_unknown_attr: false, detect_derive_debug_cycle: Cell { value: false }, detect_derive_default_cycle: Cell { value: false }, detect_has_destructor_cycle: Cell { value: false }, is_forward_declaration: false }), is_const: false }), detect_derive_debug_cycle: Cell { value: false }, detect_derive_copy_cycle: Cell { value: false } }
DEBUG:bindgen::codegen: <Type as CodeGenerator>::codegen: item = Item { id: ItemId(1), local_id: Cell { value: None }, next_child_local_id: Cell { value: 1 }, canonical_name_cache: RefCell { value: None }, comment: None, annotations: Annotations { opaque: false, hide: false, use_instead_of: None, disallow_copy: false, private_fields: None, accessor_kind: None, constify_enum_variant: false }, parent_id: ItemId(0), kind: Type(Type { name: Some("Foo"), layout: Some(Layout { size: 1, align: 1, packed: false }), kind: Comp(CompInfo { kind: Struct, fields: AfterComputingBitfieldUnits([]), template_params: [], methods: [Method { kind: Normal, signature: ItemId(7), is_const: false }], constructors: [], destructor: None, base_members: [], inner_types: [], inner_vars: [], has_vtable: false, has_destructor: false, has_nonempty_base: false, has_non_type_template_params: false, packed: false, found_unknown_attr: false, detect_derive_debug_cycle: Cell { value: false }, detect_derive_default_cycle: Cell { value: false }, detect_has_destructor_cycle: Cell { value: false }, is_forward_declaration: false }), is_const: false }), detect_derive_debug_cycle: Cell { value: false }, detect_derive_copy_cycle: Cell { value: false } }
DEBUG:bindgen::codegen: <CompInfo as CodeGenerator>::codegen: item = Item { id: ItemId(1), local_id: Cell { value: None }, next_child_local_id: Cell { value: 1 }, canonical_name_cache: RefCell { value: None }, comment: None, annotations: Annotations { opaque: false, hide: false, use_instead_of: None, disallow_copy: false, private_fields: None, accessor_kind: None, constify_enum_variant: false }, parent_id: ItemId(0), kind: Type(Type { name: Some("Foo"), layout: Some(Layout { size: 1, align: 1, packed: false }), kind: Comp(CompInfo { kind: Struct, fields: AfterComputingBitfieldUnits([]), template_params: [], methods: [Method { kind: Normal, signature: ItemId(7), is_const: false }], constructors: [], destructor: None, base_members: [], inner_types: [], inner_vars: [], has_vtable: false, has_destructor: false, has_nonempty_base: false, has_non_type_template_params: false, packed: false, found_unknown_attr: false, detect_derive_debug_cycle: Cell { value: false }, detect_derive_default_cycle: Cell { value: false }, detect_has_destructor_cycle: Cell { value: false }, is_forward_declaration: false }), is_const: false }), detect_derive_debug_cycle: Cell { value: false }, detect_derive_copy_cycle: Cell { value: false } }
DEBUG:bindgen::codegen: <Item as CodeGenerator>::codegen: self = Item { id: ItemId(2), local_id: Cell { value: None }, next_child_local_id: Cell { value: 1 }, canonical_name_cache: RefCell { value: None }, comment: None, annotations: Annotations { opaque: false, hide: false, use_instead_of: None, disallow_copy: false, private_fields: None, accessor_kind: None, constify_enum_variant: false }, parent_id: ItemId(0), kind: Type(Type { name: None, layout: Some(Layout { size: 1, align: 4, packed: false }), kind: Function(FunctionSig { return_type: ItemId(6), argument_types: [(Some("this"), ItemId(4))], is_variadic: false, abi: Unknown(4) }), is_const: false }), detect_derive_debug_cycle: Cell { value: false }, detect_derive_copy_cycle: Cell { value: false } }
DEBUG:bindgen::codegen: <Type as CodeGenerator>::codegen: item = Item { id: ItemId(2), local_id: Cell { value: None }, next_child_local_id: Cell { value: 1 }, canonical_name_cache: RefCell { value: None }, comment: None, annotations: Annotations { opaque: false, hide: false, use_instead_of: None, disallow_copy: false, private_fields: None, accessor_kind: None, constify_enum_variant: false }, parent_id: ItemId(0), kind: Type(Type { name: None, layout: Some(Layout { size: 1, align: 4, packed: false }), kind: Function(FunctionSig { return_type: ItemId(6), argument_types: [(Some("this"), ItemId(4))], is_variadic: false, abi: Unknown(4) }), is_const: false }), detect_derive_debug_cycle: Cell { value: false }, detect_derive_copy_cycle: Cell { value: false } }
DEBUG:bindgen::codegen: <Item as CodeGenerator>::codegen: self = Item { id: ItemId(4), local_id: Cell { value: None }, next_child_local_id: Cell { value: 1 }, canonical_name_cache: RefCell { value: None }, comment: None, annotations: Annotations { opaque: false, hide: false, use_instead_of: None, disallow_copy: false, private_fields: None, accessor_kind: None, constify_enum_variant: false }, parent_id: ItemId(0), kind: Type(Type { name: None, layout: None, kind: Pointer(ItemId(1)), is_const: false }), detect_derive_debug_cycle: Cell { value: false }, detect_derive_copy_cycle: Cell { value: false } }
DEBUG:bindgen::codegen: <Type as CodeGenerator>::codegen: item = Item { id: ItemId(4), local_id: Cell { value: None }, next_child_local_id: Cell { value: 1 }, canonical_name_cache: RefCell { value: None }, comment: None, annotations: Annotations { opaque: false, hide: false, use_instead_of: None, disallow_copy: false, private_fields: None, accessor_kind: None, constify_enum_variant: false }, parent_id: ItemId(0), kind: Type(Type { name: None, layout: None, kind: Pointer(ItemId(1)), is_const: false }), detect_derive_debug_cycle: Cell { value: false }, detect_derive_copy_cycle: Cell { value: false } }
DEBUG:bindgen::codegen: <Item as CodeGenerator>::codegen: self = Item { id: ItemId(6), local_id: Cell { value: None }, next_child_local_id: Cell { value: 1 }, canonical_name_cache: RefCell { value: None }, comment: None, annotations: Annotations { opaque: false, hide: false, use_instead_of: None, disallow_copy: false, private_fields: None, accessor_kind: None, constify_enum_variant: false }, parent_id: ItemId(0), kind: Type(Type { name: Some("void"), layout: None, kind: Void, is_const: false }), detect_derive_debug_cycle: Cell { value: false }, detect_derive_copy_cycle: Cell { value: false } }
DEBUG:bindgen::codegen: <Type as CodeGenerator>::codegen: item = Item { id: ItemId(6), local_id: Cell { value: None }, next_child_local_id: Cell { value: 1 }, canonical_name_cache: RefCell { value: None }, comment: None, annotations: Annotations { opaque: false, hide: false, use_instead_of: None, disallow_copy: false, private_fields: None, accessor_kind: None, constify_enum_variant: false }, parent_id: ItemId(0), kind: Type(Type { name: Some("void"), layout: None, kind: Void, is_const: false }), detect_derive_debug_cycle: Cell { value: false }, detect_derive_copy_cycle: Cell { value: false } }
DEBUG:bindgen::codegen: <Item as CodeGenerator>::codegen: self = Item { id: ItemId(7), local_id: Cell { value: None }, next_child_local_id: Cell { value: 1 }, canonical_name_cache: RefCell { value: None }, comment: None, annotations: Annotations { opaque: false, hide: false, use_instead_of: None, disallow_copy: false, private_fields: None, accessor_kind: None, constify_enum_variant: false }, parent_id: ItemId(1), kind: Function(Function { name: "test", mangled_name: Some("\u{1}?test@Foo@@QAEXXZ"), signature: ItemId(2), comment: None }), detect_derive_debug_cycle: Cell { value: false }, detect_derive_copy_cycle: Cell { value: false } }
DEBUG:bindgen::codegen: <Function as CodeGenerator>::codegen: item = Item { id: ItemId(7), local_id: Cell { value: None }, next_child_local_id: Cell { value: 1 }, canonical_name_cache: RefCell { value: None }, comment: None, annotations: Annotations { opaque: false, hide: false, use_instead_of: None, disallow_copy: false, private_fields: None, accessor_kind: None, constify_enum_variant: false }, parent_id: ItemId(1), kind: Function(Function { name: "test", mangled_name: Some("\u{1}?test@Foo@@QAEXXZ"), signature: ItemId(2), comment: None }), detect_derive_debug_cycle: Cell { value: false }, detect_derive_copy_cycle: Cell { value: false } }
@upsuper
Copy link
Contributor Author

upsuper commented Jul 18, 2017

@fitzgen emilio told me you are investigating this, but I don't see any issue open, nor any pr related, so I just open one in case we forget. This is a blocker for stylo, as far as I can see.

@emilio
Copy link
Contributor

emilio commented Jul 18, 2017

Yeah, and the regressing PR is #770. I guess I can also look into it tomorrow.

@fitzgen
Copy link
Member

fitzgen commented Jul 19, 2017

Thanks for filing this.

First half of a fix is at #827.

If I leave the --target in the test case, I get this panic:

thread 'main' panicked at 'Invalid or unknown abi 4 for function "_bindgen_ty_id_2" FunctionSig { return_type: ItemId(6), argument_types: [(Some("this"), ItemId(4))], is_variadic: false, abi: Unknown(4) }', /home/fitzgen/rust-bindgen/target/debug/build/bindgen-60472a70a279b99b/out/codegen.rs:5987
stack backtrace:
   0: std::sys::imp::backtrace::tracing::imp::unwind_backtrace
             at /checkout/src/libstd/sys/unix/backtrace/tracing/gcc_s.rs:49
   1: std::sys_common::backtrace::_print
             at /checkout/src/libstd/sys_common/backtrace.rs:71
   2: std::panicking::default_hook::{{closure}}
             at /checkout/src/libstd/sys_common/backtrace.rs:60
             at /checkout/src/libstd/panicking.rs:355
   3: std::panicking::default_hook
             at /checkout/src/libstd/panicking.rs:371
   4: std::panicking::rust_panic_with_hook
             at /checkout/src/libstd/panicking.rs:549
   5: std::panicking::begin_panic
             at /checkout/src/libstd/panicking.rs:511
   6: std::panicking::begin_panic_fmt
             at /checkout/src/libstd/panicking.rs:495
   7: <bindgen::ir::function::FunctionSig as bindgen::codegen::TryToRustTy>::try_to_rust_ty
             at ./target/debug/build/bindgen-60472a70a279b99b/out/codegen.rs:5987
   8: bindgen::codegen::utils::rust_fndecl_from_signature
             at ./target/debug/build/bindgen-60472a70a279b99b/out/codegen.rs:7880
   9: <bindgen::ir::function::Function as bindgen::codegen::CodeGenerator>::codegen
             at ./target/debug/build/bindgen-60472a70a279b99b/out/codegen.rs:6031
  10: <bindgen::ir::item::Item as bindgen::codegen::CodeGenerator>::codegen
             at ./target/debug/build/bindgen-60472a70a279b99b/out/codegen.rs:1480
  11: <bindgen::ir::module::Module as bindgen::codegen::CodeGenerator>::codegen::{{closure}}
             at ./target/debug/build/bindgen-60472a70a279b99b/out/codegen.rs:1511
  12: <bindgen::ir::module::Module as bindgen::codegen::CodeGenerator>::codegen
             at ./target/debug/build/bindgen-60472a70a279b99b/out/codegen.rs:1535
  13: <bindgen::ir::item::Item as bindgen::codegen::CodeGenerator>::codegen
             at ./target/debug/build/bindgen-60472a70a279b99b/out/codegen.rs:1476
  14: bindgen::codegen::codegen::{{closure}}
             at ./target/debug/build/bindgen-60472a70a279b99b/out/codegen.rs:6285
  15: bindgen::ir::context::BindgenContext::gen
             at src/ir/context.rs:761
  16: bindgen::codegen::codegen
             at ./target/debug/build/bindgen-60472a70a279b99b/out/codegen.rs:6263
  17: bindgen::Bindings::generate
             at src/lib.rs:1200
  18: bindgen::Builder::generate
             at src/lib.rs:816
  19: bindgen::main::{{closure}}
             at src/main.rs:57
  20: std::panicking::try::do_call
             at /checkout/src/libstd/panicking.rs:454
  21: __rust_maybe_catch_panic
             at /checkout/src/libpanic_unwind/lib.rs:98
  22: std::panicking::try
             at /checkout/src/libstd/panicking.rs:433
  23: std::panic::catch_unwind
             at /checkout/src/libstd/panic.rs:361
  24: bindgen::main
             at src/main.rs:56
  25: __rust_maybe_catch_panic
             at /checkout/src/libpanic_unwind/lib.rs:98
  26: std::rt::lang_start
             at /checkout/src/libstd/panicking.rs:433
             at /checkout/src/libstd/panic.rs:361
             at /checkout/src/libstd/rt.rs:59
  27: main
  28: __libc_start_main
  29: _start

fitzgen added a commit to fitzgen/rust-bindgen that referenced this issue Jul 20, 2017
This makes only generating certain kinds of items more robust, since we don't
need to keep checking whether codegen is enabled for different kinds of items
all over the place, and can do it the once. It should also reduce the number of
items we have to consider in our various analyses for which we don't ultimately
care about the answer.

Fixes rust-lang#826
fitzgen added a commit to fitzgen/rust-bindgen that referenced this issue Jul 20, 2017
This makes only generating certain kinds of items more robust, since we don't
need to keep checking whether codegen is enabled for different kinds of items
all over the place, and can do it the once. It should also reduce the number of
items we have to consider in our various analyses for which we don't ultimately
care about the answer.

Fixes rust-lang#826
fitzgen added a commit to fitzgen/rust-bindgen that referenced this issue Jul 20, 2017
This makes only generating certain kinds of items more robust, since we don't
need to keep checking whether codegen is enabled for different kinds of items
all over the place, and can do it the once. It should also reduce the number of
items we have to consider in our various analyses for which we don't ultimately
care about the answer.

Fixes rust-lang#826
bors-servo pushed a commit that referenced this issue Jul 20, 2017
…not-to, r=emilio

Only whitelist items for which we intend to generate bindings

This means that we only need to check in one place, rather than at ever call site.

This makes it so that we don't generate methods for the test case, but if I add the `--target` flag like in the original #826 test case, then I get a panic about an unknown ABI. I figure this change is worth landing now, and we can land the fix for the panic as a follow up.

r? @upsuper
tmfink pushed a commit to tmfink/rust-bindgen that referenced this issue Aug 4, 2017
This makes only generating certain kinds of items more robust, since we don't
need to keep checking whether codegen is enabled for different kinds of items
all over the place, and can do it the once. It should also reduce the number of
items we have to consider in our various analyses for which we don't ultimately
care about the answer.

Fixes rust-lang#826
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants