Skip to content
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

Tagged unions inside template fail to build. #2157

Open
emilio opened this issue Feb 4, 2022 · 8 comments · May be fixed by #2764
Open

Tagged unions inside template fail to build. #2157

emilio opened this issue Feb 4, 2022 · 8 comments · May be fixed by #2764

Comments

@emilio
Copy link
Contributor

emilio commented Feb 4, 2022

This is sort of a rustc limitation, but we could try to detect it better.

Input C/C++ Header

template <typename _Tp, typename _Alloc>
struct _Vector_base {
  union _Storage {
    constexpr _Storage() : _M_byte() {}
    ~_Storage() {}
    _Storage& operator=(const _Storage&) = delete;
    unsigned char _M_byte;
    _Tp _M_val;
  };
};

Bindgen Invocation

$ bindgen input.hpp | rustc -

Actual Results

#[repr(C)]
#[derive(Debug, Copy, Clone)]
pub struct _Vector_base {
    pub _address: u8,
}
#[repr(C)]
pub union _Vector_base__Storage<_Tp> {
    pub _M_byte: ::std::os::raw::c_uchar,
    pub _M_val: _Tp,
    pub _phantom_0: ::std::marker::PhantomData<::std::cell::UnsafeCell<_Tp>>,
}

and/or

error[E0740]: unions may not contain fields that need dropping
  --> <anon>:11:5
   |
11 |     pub _M_val: _Tp,
   |     ^^^^^^^^^^^^^^^
   |
help: wrap the type with `std::mem::ManuallyDrop` and ensure it is manually dropped
   |
11 |     pub _M_val: std::mem::ManuallyDrop<_Tp>,
   |                 +++++++++++++++++++++++   +

error: aborting due to 2 previous errors

Expected Results

We should probably generate non-rust unions in this case, or add ManuallyDrop around all the types in a union or something like that.

@nicoburns
Copy link

I'm still getting this error (exactly the same as above except for the line number), even with the latest bindgen (0.62) and both .manually_drop_union(".*") and .default_non_copy_union_style(NonCopyUnionStyle::ManuallyDrop) in my bindgen config. Full config:

let bindings = bindgen::Builder::default()
        .rust_target(RustTarget::Stable_1_47)
        .no_convert_floats()
        .enable_cxx_namespaces()
        .allowlist_type("YG.*")
        .allowlist_function("YG.*")
        .allowlist_var("YG.*")
        .layout_tests(false)
        .rustfmt_bindings(true)
        .rustified_enum("YG.*")
        .manually_drop_union(".*")
        .default_non_copy_union_style(NonCopyUnionStyle::ManuallyDrop)
        .header("src/wrapper.hpp")
        .generate()
        .expect("Unable to generate bindings");

https://github.com/nicoburns/yoga-rs/blob/8b0550e1f2615fa44d8f9af9891e0d4d26042080/build.rs

Does anyone have any idea what could be causing this? It builds fine for me locally on macOS (aarch64), but it fails with this error on CI running on Ubuntu 20.04 (but with Rust 1.65 installed via Rustup).

@nicoburns
Copy link

@emilio

Ok, so I'm not quite sure why this happens, but the issue seems to be caused by linking against libstd++. For some reason bindgen defaulted to this on Github Actions CI. Forcing linking against libc++ with .clang_arg("-stdlib=libc++") fixes the CI build.

