google / autocxx

Tool for safe ergonomic Rust/C++ interop driven from existing C++ headers
https://docs.rs/autocxx
Apache License 2.0
2.24k stars 144 forks source link

Github CI fails because of panic in autocxx-bindgen #1327

Open xxshady opened 1 year ago

xxshady commented 1 year ago

Describe the bug

autocxx-bindgen panics while bulding c++ code in github action, it's not related to incompatible Clang/LLVM version since it gets updated to 16.0.6 manually

Panicked github action: https://github.com/xxshady/autocxx-repro/actions/runs/6064661756/job/16453314009

Full panic:

  thread 'main' panicked at 'Non floating-type complex? Type(_Complex _Float16, kind: Complex, cconv: 100, decl: Cursor( kind: NoDeclFound, loc: builtin definitions, usr: None), canon: Cursor( kind: NoDeclFound, loc: builtin definitions, usr: None)), Type(_Float16, kind: Float16, cconv: 100, decl: Cursor( kind: NoDeclFound, loc: builtin definitions, usr: None), canon: Cursor( kind: NoDeclFound, loc: builtin definitions, usr: None))', C:\Users\runneradmin\.cargo\registry\src\index.crates.io-6f17d22bba15001f\autocxx-bindgen-0.65.1\ir\context.rs:1997:26
  stack backtrace:
     0:     0x7ff681295e0c - std::sys_common::backtrace::_print::impl$0::fmt
                                 at /rustc/eb26296b556cef10fb713a38f3d16b9886080f26/library\std\src\sys_common\backtrace.rs:44
     1:     0x7ff6812b8e6b - core::fmt::rt::Argument::fmt
                                 at /rustc/eb26296b556cef10fb713a38f3d16b9886080f26/library\core\src\fmt\rt.rs:138
     2:     0x7ff6812b8e6b - core::fmt::write
                                 at /rustc/eb26296b556cef10fb713a38f3d16b9886080f26/library\core\src\fmt\mod.rs:1094
     3:     0x7ff681290769 - std::io::Write::write_fmt<std::sys::windows::stdio::Stderr>
                                 at /rustc/eb26296b556cef10fb713a38f3d16b9886080f26/library\std\src\io\mod.rs:1713
     4:     0x7ff681295bbb - std::sys_common::backtrace::_print
                                 at /rustc/eb26296b556cef10fb713a38f3d16b9886080f26/library\std\src\sys_common\backtrace.rs:47
     5:     0x7ff681295bbb - std::sys_common::backtrace::print
                                 at /rustc/eb26296b556cef10fb713a38f3d16b9886080f26/library\std\src\sys_common\backtrace.rs:34
     6:     0x7ff681298859 - std::panicking::default_hook::closure$1
                                 at /rustc/eb26296b556cef10fb713a38f3d16b9886080f26/library\std\src\panicking.rs:269
     7:     0x7ff68129850f - std::panicking::default_hook
                                 at /rustc/eb26296b556cef10fb713a38f3d16b9886080f26/library\std\src\panicking.rs:288
     8:     0x7ff681298d5e - std::panicking::rust_panic_with_hook
                                 at /rustc/eb26296b556cef10fb713a38f3d16b9886080f26/library\std\src\panicking.rs:705
     9:     0x7ff681298c4d - std::panicking::begin_panic_handler::closure$0
                                 at /rustc/eb26296b556cef10fb713a38f3d16b9886080f26/library\std\src\panicking.rs:597
    10:     0x7ff681296a39 - std::sys_common::backtrace::__rust_end_short_backtrace<std::panicking::begin_panic_handler::closure_env$0,never$>
                                 at /rustc/eb26296b556cef10fb713a38f3d16b9886080f26/library\std\src\sys_common\backtrace.rs:151
    11:     0x7ff681298950 - std::panicking::begin_panic_handler
                                 at /rustc/eb26296b556cef10fb713a38f3d16b9886080f26/library\std\src\panicking.rs:593
    12:     0x7ff6812c3965 - core::panicking::panic_fmt
                                 at /rustc/eb26296b556cef10fb713a38f3d16b9886080f26/library\core\src\panicking.rs:67
    13:     0x7ff680dec336 - autocxx_bindgen::ir::context::BindgenContext::next_item_id::hb81caf72bb5a9c47
    14:     0x7ff680deb375 - autocxx_bindgen::ir::context::BindgenContext::builtin_or_resolved_ty::h2e32a487dcb06b1c
    15:     0x7ff680d65cfc - autocxx_bindgen::ir::item::Item::from_ty_or_ref_with_id::hc986eae69e2be39d
    16:     0x7ff680d65a88 - autocxx_bindgen::ir::item::Item::from_ty_or_ref::hd99cb19fe3e96cc4
    17:     0x7ff680cba01f - autocxx_bindgen::ir::function::args_from_ty_and_cursor::{{closure}}::h4e00369aa09a0a6d
    18:     0x7ff680ca0b17 - core::ops::function::impls::<impl core::ops::function::FnOnce<A> for &mut F>::call_once::h7ff40aa463aaa385
    19:     0x7ff680d22bf6 - <core::iter::adapters::map::Map<I,F> as core::iter::traits::iterator::Iterator>::next::hd571c9545b9028e7
    20:     0x7ff680cc0f07 - <alloc::vec::Vec<T> as alloc::vec::spec_from_iter_nested::SpecFromIterNested<T,I>>::from_iter::h7968be7e2f4b0d73
    21:     0x7ff680cd3381 - <alloc::vec::Vec<T> as alloc::vec::spec_from_iter::SpecFromIter<T,I>>::from_iter::h931445658a3e5ddb
    22:     0x7ff680cd240a - <alloc::vec::Vec<T> as core::iter::traits::collect::FromIterator<T>>::from_iter::h851cad023ef7a4e6
    23:     0x7ff680d27ef1 - core::iter::traits::iterator::Iterator::collect::hee27103ab8b1e29b
    24:     0x7ff680cb9cbb - autocxx_bindgen::ir::function::cursor_mangling::h73f6f33772e6f60f
    25:     0x7ff680cba583 - autocxx_bindgen::ir::function::FunctionSig::from_ty::h5d2a3130505f8407
    26:     0x7ff680da03cd - autocxx_bindgen::ir::ty::Type::from_clang_ty::h2ab98afb4e4f7650
    27:     0x7ff680d6720e - autocxx_bindgen::ir::item::Item::from_ty::h0c4b89d47f6496ba
    28:     0x7ff680d665b3 - autocxx_bindgen::ir::item::Item::from_ty::h0c4b89d47f6496ba
    29:     0x7ff680cbbcd2 - <autocxx_bindgen::ir::function::Function as autocxx_bindgen::parse::ClangSubItemParser>::parse::hf342f03ce147bdb0
    30:     0x7ff680d642a4 - autocxx_bindgen::ir::item::Item::parse::h11fa4dc728f169bf
    31:     0x7ff680d1dda9 - autocxx_bindgen::parse_one::h3a028463fbd6b327
    32:     0x7ff680d1e36a - autocxx_bindgen::parse::{{closure}}::{{closure}}::h96069d1c10691fe8
    33:     0x7ff680d53ea1 - autocxx_bindgen::clang::is_valid_identifier::{{closure}}::h6d2b5a5de24d4c85
    34:     0x7ff80e5f317f - clang_disposeTranslationUnit
    35:     0x7ff80e5f54db - clang_isTranslationUnit
    36:     0x7ff80e5f55cb - clang_isTranslationUnit
    37:     0x7ff80e5f3b79 - clang_isDeclaration
    38:     0x7ff80e604d06 - clang_visitChildren
    39:     0x7ff68106993d - clang_sys::clang_visitChildren::h5b86a00a805d10d1
    40:     0x7ff680d51749 - autocxx_bindgen::clang::Cursor::visit::hccb8f708d5251329
    41:     0x7ff680d1e317 - autocxx_bindgen::parse::{{closure}}::hf5d5fe8baaab40ff
    42:     0x7ff680dedf10 - autocxx_bindgen::ir::context::BindgenContext::with_module::h6af6724ee046ec7a
    43:     0x7ff680d1e15d - autocxx_bindgen::parse_one::{{closure}}::h7eeb887e017bfdc6
    44:     0x7ff680d1b1cf - autocxx_bindgen::deprecated_target_diagnostic::h9e93939014f5f604
    45:     0x7ff680d1958f - autocxx_bindgen::Builder::generate::h12c5cd58231f4354
    46:     0x7ff6809405e7 - autocxx_engine::IncludeCppEngine::generate::h5bb32af8e4f38a5e
    47:     0x7ff6809894fc - autocxx_engine::parse_file::ParsedFile::resolve_all::h72fe5da4bcac2110
    48:     0x7ff6808e913c - autocxx_engine::builder::Builder<CTX>::extra_clang_args::{{closure}}::hea4e6b25914c9786
    49:     0x7ff6808eaa9b - autocxx_engine::builder::Builder<CTX>::build::hb647455cf38db563
    50:     0x7ff6808e8552 - <core::result::Result<T,E> as core::ops::try_trait::Try>::branch::hfc2cd030249a6911
    51:     0x7ff6808ee706 - core::ops::function::FnOnce::call_once::h8d1ce75e1da0fd14
    52:     0x7ff6808e3b99 - std::sys_common::backtrace::__rust_begin_short_backtrace::hde17f94e5aa73449
    53:     0x7ff6808e3b7c - std::rt::lang_start::{{closure}}::hdf9d69128f4636c8
    54:     0x7ff68128a448 - std::rt::lang_start_internal::closure$2
                                 at /rustc/eb26296b556cef10fb713a38f3d16b9886080f26/library\std\src\rt.rs:148
    55:     0x7ff68128a448 - std::panicking::try::do_call
                                 at /rustc/eb26296b556cef10fb713a38f3d16b9886080f26/library\std\src\panicking.rs:500
    56:     0x7ff68128a448 - std::panicking::try
                                 at /rustc/eb26296b556cef10fb713a38f3d16b9886080f26/library\std\src\panicking.rs:464
    57:     0x7ff68128a448 - std::panic::catch_unwind
                                 at /rustc/eb26296b556cef10fb713a38f3d16b9886080f26/library\std\src\panic.rs:142
    58:     0x7ff68128a448 - std::rt::lang_start_internal
                                 at /rustc/eb26296b556cef10fb713a38f3d16b9886080f26/library\std\src\rt.rs:148
    59:     0x7ff6808e3b57 - std::rt::lang_start::h0ceb387ac768f166
    60:     0x7ff6808e8609 - main
    61:     0x7ff6812c0f60 - invoke_main
                                 at D:\a\_work\1\s\src\vctools\crt\vcstartup\src\startup\exe_common.inl:78
    62:     0x7ff6812c0f60 - __scrt_common_main_seh
                                 at D:\a\_work\1\s\src\vctools\crt\vcstartup\src\startup\exe_common.inl:288
    63:     0x7ff84dbf4de0 - BaseThreadInitThunk
    64:     0x7ff84e9fec4b - RtlUserThreadStart

