Conversation
|
Any chance for a review on this? The CI appears to be failing for unrelated reasons... |
|
@mrexodia thank you for your contribution. We are currently short on reviewing time, sorry for the delay. On what platform have you seen the need for these changes? This being said, the PR looks useful and fine overall. However, to simplify reviewing, it would be useful to split the single commit into multiple ones with a short explanation of what each set of changes does. I would also split this into 3 PRs: one for the small LLVM 17 change (for which we also need to add a CI target), one for the smaller changes involving headers and definitions, and one for the errno changes, which might require some more discussion. Thanks again. |
|
These changes were necessary on macos (M1) and they would also be necessary for Windows (would have to try). Generally LLVM in freestanding mode does not have access to any system headers (even |
739b6b5 to
e7c636b
Compare
|
Why introduce errno.h in freestanding? Aren't error codes platform-dependent? |
|
Yes, errno is platform-dependent but the functions assign to it so I had to do something 🤷♂️ The specific values don’t matter in this context either, it’s just to make things compile without |
|
I don't see any functions touching errno in |
4905b5d to
d5babc6
Compare
|
Yeah the references are in |
|
Yes, putting that into klee-libc now makes more sense, thank you. On other hand, this might pose a problem with FreeBSD - the error codes we have might not match ones used by klee-libc and we also don't have uclibc. Maybe klee-libc should still take errno.h from the host system? |
|
I don’t think we should take anything from the host system. For example on Windows I do not have errno.h at all, which is the whole point of this PR. I checked and there are only two occurrences of errno in the klee-libc runtime, perhaps we could pass the defines manually or something? |
|
Also the CI failure related to rlimit64 happens because the host does not have |
errno.h on Windows is shipped with ucrt.
Well, the user will define them to host values in 99% of cases, I believe, |
|
Alright, I will try to extract the 2 error codes used from the host at configure-time and put them in a generated errno.h. The issue I ran into is that the host headers are not available at all, because clang doesn’t have a sysroot for them. |
a923c6b to
9a90c94
Compare
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## master #1739 +/- ##
==========================================
+ Coverage 68.98% 70.18% +1.20%
==========================================
Files 162 162
Lines 19446 19443 -3
Branches 4643 4638 -5
==========================================
+ Hits 13414 13646 +232
+ Misses 3999 3756 -243
- Partials 2033 2041 +8
|
9a90c94 to
b54a005
Compare
|
Alright, I rebased on the latest master and put everything in separate commits for review.
Unless you pass the appropriate @ccadar I think this is now ready for another review. Once this is merged I plan to add freestanding Windows support (which should be fairly straightforward with these changes). |
b54a005 to
7a26354
Compare
|
The PR looks good to me overall, but I'm not a KLEE developer and can not approve. |
7a26354 to
acafcc9
Compare
|
Done! |
|
Thanks, @mrexodia . I see a test is failing now with ASan, can you take a look? |
Fixes an issue where off64_t and rlimit64_t are not always available.
acafcc9 to
b03cbaa
Compare
The failing tests appear to be |
|
I think it was |
|
Yeah the last force push was just to rebase on master, nothing else was changed. |
|
🥳 |
Summary:
Currently the 'freestanding' runtime is not actually freestanding, since it depends on system headers that might not be available. This PR addresses this issue by only using headers like
stddef.handstdint.h, which are part of the compiler headers (<clang prefix>/lib/clang/<version>/include) and therefore always available.For
errno.hit tries to include the host<errno.h>and if that does not work there is aKLEE_FREESTANDING_ERRNOimplementation copied from the Linux headers.My compilation settings (macos M1 pro with AppleClang):
I used LLVM 19, support for which was added in #1745.
Checklist: