Compiling rust example programs for native - rust2c error

Hello,

I’m working on a project which ports over a rust-based eBPF VM to run on RIOT. So far I’ve been testing it out on the nucleo-f439zi stm32 board and everything was working fine. I have installed c2rust as suggested from the github repo (not directly from cargo).

The problem is that when I try to compile my project for native, c2rust fails with the following error:

Running C2Rust on /home/szymon/Projects/ebpf-on-microcontrollers/mibpf/RIOT/examples/rust-hello-world/bin/native/target/i686-unknown-linux-gnu/release/build/riot-sys-2c2c5674e877dcb9/out/compile_commands.json
  Transpiling riot-c2rust.h
  cargo:warning=C2Rust failed with error code exit status: 101, exiting

  --- stderr
  In file included from riot-c2rust.h:79:
  In file included from /home/szymon/Projects/ebpf-on-microcontrollers/mibpf/RIOT/core/lib/include/rmutex.h:28:
  /home/szymon/Projects/ebpf-on-microcontrollers/mibpf/RIOT/core/include/mutex.h:130:10: fatal error: 'stddef.h' file not found
  #include <stddef.h>
           ^~~~~~~~~~
  1 error generated.
  Error while processing /home/szymon/Projects/ebpf-on-microcontrollers/mibpf/RIOT/examples/rust-hello-world/bin/native/target/i686-unknown-linux-gnu/release/build/riot-sys-2c2c5674e877dcb9/out/riot-c2rust.h.
  warning: Missing child 108724094825960 of node AstNode { tag: TagCallExpr, children: [Some(108724094825960)], loc: SrcSpan { fileid: 110, begin_line: 384, begin_column: 11, end_line: 384, end_column: 33 }, type_id: Some(108724091303168), rvalue: RValue, macro_expansions: [], macro_expansion_text: None, extras: [] }
  Exported Clang AST was invalid. Check warnings above for unimplemented features.
  --> /home/szymon/Projects/ebpf-on-microcontrollers/mibpf/RIOT/sys/include/net/gnrc/netif/internal.h:384:11
   [-Wclang-ast]
  warning: Missing child 108724094826208 of node AstNode { tag: TagCallExpr, children: [Some(108724094826208), Some(108724094826240)], loc: SrcSpan { fileid: 110, begin_line: 387, begin_column: 16, end_line: 387, end_column: 43 }, type_id: Some(108724091303168), rvalue: RValue, macro_expansions: [], macro_expansion_text: None, extras: [] }
  Exported Clang AST was invalid. Check warnings above for unimplemented features.

The same issue is present when I try to compile any of the rust example programs. I suspect it has something to do with my OS as I’m using arch linux and when installing c2rust I needed to explicitly specify the llvm installation dir.

Has anyone seen a similar issue before? Thank you

I’ve moved this to the issue tracker at https://github.com/RIOT-OS/RIOT/issues/20451; CC’d you, so you should get responses from there.

Hello chrysn,

Thank you for your response and opening the new issue for me. I will move over to the issue tracker.

Thank you for all of your contributions to RIOT. So far I’ve been using a lot of your examples for rust programs and they proved to be an invaluable resource. Thanks!