To Reproduce

https://github.com/xxshady/autocxx-repro

Expected behavior No panic

xxshady commented 1 year ago

seems like its related to c++20: https://github.com/xxshady/autocxx-repro/actions/runs/6292598553/job/17082160466

however, it was working completely fine with c++20 for some time before visual studio and clang were updated in windows-2022 github image

xxshady commented 1 year ago

Removing LLVM from PATH helps with avoiding this issue: https://github.com/xxshady/autocxx-repro/actions/runs/6380197303/job/17314131098

  set PATH=%PATH:C:\Program Files\LLVM\bin;=%
  echo %PATH%
  cargo build
adetaylor commented 1 year ago

Thanks for looking into this. I'm unable to eke out time to look into it right now, but my guess is that corresponding changes have been made to bindgen and need to be rolled into autocxx_bindgen.

xxshady commented 6 months ago

for some reason now latest version (clang --version showed clang version 18.1.3) LLVM/clang freezes compilation on windows: https://github.com/xxshady/altv-rust/actions/runs/8819720686/job/24211619136#step:9:957

it compiles fine on 16.0.6: https://github.com/xxshady/altv-rust/actions/runs/8818604846/job/24207787321#step:5:5

xxshady commented 6 months ago

freezes somewhere inside the autocxx_build::Builder::build method

xxshady commented 2 months ago

doesn't work with 16.0.6, but works with 17.0.1 https://github.com/xxshady/altv-rust/blob/740c3ca7d2ebb6fe25228d7462092ae2695d2a27/.github/workflows/test.yml#L58-L63