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

Skip or Add NonAtomicToAtomic Support Within C99 #761

Open
plutoup opened this issue Dec 20, 2022 · 6 comments
Open

Skip or Add NonAtomicToAtomic Support Within C99 #761

plutoup opened this issue Dec 20, 2022 · 6 comments

Comments

@plutoup
Copy link

plutoup commented Dec 20, 2022

A request to add support or skip support for the functionality of casting regular types to a atomic type feature.

Error:

thread 'main' panicked at 'Unsupported implicit cast: NonAtomicToAtomic', /.../c2rust-transpile-0.16.0/src/c_ast/conversion.rs:167:14

Clang Version:
Ubuntu clang version 14.0.0-1ubuntu1
Target: x86_64-pc-linux-gnu
Thread model: posix

File Link:
https://github.com/immunant/c2rust/blob/master/c2rust-transpile/src/c_ast/conversion.rs

@rinon
Copy link
Contributor

rinon commented Dec 20, 2022

What file in raylib cause this issue? Would like to narrow down the cause of this cast on the C side.

@plutoup
Copy link
Author

plutoup commented Dec 20, 2022

The file is actual not in raylib but in libclang after looking more closely at output. c2rust then stops converting after trying to convert the atomic types in stdatomic.h of libclang 14.0:
https://clang.llvm.org/doxygen/stdatomic_8h_source.html:91:126
The file that is being converted is this one:
https://github.com/raysan5/raylib/blob/master/examples/core/core_loading_thread.c
I don't know where the file begins and ends but this was the last warning:

warning: Missing type 94425815108752 for node: AstNode { tag: TagTypedefDecl, children: [], loc: SrcSpan { fileid: 31, begin_line: 109, begin_column: 1, end_line: 109, end_column: 37 }, type_id: Some(94425815108752), rvalue: LValue, macro_expansions: [], macro_expansion_text: Some("__ATOMIC_SEQ_CST"), extras: [Text("atomic_int_fast8_t"), Bool(false)] }
Exported Clang AST was invalid. Check warnings above for unimplemented features.
--> /usr/lib/llvm-14/lib/clang/14.0.0/include/stdatomic.h:109:1

@plutoup
Copy link
Author

plutoup commented Dec 20, 2022

Apologies for the long wait.

@rinon
Copy link
Contributor

rinon commented Dec 20, 2022

ahhhh, that is C11 atomics.

#include <stdatomic.h> // C11 atomic data types

Both functions in that file use C11 atomics, and so wouldn't get transpiled even if we get past parsing until we support these atomics properly. We don't have a singular issue for C11 atomics, so I'll keep this open until we either do or we implement some sort of support for them.

@plutoup
Copy link
Author

plutoup commented Dec 20, 2022

Yeah still I would like the program not to panic but give a error and keep going. So if some else is willing to add Result support for the CastKind match function would be great. I am also willing to do it as well so that I can at least get the file conversions of the files can be converted (skip support). I think it would also be useful to record all the functions that show a warning and error to a function so that they can be re-implemented.

@kkysen kkysen changed the title Skip or Add NonAtomicToAtomic Support Within C99 Skip or Add NonAtomicToAtomic Support Within C99 Jan 4, 2023
@Pesky01
Copy link

Pesky01 commented Apr 12, 2023

Is there a way to just ignore it and transpile the rest so I can manually fix it instead?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants