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

Fatal error: 'stddef.h' file not found #1078

Open
djc opened this issue Apr 10, 2024 · 4 comments
Open

Fatal error: 'stddef.h' file not found #1078

djc opened this issue Apr 10, 2024 · 4 comments

Comments

@djc
Copy link

djc commented Apr 10, 2024

I tried to transpile cronie. After finally getting c2rust to compile on my Gentoo box (with llvm-17.0.6 installed) and generating compile_commands.json via intercept-build, this is the output I got:

enrai cronie $ ../c2rust/target/release/c2rust transpile compile_commands.json
In file included from anacron/lock.c:29:
/usr/include/stdio.h:33:10: fatal error: 'stddef.h' file not found
   33 | #include <stddef.h>
      |          ^~~~~~~~~~
1 error generated.
Error while processing /home/djc/src/cronie/anacron/lock.c.
Transpiling lock.c
warning: Missing child 93960771518624 of node AstNode { tag: TagCallExpr, children: [Some(93960771518528), Some(93960771518560), Some(93960771518592), Some(93960771518624)], loc: SrcSpan { fileid: 11, begin_line: 41, begin_column: 10, end_line: 41, end_column: 40 }, type_id: Some(93960770786800), rvalue: RValue, macro_expansions: [], macro_expansion_text: None, extras: [] }
Exported Clang AST was invalid. Check warnings above for unimplemented features.
--> /usr/include/bits/stdio.h:41:10
 [-Wclang-ast]
warning: Missing child 93960772464328 of node AstNode { tag: TagCallExpr, children: [Some(93960772464328), Some(93960772464416), Some(93960772464464), Some(93960772464496)], loc: SrcSpan { fileid: 60, begin_line: 89, begin_column: 9, end_line: 89, end_column: 44 }, type_id: Some(93960770786800), rvalue: RValue, macro_expansions: [], macro_expansion_text: None, extras: [] }
Exported Clang AST was invalid. Check warnings above for unimplemented features.
--> /home/djc/src/cronie/anacron/lock.c:89:9
 [-Wclang-ast]
warning: Missing child 93960772486248 of node AstNode { tag: TagCallExpr, children: [Some(93960772486248), Some(93960772486336), Some(93960772486384), Some(93960772486416)], loc: SrcSpan { fileid: 6
0, begin_line: 204, begin_column: 9, end_line: 204, end_column: 41 }, type_id: Some(93960770786800), rvalue: RValue, macro_expansions: [], macro_expansion_text: None, extras: [] }
Exported Clang AST was invalid. Check warnings above for unimplemented features.
--> /home/djc/src/cronie/anacron/lock.c:204:9
 [-Wclang-ast]
thread 'main' panicked at 'Type conversion not implemented for TagTypeUnknown expecting 3', c2rust-transpile/src/c_ast/conversion.rs:827:22
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace

I'm a little confused that the process continues after the fatal error concerning stddef.h (and, indeed, why clang can't find that file at this point -- I have one in /usr/lib/clang/17/include/stddef.h). Is there something I could do for TagTypeUnknown expecting 3?

@fw-immunant
Copy link
Contributor

As far as I can tell, this is the problem fixed by commit f3b5623. Make sure your version of c2rust includes that commit (which is newer than the latest release, so you'll have to build from git).

@djc
Copy link
Author

djc commented Apr 10, 2024

I built from 0e732f6, which should include that change, right?

@fw-immunant
Copy link
Contributor

0e732f6 does include that change. You can double-check the version you have built with c2rust --version and you can see where the transpiler is looking for stddef.h with strace (you'll have to remove the generated .rs files and run the transpiler afresh):

strace -f -e open,openat,openat2 $CARGO_TARGET_DIR/release/c2rust transpile compile_commands.json

@djc
Copy link
Author

djc commented Apr 10, 2024

The version is as expected. strace output:

[pid 13068] openat(AT_FDCWD, "./stddef.h", O_RDONLY|O_CLOEXEC) = -1 ENOENT (No such file or directory)
[pid 13068] openat(AT_FDCWD, "/usr/local/include/stddef.h", O_RDONLY|O_CLOEXEC) = -1 ENOENT (No such file or directory)
[pid 13068] openat(AT_FDCWD, "/usr/include/stddef.h", O_RDONLY|O_CLOEXEC) = -1 ENOENT (No such file or directory)
In file included from anacron/lock.c:29:
/usr/include/stdio.h:33:10: fatal error: 'stddef.h' file not found
   33 | #include <stddef.h>
      |          ^~~~~~~~~~

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

2 participants