-
Notifications
You must be signed in to change notification settings - Fork 248
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
transpile
: Rewrite fn compare_src_locs
implementation to have a total order
#1128
Conversation
compare_src_locs
implementation to have a total ordertranspile
: Rewrite fn compare_src_locs
implementation to have a total order
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks! This looks a lot better, and the better comments help a lot as well.
Is there a test we can add to make sure this is working as intended (correctly sorted, no panics)?
I've added a test for the total order, based on a reduced test case from the issue (apparently creduce can reduce any text file). |
Not sure what my IDE did to the imports but I'll fix it, I'll also fix your other suggestions. But it will have to wait until after the weekend |
No problem, no rush. |
b562165
to
12f7571
Compare
@kkysen I've included your suggestions. Is there anything else that needs to change? |
12f7571
to
d499998
Compare
Added your last suggestion |
CI seems to be failing, only on Darwin, for some reason: /Users/runner/work/1/s/tests/statics/src/thread_locals.c:4:17: error: type specifier missing, defaults to 'int'; ISO C99 and later do not support implicit int [-Wimplicit-int]
static __thread gsti = 37;
~~~~~~~~~~~~~~~ ^
int
/Users/runner/work/1/s/tests/statics/src/thread_locals.c:5:17: error: type specifier missing, defaults to 'int'; ISO C99 and later do not support implicit int [-Wimplicit-int]
extern __thread geti;
~~~~~~~~~~~~~~~ ^
int
/Users/runner/work/1/s/tests/statics/src/thread_locals.c:12:21: error: type specifier missing, defaults to 'int'; ISO C99 and later do not support implicit int [-Wimplicit-int]
static __thread fsti = 59;
~~~~~~~~~~~~~~~ ^
int
/Users/runner/work/1/s/tests/statics/src/thread_locals.c:13:21: error: type specifier missing, defaults to 'int'; ISO C99 and later do not support implicit int [-Wimplicit-int]
extern __thread feti;
~~~~~~~~~~~~~~~ ^
int This doesn't seem to be related to the changes, here, though, so I'm not sure what's happening. |
Maybe the darwin image got updated or something? I really don't see how this change can cause this |
Could you try triggering the CI on the last commit in master? See if it has the same failure |
d499998
to
e9082bb
Compare
This implementation is simplified compared to the previous one. It is also almost twice as slow in the exhaustive test (15 vs 25 seconds) in immunant#1126 (comment) However, in real sort usage the impact should be significantly less. Fixes immunant#1126
Also included some code suggestions by Khyber. Co-authored-by: Khyber Sen <[email protected]>
e9082bb
to
ea15739
Compare
@kkysen with your CI fix from yesterday, this PR is now green again. |
Awesome! I'll merge this now. Sorry for the delay with the CI, and thanks for fixing this! |
Oops, I'm now getting a different CI error in the CI workflow that won't run on outside contributors' PRs correctly: https://github.com/immunant/c2rust/actions/runs/11493361902/job/31988919249. Do you have an idea of what this might be? Sorry this CI workflow still isn't set up to correctly run on external PRs. |
Maybe a path confusion? If you look at the first error:
It seems that C2RustUnnamed_4 is put in |
…rcLoc` order #1128 fixed the non-total (non-transitive) `SrcLoc` ordering, but accidentally broke the `curl` transpilation test in `c2rust-testsuites`, which is tested in CI, but was broken for external contributors PRs (fixed now in #1159). In the `curl` transpilation, a couple of `use` imports (`__sigset_t` and `C2RustUnnamed_4`) were missing, cause the build to fail afterward. I'm still not exactly sure why this fixes the issue while maintaining a transitive, total order, but it passes the total order test and transpiles `curl` correctly now. Hopefully this is a complete fix, and I didn't just fix a one-off error in `curl`.
…rcLoc` order (#1163) #1128 fixed the non-total (non-transitive) `SrcLoc` ordering, but accidentally broke the `curl` transpilation test in `c2rust-testsuites`, which is tested in CI, but was broken for external contributors PRs (fixed now in #1159). In the `curl` transpilation, a couple of `use` imports (`__sigset_t` and `C2RustUnnamed_4`) were missing, cause the build to fail afterward. I'm still not exactly sure why this fixes the issue while maintaining a transitive, total order, but it passes the total order test and transpiles `curl` correctly now. Hopefully this is a complete fix, and I didn't just fix a one-off error in `curl`. * 9679a3b is the real fix. * a4a052b are generally useful for testing and debugging.
This implementation is simplified compared to the previous one. It is also almost twice as slow in the exhaustive test (15 vs 25 seconds).
However, in real sort usage the impact should be significantly less.
SrcLoc
sorting is non-transitive and a false total order and equality (panics in 1.81) #1126