The offending generated code (which rustc won't compile) is:

#[repr(C)]
pub union vector__Temporary_value__Storage<_Tp> {
    pub _M_byte: ::std::os::raw::c_uchar,
    pub _M_val: _Tp,
    pub _phantom_0: ::std::marker::PhantomData<::std::cell::UnsafeCell<_Tp>>,
}

This is generated even with:

  • .manually_drop_union(".*")
  • .default_non_copy_union_style(NonCopyUnionStyle::ManuallyDrop)

both set. Which looks like a bug to me (although I'm not knowledgable enough about bindgen to be sure).

I have also included the full generated bindings (from the yoga-rs project) below in case they are helpful:

Full generated bindings (click to expand)

/* automatically generated by rust-bindgen 0.62.0 */

#[allow(non_snake_case, non_camel_case_types, non_upper_case_globals)]
pub mod root {
#[allow(unused_imports)]
use self::super::root;
pub mod std {
#[allow(unused_imports)]
use self::super::super::root;
pub type integral_constant_value_type<_Tp> = _Tp;
pub type integral_constant_type = u8;
pub type true_type = u8;
pub type false_type = u8;
#[repr(C)]
#[derive(Debug, Copy, Clone)]
pub struct _and {
pub _address: u8,
}
#[repr(C)]
#[derive(Debug, Copy, Clone)]
pub struct is_empty {
pub _address: u8,
}
#[repr(C)]
#[derive(Debug, Copy, Clone)]
pub struct make_unsigned {
pub _address: u8,
}
pub type make_unsigned_type = u8;
pub type __enable_if_t = u8;
#[repr(C)]
#[derive(Debug, Copy, Clone)]
pub struct __detector {
pub _address: u8,
}
pub type __detector_value_t = root::std::false_type;
pub type __detector_type<_Default> = _Default;
pub type __detected_or = root::std::__detector;
pub type __detected_or_t = root::std::__detected_or;
#[repr(C)]
#[derive(Debug, Copy, Clone)]
pub struct function {
pub _address: u8,
}
#[repr(C)]
#[derive(Debug, Copy, Clone)]
pub struct iterator {
pub _address: u8,
}
pub type iterator_iterator_category<_Category> = _Category;
pub type iterator_value_type<_Tp> = _Tp;
pub type iterator_difference_type<_Distance> = _Distance;
pub type iterator_pointer<_Pointer> = _Pointer;
pub type iterator_reference<_Reference> = _Reference;
#[repr(C)]
#[derive(Debug, Copy, Clone)]
pub struct __iterator_traits {
pub _address: u8,
}
#[repr(C)]
#[derive(Debug, Copy, Clone)]
pub struct iterator_traits {
pub _address: u8,
}
#[repr(C)]
#[derive(Debug, Copy, Clone)]
pub struct __undefined {
_unused: [u8; 0],
}
#[repr(C)]
#[derive(Debug, Copy, Clone)]
pub struct __get_first_arg {
pub _address: u8,
}
pub type __get_first_arg_type = root::std::__undefined;
#[repr(C)]
#[derive(Debug, Copy, Clone)]
pub struct __replace_first_arg {
pub _address: u8,
}
#[repr(C)]
#[derive(Debug, Copy, Clone)]
pub struct __ptr_traits_elem {
pub _address: u8,
}
pub type __ptr_traits_elem_t = root::std::__ptr_traits_elem;
pub type __ptr_traits_ptr_to_pointer<_Ptr> = _Ptr;
pub type __ptr_traits_ptr_to_element_type<_Elt> = _Elt;
#[repr(C)]
#[derive(Debug, Copy, Clone)]
pub struct __ptr_traits_impl {
pub _address: u8,
}
#[repr(C)]
#[derive(Debug, Copy, Clone)]
pub struct __ptr_traits_impl___difference {
pub _address: u8,
}
pub type __ptr_traits_impl___difference_type = isize;
#[repr(C)]
#[derive(Debug, Copy, Clone)]
pub struct __ptr_traits_impl___rebind {
pub _address: u8,
}
pub type __ptr_traits_impl_pointer<_Ptr> = _Ptr;
pub type __ptr_traits_impl_element_type<_Elt> = _Elt;
pub type __ptr_traits_impl_difference_type = root::std::__ptr_traits_impl___difference;
pub type __ptr_traits_impl_rebind = root::std::__ptr_traits_impl___rebind;
#[repr(C)]
#[derive(Debug, Copy, Clone)]
pub struct pointer_traits {
pub _address: u8,
}
#[repr(C)]
#[derive(Debug, Copy, Clone)]
pub struct reverse_iterator<_Iterator> {
pub current: _Iterator,
pub _phantom_0: ::std::marker::PhantomData<::std::cell::UnsafeCell<_Iterator>>,
}
pub type reverse_iterator___traits_type = root::std::iterator_traits;
pub type reverse_iterator_iterator_type<_Iterator> = _Iterator;
pub type reverse_iterator_pointer = root::std::reverse_iterator___traits_type;
pub type reverse_iterator_difference_type = root::std::reverse_iterator___traits_type;
pub type reverse_iterator_reference = root::std::reverse_iterator___traits_type;
#[repr(C)]
#[derive(Debug)]
pub struct __new_allocator {
pub _address: u8,
}
pub type __new_allocator_value_type<_Tp> = _Tp;
pub type __new_allocator_size_type = usize;
pub type __new_allocator_difference_type = isize;
pub type __new_allocator_pointer<_Tp> = *mut _Tp;
pub type __new_allocator_const_pointer<_Tp> = *const _Tp;
pub type __new_allocator_reference<_Tp> = *mut _Tp;
pub type __new_allocator_const_reference<_Tp> = *const _Tp;
#[repr(C)]
#[derive(Debug, Copy, Clone)]
pub struct __new_allocator_rebind {
pub _address: u8,
}
pub type __new_allocator_propagate_on_container_move_assignment = root::std::true_type;
pub type __allocator_base = root::std::__new_allocator;
#[repr(C)]
#[derive(Debug)]
pub struct allocator {
pub _address: u8,
}
pub type allocator_value_type<_Tp> = _Tp;
pub type allocator_size_type = usize;
pub type allocator_difference_type = isize;
pub type allocator_pointer<_Tp> = *mut _Tp;
pub type allocator_const_pointer<_Tp> = *const _Tp;
pub type allocator_reference<_Tp> = *mut _Tp;
pub type allocator_const_reference<_Tp> = *const _Tp;
#[repr(C)]
#[derive(Debug, Copy, Clone)]
pub struct allocator_rebind {
pub _address: u8,
}
pub type allocator_rebind_other = root::std::allocator;
pub type allocator_propagate_on_container_move_assignment = root::std::true_type;
pub type allocator_is_always_equal = root::std::true_type;
#[repr(C)]
#[derive(Debug, Copy, Clone)]
pub struct __allocator_traits_base {
pub _address: u8,
}
#[repr(C)]
#[derive(Debug, Copy, Clone)]
pub struct __allocator_traits_base___rebind {
pub _address: u8,
}
pub type __allocator_traits_base___pointer = [u8; 0usize];
pub type __allocator_traits_base___c_pointer = [u8; 0usize];
pub type __allocator_traits_base___v_pointer = [u8; 0usize];
pub type __allocator_traits_base___cv_pointer = [u8; 0usize];
pub type __allocator_traits_base___pocca = [u8; 0usize];
pub type __allocator_traits_base___pocma = [u8; 0usize];
pub type __allocator_traits_base___pocs = [u8; 0usize];
pub type __allocator_traits_base___equal = [u8; 0usize];
pub type __alloc_rebind = root::std::__allocator_traits_base;
#[repr(C)]
#[derive(Debug, Copy, Clone)]
pub struct allocator_traits {
pub _address: u8,
}
pub type allocator_traits_allocator_type<_Alloc> = _Alloc;
pub type allocator_traits_value_type = [u8; 0usize];
pub type allocator_traits_pointer = root::std::__detected_or_t;
#[repr(C)]
#[derive(Debug, Copy, Clone)]
pub struct allocator_traits__Ptr {
pub _address: u8,
}
pub type allocator_traits__Ptr_type = [u8; 0usize];
#[repr(C)]
#[derive(Debug, Copy, Clone)]
pub struct allocator_traits__Diff {
pub _address: u8,
}
pub type allocator_traits__Diff_type = root::std::pointer_traits;
#[repr(C)]
#[derive(Debug, Copy, Clone)]
pub struct allocator_traits__Size {
pub _address: u8,
}
pub type allocator_traits_const_pointer = [u8; 0usize];
pub type allocator_traits_void_pointer = root::std::allocator_traits__Ptr;
pub type allocator_traits_const_void_pointer = root::std::allocator_traits__Ptr;
pub type allocator_traits_difference_type = [u8; 0usize];
pub type allocator_traits_size_type = [u8; 0usize];
pub type allocator_traits_propagate_on_container_copy_assignment =
root::std::__detected_or_t;
pub type allocator_traits_propagate_on_container_move_assignment =
root::std::__detected_or_t;
pub type allocator_traits_propagate_on_container_swap = root::std::__detected_or_t;
pub type allocator_traits_is_always_equal = root::std::__detected_or_t;
pub type allocator_traits_rebind_alloc = root::std::__alloc_rebind;
pub type allocator_traits_rebind_traits = root::std::allocator_traits;
#[repr(C)]
#[derive(Debug, Copy, Clone)]
pub struct allocator_traits___construct_helper {
pub _address: u8,
}
pub type allocator_traits___construct_helper_type<_Alloc> = _Alloc;
pub type allocator_traits___has_construct = root::std::allocator_traits___construct_helper;
#[repr(C)]
pub struct _Vector_base {
pub _M_impl: root::std::_Vector_base__Vector_impl,
}
pub type _Vector_base__Tp_alloc_type = [u8; 0usize];
pub type _Vector_base_pointer = [u8; 0usize];
#[repr(C)]
pub struct _Vector_base__Vector_impl_data {
pub _M_start: root::std::_Vector_base_pointer,
pub _M_finish: root::std::_Vector_base_pointer,
pub _M_end_of_storage: root::std::_Vector_base_pointer,
}
#[repr(C)]
pub struct _Vector_base__Vector_impl {
pub _base_1: root::std::_Vector_base__Vector_impl_data,
}
pub type _Vector_base_allocator_type<_Alloc> = _Alloc;
#[repr(C)]
pub struct vector {
pub _base: root::std::_Vector_base,
}
pub type vector__Base = root::std::_Vector_base;
pub type vector__Tp_alloc_type = root::std::vector__Base;
pub type vector__Alloc_traits = root::__gnu_cxx::__alloc_traits;
pub type vector_value_type<_Tp> = _Tp;
pub type vector_pointer = root::std::vector__Base;
pub type vector_const_pointer = root::std::vector__Alloc_traits;
pub type vector_reference = root::std::vector__Alloc_traits;
pub type vector_const_reference = root::std::vector__Alloc_traits;
pub type vector_iterator = root::__gnu_cxx::__normal_iteratorroot::std::vector_pointer;
pub type vector_const_iterator =
root::__gnu_cxx::__normal_iteratorroot::std::vector_const_pointer;
pub type vector_const_reverse_iterator =
root::std::reverse_iteratorroot::std::vector_const_iterator;
pub type vector_reverse_iterator = root::std::reverse_iteratorroot::std::vector_iterator;
pub type vector_size_type = usize;
pub type vector_difference_type = isize;
pub type vector_allocator_type<_Alloc> = _Alloc;
#[repr(C)]
pub struct vector__Temporary_value<_Tp> {
pub _M_this: *mut root::std::vector,
pub _M_storage: root::std::vector__Temporary_value__Storage<_Tp>,
pub _phantom_0: ::std::marker::PhantomData<::std::cell::UnsafeCell<_Tp>>,
}
#[repr(C)]
pub union vector__Temporary_value__Storage<_Tp> {
pub _M_byte: ::std::os::raw::c_uchar,
pub _M_val: _Tp,
pub _phantom_0: ::std::marker::PhantomData<::std::cell::UnsafeCell<_Tp>>,
}
}
pub mod __gnu_cxx {
#[allow(unused_imports)]
use self::super::super::root;
#[repr(C)]
#[derive(Debug, Copy, Clone)]
pub struct __normal_iterator<_Iterator> {
pub _M_current: _Iterator,
pub _phantom_0: ::std::marker::PhantomData<::std::cell::UnsafeCell<_Iterator>>,
}
pub type __normal_iterator___traits_type = root::std::iterator_traits;
pub type __normal_iterator___convertible_from = root::std::__enable_if_t;
pub type __normal_iterator_iterator_type<_Iterator> = _Iterator;
pub type __normal_iterator_iterator_category =
root::__gnu_cxx::__normal_iterator___traits_type;
pub type __normal_iterator_value_type = root::__gnu_cxx::__normal_iterator___traits_type;
pub type __normal_iterator_difference_type =
root::__gnu_cxx::__normal_iterator___traits_type;
pub type __normal_iterator_reference = root::__gnu_cxx::__normal_iterator___traits_type;
pub type __normal_iterator_pointer = root::__gnu_cxx::__normal_iterator___traits_type;
#[repr(C)]
#[derive(Debug, Copy, Clone)]
pub struct __alloc_traits {
pub _address: u8,
}
pub type __alloc_traits_allocator_type<_Alloc> = _Alloc;
pub type __alloc_traits__Base_type = root::std::allocator_traits;
pub type __alloc_traits_value_type = root::__gnu_cxx::__alloc_traits__Base_type;
pub type __alloc_traits_pointer = root::__gnu_cxx::__alloc_traits__Base_type;
pub type __alloc_traits_const_pointer = root::__gnu_cxx::__alloc_traits__Base_type;
pub type __alloc_traits_size_type = root::__gnu_cxx::__alloc_traits__Base_type;
pub type __alloc_traits_difference_type = root::__gnu_cxx::__alloc_traits__Base_type;
pub type __alloc_traits_reference = *mut root::__gnu_cxx::__alloc_traits_value_type;
pub type __alloc_traits_const_reference = *const root::__gnu_cxx::__alloc_traits_value_type;
pub type __alloc_traits___is_custom_pointer = root::std::_and;
#[repr(C)]
#[derive(Debug, Copy, Clone)]
pub struct __alloc_traits_rebind {
pub _address: u8,
}
pub type __alloc_traits_rebind_other = root::__gnu_cxx::__alloc_traits__Base_type;
}
pub mod facebook {
#[allow(unused_imports)]
use self::super::super::root;
pub mod yoga {
#[allow(unused_imports)]
use self::super::super::super::root;
pub mod enums {
#[allow(unused_imports)]
use self::super::super::super::super::root;
}
}
}
#[repr(u32)]
#[derive(Debug, Copy, Clone, Hash, PartialEq, Eq)]
pub enum YGAlign {
YGAlignAuto = 0,
YGAlignFlexStart = 1,
YGAlignCenter = 2,
YGAlignFlexEnd = 3,
YGAlignStretch = 4,
YGAlignBaseline = 5,
YGAlignSpaceBetween = 6,
YGAlignSpaceAround = 7,
}
extern "C" {
pub fn YGAlignToString(arg1: root::YGAlign) -> *const ::std::os::raw::c_char;
}
#[repr(u32)]
#[derive(Debug, Copy, Clone, Hash, PartialEq, Eq)]
pub enum YGDimension {
YGDimensionWidth = 0,
YGDimensionHeight = 1,
}
extern "C" {
pub fn YGDimensionToString(arg1: root::YGDimension) -> *const ::std::os::raw::c_char;
}
#[repr(u32)]
#[derive(Debug, Copy, Clone, Hash, PartialEq, Eq)]
pub enum YGDirection {
YGDirectionInherit = 0,
YGDirectionLTR = 1,
YGDirectionRTL = 2,
}
extern "C" {
pub fn YGDirectionToString(arg1: root::YGDirection) -> *const ::std::os::raw::c_char;
}
#[repr(u32)]
#[derive(Debug, Copy, Clone, Hash, PartialEq, Eq)]
pub enum YGDisplay {
YGDisplayFlex = 0,
YGDisplayNone = 1,
}
extern "C" {
pub fn YGDisplayToString(arg1: root::YGDisplay) -> *const ::std::os::raw::c_char;
}
#[repr(u32)]
#[derive(Debug, Copy, Clone, Hash, PartialEq, Eq)]
pub enum YGEdge {
YGEdgeLeft = 0,
YGEdgeTop = 1,
YGEdgeRight = 2,
YGEdgeBottom = 3,
YGEdgeStart = 4,
YGEdgeEnd = 5,
YGEdgeHorizontal = 6,
YGEdgeVertical = 7,
YGEdgeAll = 8,
}
extern "C" {
pub fn YGEdgeToString(arg1: root::YGEdge) -> *const ::std::os::raw::c_char;
}
#[repr(u32)]
#[derive(Debug, Copy, Clone, Hash, PartialEq, Eq)]
pub enum YGExperimentalFeature {
YGExperimentalFeatureWebFlexBasis = 0,
}
extern "C" {
pub fn YGExperimentalFeatureToString(
arg1: root::YGExperimentalFeature,
) -> *const ::std::os::raw::c_char;
}
#[repr(u32)]
#[derive(Debug, Copy, Clone, Hash, PartialEq, Eq)]
pub enum YGFlexDirection {
YGFlexDirectionColumn = 0,
YGFlexDirectionColumnReverse = 1,
YGFlexDirectionRow = 2,
YGFlexDirectionRowReverse = 3,
}
extern "C" {
pub fn YGFlexDirectionToString(
arg1: root::YGFlexDirection,
) -> *const ::std::os::raw::c_char;
}
#[repr(u32)]
#[derive(Debug, Copy, Clone, Hash, PartialEq, Eq)]
pub enum YGGutter {
YGGutterColumn = 0,
YGGutterRow = 1,
YGGutterAll = 2,
}
extern "C" {
pub fn YGGutterToString(arg1: root::YGGutter) -> *const ::std::os::raw::c_char;
}
#[repr(u32)]
#[derive(Debug, Copy, Clone, Hash, PartialEq, Eq)]
pub enum YGJustify {
YGJustifyFlexStart = 0,
YGJustifyCenter = 1,
YGJustifyFlexEnd = 2,
YGJustifySpaceBetween = 3,
YGJustifySpaceAround = 4,
YGJustifySpaceEvenly = 5,
}
extern "C" {
pub fn YGJustifyToString(arg1: root::YGJustify) -> *const ::std::os::raw::c_char;
}
#[repr(u32)]
#[derive(Debug, Copy, Clone, Hash, PartialEq, Eq)]
pub enum YGLogLevel {
YGLogLevelError = 0,
YGLogLevelWarn = 1,
YGLogLevelInfo = 2,
YGLogLevelDebug = 3,
YGLogLevelVerbose = 4,
YGLogLevelFatal = 5,
}
extern "C" {
pub fn YGLogLevelToString(arg1: root::YGLogLevel) -> *const ::std::os::raw::c_char;
}
#[repr(u32)]
#[derive(Debug, Copy, Clone, Hash, PartialEq, Eq)]
pub enum YGMeasureMode {
YGMeasureModeUndefined = 0,
YGMeasureModeExactly = 1,
YGMeasureModeAtMost = 2,
}
extern "C" {
pub fn YGMeasureModeToString(arg1: root::YGMeasureMode) -> *const ::std::os::raw::c_char;
}
#[repr(u32)]
#[derive(Debug, Copy, Clone, Hash, PartialEq, Eq)]
pub enum YGNodeType {
YGNodeTypeDefault = 0,
YGNodeTypeText = 1,
}
extern "C" {
pub fn YGNodeTypeToString(arg1: root::YGNodeType) -> *const ::std::os::raw::c_char;
}
#[repr(u32)]
#[derive(Debug, Copy, Clone, Hash, PartialEq, Eq)]
pub enum YGOverflow {
YGOverflowVisible = 0,
YGOverflowHidden = 1,
YGOverflowScroll = 2,
}
extern "C" {
pub fn YGOverflowToString(arg1: root::YGOverflow) -> *const ::std::os::raw::c_char;
}
#[repr(u32)]
#[derive(Debug, Copy, Clone, Hash, PartialEq, Eq)]
pub enum YGPositionType {
YGPositionTypeStatic = 0,
YGPositionTypeRelative = 1,
YGPositionTypeAbsolute = 2,
}
extern "C" {
pub fn YGPositionTypeToString(arg1: root::YGPositionType) -> *const ::std::os::raw::c_char;
}
#[repr(u32)]
#[derive(Debug, Copy, Clone, Hash, PartialEq, Eq)]
pub enum YGPrintOptions {
YGPrintOptionsLayout = 1,
YGPrintOptionsStyle = 2,
YGPrintOptionsChildren = 4,
}
extern "C" {
pub fn YGPrintOptionsToString(arg1: root::YGPrintOptions) -> *const ::std::os::raw::c_char;
}
#[repr(u32)]
#[derive(Debug, Copy, Clone, Hash, PartialEq, Eq)]
pub enum YGUnit {
YGUnitUndefined = 0,
YGUnitPoint = 1,
YGUnitPercent = 2,
YGUnitAuto = 3,
}
extern "C" {
pub fn YGUnitToString(arg1: root::YGUnit) -> *const ::std::os::raw::c_char;
}
#[repr(u32)]
#[derive(Debug, Copy, Clone, Hash, PartialEq, Eq)]
pub enum YGWrap {
YGWrapNoWrap = 0,
YGWrapWrap = 1,
YGWrapWrapReverse = 2,
}
extern "C" {
pub fn YGWrapToString(arg1: root::YGWrap) -> *const ::std::os::raw::c_char;
}
#[repr(C)]
#[derive(Debug, Copy, Clone)]
pub struct YGValue {
pub value: ::std::os::raw::c_float,
pub unit: root::YGUnit,
}
extern "C" {
pub static YGValueAuto: root::YGValue;
}
extern "C" {
pub static YGValueUndefined: root::YGValue;
}
extern "C" {
pub static YGValueZero: root::YGValue;
}
pub type va_list = root::__builtin_va_list;
#[repr(C)]
#[derive(Debug, Copy, Clone)]
pub struct YGSize {
pub width: ::std::os::raw::c_float,
pub height: ::std::os::raw::c_float,
}
#[repr(C)]
#[derive(Debug, Copy, Clone)]
pub struct YGConfig {
_unused: [u8; 0],
}
pub type YGConfigRef = *mut root::YGConfig;
#[repr(C)]
#[derive(Debug, Copy, Clone)]
pub struct YGNode {
_unused: [u8; 0],
}
pub type YGNodeRef = *mut root::YGNode;
pub type YGNodeConstRef = *const root::YGNode;
pub type YGMeasureFunc = ::std::option::Option<
unsafe extern "C" fn(
node: root::YGNodeRef,
width: ::std::os::raw::c_float,
widthMode: root::YGMeasureMode,
height: ::std::os::raw::c_float,
heightMode: root::YGMeasureMode,
) -> root::YGSize,
>;
pub type YGBaselineFunc = ::std::option::Option<
unsafe extern "C" fn(
node: root::YGNodeRef,
width: ::std::os::raw::c_float,
height: ::std::os::raw::c_float,
) -> ::std::os::raw::c_float,
>;
pub type YGDirtiedFunc = ::std::option::Option<unsafe extern "C" fn(node: root::YGNodeRef)>;
pub type YGPrintFunc = ::std::option::Option<unsafe extern "C" fn(node: root::YGNodeRef)>;
pub type YGNodeCleanupFunc = ::std::option::Option<unsafe extern "C" fn(node: root::YGNodeRef)>;
pub type YGLogger = ::std::option::Option<
unsafe extern "C" fn(
config: root::YGConfigRef,
node: root::YGNodeRef,
level: root::YGLogLevel,
format: *const ::std::os::raw::c_char,
args: *mut root::__va_list_tag,
) -> ::std::os::raw::c_int,
>;
pub type YGCloneNodeFunc = ::std::option::Option<
unsafe extern "C" fn(
oldNode: root::YGNodeRef,
owner: root::YGNodeRef,
childIndex: ::std::os::raw::c_int,
) -> root::YGNodeRef,
>;
extern "C" {
pub fn YGNodeNew() -> root::YGNodeRef;
}
extern "C" {
pub fn YGNodeNewWithConfig(config: root::YGConfigRef) -> root::YGNodeRef;
}
extern "C" {
pub fn YGNodeClone(node: root::YGNodeRef) -> root::YGNodeRef;
}
extern "C" {
pub fn YGNodeFree(node: root::YGNodeRef);
}
extern "C" {
pub fn YGNodeFreeRecursiveWithCleanupFunc(
node: root::YGNodeRef,
cleanup: root::YGNodeCleanupFunc,
);
}
extern "C" {
pub fn YGNodeFreeRecursive(node: root::YGNodeRef);
}
extern "C" {
pub fn YGNodeReset(node: root::YGNodeRef);
}
extern "C" {
pub fn YGNodeInsertChild(node: root::YGNodeRef, child: root::YGNodeRef, index: u32);
}
extern "C" {
pub fn YGNodeSwapChild(node: root::YGNodeRef, child: root::YGNodeRef, index: u32);
}
extern "C" {
pub fn YGNodeRemoveChild(node: root::YGNodeRef, child: root::YGNodeRef);
}
extern "C" {
pub fn YGNodeRemoveAllChildren(node: root::YGNodeRef);
}
extern "C" {
pub fn YGNodeGetChild(node: root::YGNodeRef, index: u32) -> root::YGNodeRef;
}
extern "C" {
pub fn YGNodeGetOwner(node: root::YGNodeRef) -> root::YGNodeRef;
}
extern "C" {
pub fn YGNodeGetParent(node: root::YGNodeRef) -> root::YGNodeRef;
}
extern "C" {
pub fn YGNodeGetChildCount(node: root::YGNodeRef) -> u32;
}
extern "C" {
pub fn YGNodeSetChildren(
owner: root::YGNodeRef,
children: *const root::YGNodeRef,
count: u32,
);
}
extern "C" {
pub fn YGNodeSetIsReferenceBaseline(node: root::YGNodeRef, isReferenceBaseline: bool);
}
extern "C" {
pub fn YGNodeIsReferenceBaseline(node: root::YGNodeRef) -> bool;
}
extern "C" {
pub fn YGNodeCalculateLayout(
node: root::YGNodeRef,
availableWidth: ::std::os::raw::c_float,
availableHeight: ::std::os::raw::c_float,
ownerDirection: root::YGDirection,
);
}
extern "C" {
pub fn YGNodeMarkDirty(node: root::YGNodeRef);
}
extern "C" {
pub fn YGNodeMarkDirtyAndPropogateToDescendants(node: root::YGNodeRef);
}
extern "C" {
pub fn YGNodePrint(node: root::YGNodeRef, options: root::YGPrintOptions);
}
extern "C" {
pub fn YGFloatIsUndefined(value: ::std::os::raw::c_float) -> bool;
}
extern "C" {
pub fn YGNodeCanUseCachedMeasurement(
widthMode: root::YGMeasureMode,
width: ::std::os::raw::c_float,
heightMode: root::YGMeasureMode,
height: ::std::os::raw::c_float,
lastWidthMode: root::YGMeasureMode,
lastWidth: ::std::os::raw::c_float,
lastHeightMode: root::YGMeasureMode,
lastHeight: ::std::os::raw::c_float,
lastComputedWidth: ::std::os::raw::c_float,
lastComputedHeight: ::std::os::raw::c_float,
marginRow: ::std::os::raw::c_float,
marginColumn: ::std::os::raw::c_float,
config: root::YGConfigRef,
) -> bool;
}
extern "C" {
pub fn YGNodeCopyStyle(dstNode: root::YGNodeRef, srcNode: root::YGNodeRef);
}
extern "C" {
pub fn YGNodeGetContext(node: root::YGNodeRef) -> *mut ::std::os::raw::c_void;
}
extern "C" {
pub fn YGNodeSetContext(node: root::YGNodeRef, context: *mut ::std::os::raw::c_void);
}
extern "C" {
pub fn YGConfigSetPrintTreeFlag(config: root::YGConfigRef, enabled: bool);
}
extern "C" {
pub fn YGNodeHasMeasureFunc(node: root::YGNodeRef) -> bool;
}
extern "C" {
pub fn YGNodeSetMeasureFunc(node: root::YGNodeRef, measureFunc: root::YGMeasureFunc);
}
extern "C" {
pub fn YGNodeHasBaselineFunc(node: root::YGNodeRef) -> bool;
}
extern "C" {
pub fn YGNodeSetBaselineFunc(node: root::YGNodeRef, baselineFunc: root::YGBaselineFunc);
}
extern "C" {
pub fn YGNodeGetDirtiedFunc(node: root::YGNodeRef) -> root::YGDirtiedFunc;
}
extern "C" {
pub fn YGNodeSetDirtiedFunc(node: root::YGNodeRef, dirtiedFunc: root::YGDirtiedFunc);
}
extern "C" {
pub fn YGNodeSetPrintFunc(node: root::YGNodeRef, printFunc: root::YGPrintFunc);
}
extern "C" {
pub fn YGNodeGetHasNewLayout(node: root::YGNodeRef) -> bool;
}
extern "C" {
pub fn YGNodeSetHasNewLayout(node: root::YGNodeRef, hasNewLayout: bool);
}
extern "C" {
pub fn YGNodeGetNodeType(node: root::YGNodeRef) -> root::YGNodeType;
}
extern "C" {
pub fn YGNodeSetNodeType(node: root::YGNodeRef, nodeType: root::YGNodeType);
}
extern "C" {
pub fn YGNodeIsDirty(node: root::YGNodeRef) -> bool;
}
extern "C" {
pub fn YGNodeLayoutGetDidUseLegacyFlag(node: root::YGNodeRef) -> bool;
}
extern "C" {
pub fn YGNodeStyleSetDirection(node: root::YGNodeRef, direction: root::YGDirection);
}
extern "C" {
pub fn YGNodeStyleGetDirection(node: root::YGNodeConstRef) -> root::YGDirection;
}
extern "C" {
pub fn YGNodeStyleSetFlexDirection(
node: root::YGNodeRef,
flexDirection: root::YGFlexDirection,
);
}
extern "C" {
pub fn YGNodeStyleGetFlexDirection(node: root::YGNodeConstRef) -> root::YGFlexDirection;
}
extern "C" {
pub fn YGNodeStyleSetJustifyContent(node: root::YGNodeRef, justifyContent: root::YGJustify);
}
extern "C" {
pub fn YGNodeStyleGetJustifyContent(node: root::YGNodeConstRef) -> root::YGJustify;
}
extern "C" {
pub fn YGNodeStyleSetAlignContent(node: root::YGNodeRef, alignContent: root::YGAlign);
}
extern "C" {
pub fn YGNodeStyleGetAlignContent(node: root::YGNodeConstRef) -> root::YGAlign;
}
extern "C" {
pub fn YGNodeStyleSetAlignItems(node: root::YGNodeRef, alignItems: root::YGAlign);
}
extern "C" {
pub fn YGNodeStyleGetAlignItems(node: root::YGNodeConstRef) -> root::YGAlign;
}
extern "C" {
pub fn YGNodeStyleSetAlignSelf(node: root::YGNodeRef, alignSelf: root::YGAlign);
}
extern "C" {
pub fn YGNodeStyleGetAlignSelf(node: root::YGNodeConstRef) -> root::YGAlign;
}
extern "C" {
pub fn YGNodeStyleSetPositionType(
node: root::YGNodeRef,
positionType: root::YGPositionType,
);
}
extern "C" {
pub fn YGNodeStyleGetPositionType(node: root::YGNodeConstRef) -> root::YGPositionType;
}
extern "C" {
pub fn YGNodeStyleSetFlexWrap(node: root::YGNodeRef, flexWrap: root::YGWrap);
}
extern "C" {
pub fn YGNodeStyleGetFlexWrap(node: root::YGNodeConstRef) -> root::YGWrap;
}
extern "C" {
pub fn YGNodeStyleSetOverflow(node: root::YGNodeRef, overflow: root::YGOverflow);
}
extern "C" {
pub fn YGNodeStyleGetOverflow(node: root::YGNodeConstRef) -> root::YGOverflow;
}
extern "C" {
pub fn YGNodeStyleSetDisplay(node: root::YGNodeRef, display: root::YGDisplay);
}
extern "C" {
pub fn YGNodeStyleGetDisplay(node: root::YGNodeConstRef) -> root::YGDisplay;
}
extern "C" {
pub fn YGNodeStyleSetFlex(node: root::YGNodeRef, flex: ::std::os::raw::c_float);
}
extern "C" {
pub fn YGNodeStyleGetFlex(node: root::YGNodeConstRef) -> ::std::os::raw::c_float;
}
extern "C" {
pub fn YGNodeStyleSetFlexGrow(node: root::YGNodeRef, flexGrow: ::std::os::raw::c_float);
}
extern "C" {
pub fn YGNodeStyleGetFlexGrow(node: root::YGNodeConstRef) -> ::std::os::raw::c_float;
}
extern "C" {
pub fn YGNodeStyleSetFlexShrink(node: root::YGNodeRef, flexShrink: ::std::os::raw::c_float);
}
extern "C" {
pub fn YGNodeStyleGetFlexShrink(node: root::YGNodeConstRef) -> ::std::os::raw::c_float;
}
extern "C" {
pub fn YGNodeStyleSetFlexBasis(node: root::YGNodeRef, flexBasis: ::std::os::raw::c_float);
}
extern "C" {
pub fn YGNodeStyleSetFlexBasisPercent(
node: root::YGNodeRef,
flexBasis: ::std::os::raw::c_float,
);
}
extern "C" {
pub fn YGNodeStyleSetFlexBasisAuto(node: root::YGNodeRef);
}
extern "C" {
pub fn YGNodeStyleGetFlexBasis(node: root::YGNodeConstRef) -> root::YGValue;
}
extern "C" {
pub fn YGNodeStyleSetPosition(
node: root::YGNodeRef,
edge: root::YGEdge,
position: ::std::os::raw::c_float,
);
}
extern "C" {
pub fn YGNodeStyleSetPositionPercent(
node: root::YGNodeRef,
edge: root::YGEdge,
position: ::std::os::raw::c_float,
);
}
extern "C" {
pub fn YGNodeStyleGetPosition(
node: root::YGNodeConstRef,
edge: root::YGEdge,
) -> root::YGValue;
}
extern "C" {
pub fn YGNodeStyleSetMargin(
node: root::YGNodeRef,
edge: root::YGEdge,
margin: ::std::os::raw::c_float,
);
}
extern "C" {
pub fn YGNodeStyleSetMarginPercent(
node: root::YGNodeRef,
edge: root::YGEdge,
margin: ::std::os::raw::c_float,
);
}
extern "C" {
pub fn YGNodeStyleSetMarginAuto(node: root::YGNodeRef, edge: root::YGEdge);
}
extern "C" {
pub fn YGNodeStyleGetMargin(
node: root::YGNodeConstRef,
edge: root::YGEdge,
) -> root::YGValue;
}
extern "C" {
pub fn YGNodeStyleSetPadding(
node: root::YGNodeRef,
edge: root::YGEdge,
padding: ::std::os::raw::c_float,
);
}
extern "C" {
pub fn YGNodeStyleSetPaddingPercent(
node: root::YGNodeRef,
edge: root::YGEdge,
padding: ::std::os::raw::c_float,
);
}
extern "C" {
pub fn YGNodeStyleGetPadding(
node: root::YGNodeConstRef,
edge: root::YGEdge,
) -> root::YGValue;
}
extern "C" {
pub fn YGNodeStyleSetBorder(
node: root::YGNodeRef,
edge: root::YGEdge,
border: ::std::os::raw::c_float,
);
}
extern "C" {
pub fn YGNodeStyleGetBorder(
node: root::YGNodeConstRef,
edge: root::YGEdge,
) -> ::std::os::raw::c_float;
}
extern "C" {
pub fn YGNodeStyleSetGap(
node: root::YGNodeRef,
gutter: root::YGGutter,
gapLength: ::std::os::raw::c_float,
);
}
extern "C" {
pub fn YGNodeStyleGetGap(
node: root::YGNodeConstRef,
gutter: root::YGGutter,
) -> ::std::os::raw::c_float;
}
extern "C" {
pub fn YGNodeStyleSetWidth(node: root::YGNodeRef, width: ::std::os::raw::c_float);
}
extern "C" {
pub fn YGNodeStyleSetWidthPercent(node: root::YGNodeRef, width: ::std::os::raw::c_float);
}
extern "C" {
pub fn YGNodeStyleSetWidthAuto(node: root::YGNodeRef);
}
extern "C" {
pub fn YGNodeStyleGetWidth(node: root::YGNodeConstRef) -> root::YGValue;
}
extern "C" {
pub fn YGNodeStyleSetHeight(node: root::YGNodeRef, height: ::std::os::raw::c_float);
}
extern "C" {
pub fn YGNodeStyleSetHeightPercent(node: root::YGNodeRef, height: ::std::os::raw::c_float);
}
extern "C" {
pub fn YGNodeStyleSetHeightAuto(node: root::YGNodeRef);
}
extern "C" {
pub fn YGNodeStyleGetHeight(node: root::YGNodeConstRef) -> root::YGValue;
}
extern "C" {
pub fn YGNodeStyleSetMinWidth(node: root::YGNodeRef, minWidth: ::std::os::raw::c_float);
}
extern "C" {
pub fn YGNodeStyleSetMinWidthPercent(
node: root::YGNodeRef,
minWidth: ::std::os::raw::c_float,
);
}
extern "C" {
pub fn YGNodeStyleGetMinWidth(node: root::YGNodeConstRef) -> root::YGValue;
}
extern "C" {
pub fn YGNodeStyleSetMinHeight(node: root::YGNodeRef, minHeight: ::std::os::raw::c_float);
}
extern "C" {
pub fn YGNodeStyleSetMinHeightPercent(
node: root::YGNodeRef,
minHeight: ::std::os::raw::c_float,
);
}
extern "C" {
pub fn YGNodeStyleGetMinHeight(node: root::YGNodeConstRef) -> root::YGValue;
}
extern "C" {
pub fn YGNodeStyleSetMaxWidth(node: root::YGNodeRef, maxWidth: ::std::os::raw::c_float);
}
extern "C" {
pub fn YGNodeStyleSetMaxWidthPercent(
node: root::YGNodeRef,
maxWidth: ::std::os::raw::c_float,
);
}
extern "C" {
pub fn YGNodeStyleGetMaxWidth(node: root::YGNodeConstRef) -> root::YGValue;
}
extern "C" {
pub fn YGNodeStyleSetMaxHeight(node: root::YGNodeRef, maxHeight: ::std::os::raw::c_float);
}
extern "C" {
pub fn YGNodeStyleSetMaxHeightPercent(
node: root::YGNodeRef,
maxHeight: ::std::os::raw::c_float,
);
}
extern "C" {
pub fn YGNodeStyleGetMaxHeight(node: root::YGNodeConstRef) -> root::YGValue;
}
extern "C" {
pub fn YGNodeStyleSetAspectRatio(
node: root::YGNodeRef,
aspectRatio: ::std::os::raw::c_float,
);
}
extern "C" {
pub fn YGNodeStyleGetAspectRatio(node: root::YGNodeConstRef) -> ::std::os::raw::c_float;
}
extern "C" {
pub fn YGNodeLayoutGetLeft(node: root::YGNodeRef) -> ::std::os::raw::c_float;
}
extern "C" {
pub fn YGNodeLayoutGetTop(node: root::YGNodeRef) -> ::std::os::raw::c_float;
}
extern "C" {
pub fn YGNodeLayoutGetRight(node: root::YGNodeRef) -> ::std::os::raw::c_float;
}
extern "C" {
pub fn YGNodeLayoutGetBottom(node: root::YGNodeRef) -> ::std::os::raw::c_float;
}
extern "C" {
pub fn YGNodeLayoutGetWidth(node: root::YGNodeRef) -> ::std::os::raw::c_float;
}
extern "C" {
pub fn YGNodeLayoutGetHeight(node: root::YGNodeRef) -> ::std::os::raw::c_float;
}
extern "C" {
pub fn YGNodeLayoutGetDirection(node: root::YGNodeRef) -> root::YGDirection;
}
extern "C" {
pub fn YGNodeLayoutGetHadOverflow(node: root::YGNodeRef) -> bool;
}
extern "C" {
pub fn YGNodeLayoutGetDidLegacyStretchFlagAffectLayout(node: root::YGNodeRef) -> bool;
}
extern "C" {
pub fn YGNodeLayoutGetMargin(
node: root::YGNodeRef,
edge: root::YGEdge,
) -> ::std::os::raw::c_float;
}
extern "C" {
pub fn YGNodeLayoutGetBorder(
node: root::YGNodeRef,
edge: root::YGEdge,
) -> ::std::os::raw::c_float;
}
extern "C" {
pub fn YGNodeLayoutGetPadding(
node: root::YGNodeRef,
edge: root::YGEdge,
) -> ::std::os::raw::c_float;
}
extern "C" {
pub fn YGConfigSetLogger(config: root::YGConfigRef, logger: root::YGLogger);
}
extern "C" {
pub fn YGAssert(condition: bool, message: *const ::std::os::raw::c_char);
}
extern "C" {
pub fn YGAssertWithNode(
node: root::YGNodeRef,
condition: bool,
message: *const ::std::os::raw::c_char,
);
}
extern "C" {
pub fn YGAssertWithConfig(
config: root::YGConfigRef,
condition: bool,
message: *const ::std::os::raw::c_char,
);
}
extern "C" {
pub fn YGConfigSetPointScaleFactor(
config: root::YGConfigRef,
pixelsInPoint: ::std::os::raw::c_float,
);
}
extern "C" {
pub fn YGConfigSetShouldDiffLayoutWithoutLegacyStretchBehaviour(
config: root::YGConfigRef,
shouldDiffLayout: bool,
);
}
extern "C" {
pub fn YGConfigGetUseLegacyStretchBehaviour(config: root::YGConfigRef) -> bool;
}
extern "C" {
pub fn YGConfigSetUseLegacyStretchBehaviour(
config: root::YGConfigRef,
useLegacyStretchBehaviour: bool,
);
}
extern "C" {
pub fn YGConfigNew() -> root::YGConfigRef;
}
extern "C" {
pub fn YGConfigFree(config: root::YGConfigRef);
}
extern "C" {
pub fn YGConfigCopy(dest: root::YGConfigRef, src: root::YGConfigRef);
}
extern "C" {
pub fn YGConfigGetInstanceCount() -> i32;
}
extern "C" {
pub fn YGConfigSetExperimentalFeatureEnabled(
config: root::YGConfigRef,
feature: root::YGExperimentalFeature,
enabled: bool,
);
}
extern "C" {
pub fn YGConfigIsExperimentalFeatureEnabled(
config: root::YGConfigRef,
feature: root::YGExperimentalFeature,
) -> bool;
}
extern "C" {
pub fn YGConfigSetUseWebDefaults(config: root::YGConfigRef, enabled: bool);
}
extern "C" {
pub fn YGConfigGetUseWebDefaults(config: root::YGConfigRef) -> bool;
}
extern "C" {
pub fn YGConfigSetCloneNodeFunc(config: root::YGConfigRef, callback: root::YGCloneNodeFunc);
}
extern "C" {
pub fn YGConfigGetDefault() -> root::YGConfigRef;
}
extern "C" {
pub fn YGConfigSetContext(config: root::YGConfigRef, context: *mut ::std::os::raw::c_void);
}
extern "C" {
pub fn YGConfigGetContext(config: root::YGConfigRef) -> *mut ::std::os::raw::c_void;
}
extern "C" {
pub fn YGRoundValueToPixelGrid(
value: ::std::os::raw::c_double,
pointScaleFactor: ::std::os::raw::c_double,
forceCeil: bool,
forceFloor: bool,
) -> ::std::os::raw::c_float;
}
extern "C" {
#[link_name = "\u{1}_Z18YGTraversePreOrderP6YGNodeOSt8functionIFvS0_EE"]
pub fn YGTraversePreOrder(node: root::YGNodeRef, f: *mut root::std::function);
}
extern "C" {
#[link_name = "\u{1}_Z17YGNodeSetChildrenP6YGNodeRKSt6vectorIS0_SaIS0_EE"]
pub fn YGNodeSetChildren1(owner: root::YGNodeRef, children: *const root::std::vector);
}
pub type __builtin_va_list = [root::__va_list_tag; 1usize];
#[repr(C)]
#[derive(Debug, Copy, Clone)]
pub struct __va_list_tag {
pub gp_offset: ::std::os::raw::c_uint,
pub fp_offset: ::std::os::raw::c_uint,
pub overflow_arg_area: *mut ::std::os::raw::c_void,
pub reg_save_area: *mut ::std::os::raw::c_void,
}
}

@virtualritz
Copy link

virtualritz commented Feb 21, 2023

I have the same issue on my opensubdiv-petite-sys wrapper when building on Linux (Ubuntu 22.04).

It does indeed go away if I link against libc++ but I would very much like to avoid that on that platform and use the default, libstd++.

@nicoburns
Copy link

It does indeed go away if I link against libc++ but I would very much like to avoid that on that platform and use the feault, libstd++.

Yes, and I would add that there is an objective reason to want to do this, which is that the docs.rs build image doesn't include the libc++ headers (and is blocked from doing so by an ubuntu bug). So linking against libc++ to work around this bug means no docs.rs documentation.

See: rust-lang/crates-build-env#125

@virtualritz
Copy link

[...] So linking against libc++ to work around this bug means no docs.rs documentation.

Bummer, it does indeed. I just published an update to my crate and the docs are missing. Doh!

@bobbbay
Copy link

bobbbay commented Sep 3, 2023

Any update on this? On 0.66.1 and still having this issue.

@ileixe ileixe linked a pull request Feb 20, 2024 that will close this issue
@ileixe
Copy link

ileixe commented Feb 20, 2024

Hi. I made up small PR to avoid this issue, as we've been in trouble for boncheolgu/tflite-rs#58

I have no background regarding bindgen codebase at all, so the fix is very likely to go wrong way (any other side effect) as I just tracked problematic stacktrace and pinpointed this very specific problem. My purpose is to attract attention to fix this old irritating issue and create an entry point PR to fix ultimately, so any guidance would be appreciated, I'm happily following it.

@fantajeon
Copy link

It's not an exact solution, but after trying several approaches, I added ManuallyDrop. However, I haven't been able to add <_Tp, _Alloc> yet.

./target/debug/bindgen \
input.hpp \
--manually-drop-union ".*" \
--no-derive-copy \
/* automatically generated by rust-bindgen 0.69.4 */

#[repr(C)]
#[derive(Debug)]
pub struct _Vector_base {
pub _address: u8,
}

#[repr(C)]
pub union _Vector_base__Storage<_Tp> {
pub _M_byte: ::std::mem::ManuallyDrop<::std::os::raw::c_uchar>,
pub _M_val: ::std::mem::ManuallyDrop<_Tp>,
pub _phantom_0: ::std::marker::PhantomData<::std::cell::UnsafeCell<_Tp>>,
}

The first block of code is a shell command that runs the bindgen tool with specific options and an input file named input.hpp.

The second block of code is Rust code that defines two data structures:

  1. _Vector_base: A struct with a single field _address of type u8.

  2. _Vector_base__Storage<_Tp>: A union with three fields:

    • _M_byte: A field of type ManuallyDrop<c_uchar>.
    • _M_val: A field of type ManuallyDrop<_Tp>.
    • _phantom_0: A field of type PhantomData<UnsafeCell<_Tp>>.

The code is automatically generated by the rust-bindgen tool version 0.69.4.

efenniht-furiosa pushed a commit to efenniht-furiosa/tflite-rs that referenced this issue Jun 22, 2024
efenniht-furiosa pushed a commit to efenniht-furiosa/tflite-rs that referenced this issue Jun 22, 2024
boncheolgu pushed a commit to boncheolgu/tflite-rs that referenced this issue Jun 24, 2024
* fix: workaround bindgen bug (rust-lang/rust-bindgen#2157)

* lint.

* fix: `slice::from_raw_parts(null(), 0)` is UB.

---------

Co-authored-by: Sanguk Park <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

6 participants