-
Notifications
You must be signed in to change notification settings - Fork 225
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
Investigate differences in clang format in CI and Windows #2552
Comments
I'm running it on Linux, not Windows.
I don't remember if we pinned CI to an earlier or later version... |
Ok. Thought you were developing on Windows too.
It’s clang format 10 probably? So something else must be wrong. |
I just tried running the clang-format check workflow on my repo: So it's weird... |
I'm using clang-format Version 13.0.1 on Windows and macOS and Version 10.0.0-4ubuntu1 on Linux.
|
Thanks for your comment. If I find time for it I’ll check what my clang-format does (but it should also be clang-format 10) @passing knows clang format well, so he might know what goes wrong. Else it might be worth opening an issue on the clang format action repo |
I had the same problem on my Qt6 work. |
I didn't have time to investigate all hints yet, but I mainly suspect discrepancies in clang-format versions to be the cause. I've checked https://github.com/jamulussoftware/jamulus/runs/5704004785?check_suite_focus=true (e36d3d6):
I don't have a good idea what to do about this though. We've decided against using a newer clang-format version in CI due to it not being widely available on Linux distribution packages. Maybe we should revisit this decision. What still needs investigation the case where Ubuntu's clang 10 disagrees as well. |
What is the output of |
Indeed. As said I use Version 13.0.1 on Windows and macOS and Version 10.0.0-4ubuntu1 on Linux. And locally they all agree. |
clang-format version 10.0.0 (https://github.com/muttleyxd/clang-format-static-binaries 5b56bb49b977b80cd18f44df4444db93e2d30f46)
Getting the same output from 13.0.1 on both Windows and macOS sounds reasonable to me. Getting the same output with 10.0.0-4ubuntu1 in the mentioned cases sounds surprising to me based on my tests. Can you confirm that the binary which is invoked is indeed extactly the version you've mentioned? Maybe some editors include their own (more-recent) clang-format?
I just tried it as part of a variable assignment/function call and could not reproduce anything unexpected with 149 columns, either with clang-format 10 or 13. Maybe it requires specific circumstances to trigger. As far as I understand, your local formatting (= clang-format 13) provides the better/correct result, right?
Yep. v13 output seems more logical.
llvm/llvm-project#27727 mentions formatting problems for pointer receivers when using
The #1432 PR check ran on 69a2411 and failed. All in all I can confirm that all the mentioned strangeness is reproducible with clang-format 10 (both with the binary from CI, but not with clang-format 13). There are huge numbers of Issues for clang-format. I see two ways foward:
In any case, we should specify which clang-format version we require (and mayb where to get it). |
We currently use clang-format 10 which has shown to produce unexpected output. This is annoying for PR submitters as the CI forces non-optimal code layout, especially when submitters use a later clang-format version which does not show this behavior. This commit changes CI to use clang-format 13 and updates relevant clang-format inline docs. Related: jamulussoftware#2552
We currently use clang-format 10 which has shown to produce unexpected output. This is annoying for PR submitters as the CI forces non-optimal code layout, especially when submitters use a later clang-format version which does not show this behavior. This commit changes CI to use clang-format 13 and updates relevant clang-format inline docs. Related: jamulussoftware#2552
We currently use clang-format 10 which has shown to produce unexpected output. This is annoying for PR submitters as the CI forces non-optimal code layout, especially when submitters use a later clang-format version which does not show this behavior. This commit changes CI to use clang-format 13 and updates relevant clang-format inline docs. This also updates the version of the Github Action to the latest version as this is required for v13 support. Related: jamulussoftware#2552
Have you tried it on my code? It's consistent except sometimes it isn't. One specific place it differs. |
Suddenly it's consistent. Nothing in that area of the code changed. But suddenly my local |
Strange indeed! On all tree systems I just used:
To do the clang-format, but no files seemed to change when clang-formatting the same folder on different OS'es. Just as strange is that if I do the same on a fresh clone of the jamulus master repo on Windows also nothing seems to change, though the files are validated with version 10.0.0 and I'm now checking with version 13.0.1 ??? As I said before, there seems to be playing more than just the clang-format version.... (Except for the pointer problem, in my sound-redesign repo, that one does give different results on 10.0.0 and 13.0.1, but also strange that this happens only at some positions in the file and other files with similar coding format also do not have the same problem.) |
Are there other tools that do something similar to clang-format that might work more reliably? |
Just a quick google says there are:
And probably there are more, but I doubt they would be any better... |
Can you provide some kind of reproducer? I can then have a look at this again. Until now, I haven't encountered any non-determinism (and I'd still be surprised to find any, but I'm happy to be proven wrong ;)).
I think |
Well this seems to be hard but this one seems to give different results. P.S.: Also see pljones's comment
Some things seem to be inconsistant independant of the clang-format version... P.S.2: Did CI already run a test on this commit ? It might "bypass" the problem and I don't see a failed check yet. |
According to the action, the commit was e36d3d6. I think I had already checked this in detail, but I've just done it again:
Conclusion: clang-format 10 consistenly makes improper changes. clang-format 13 consistenly fixes it.
Do you have a specific example where CI fails for this and local checks don't?
I saw that, but that's hard to investigate if it's no longer reproducible.
I'm trying to get this "seem to" backed by facts which make it reproducible (and hopefully: fixable).
The check was waiting for approval. I did that just now and it's green: https://github.com/jamulussoftware/jamulus/runs/5757957920?check_suite_focus=true |
No this doesnt' seem to be the same commit to me, though they both include the same problem in settings.cpp. But my link is a later commit, trying to fix all the clang-format errors. And on that one I DID check on both 10.0.0 and 13.0.1 where both gave the same OK result, but on CI only this, single, specific problem with alignment persisted.
Again strange that this NOT according my test results. (Again, there seems to be playing more, but we still have to find out what...)
Also see: https://github.com/jamulussoftware/jamulus/runs/5264767533?check_suite_focus=true [Line 70] And I just did some thorough testing on that one with some logical, as well as remarkable, results: So
But it again might indicate there is more playing than just clang-format versions...
So this really seems to be a way to avoid at least "some" clang-format problems... So, what I did was, do NOT use clang-format off/on around parts of statements, and use empty lines before and after clang-format off/on. (Though I'm not yet sure if the empty lines actually make a difference, they certainly make the clang-format controls themselves stand out more.) |
Can you help me pin-point the commit you mean? That says e36d3d6, so that's what this Action run was about. Maybe you meant a different run?
Yes, there's only one CI job for that which always runs from the checkout root.
We can't control that, but I hope that most IDEs/editors properly handle that case. It's not Jamulus-specific and I don't think it's appropriate to spray .clang-format files into each and every source dir.
Ah, nice finding!
Do you mean LF (\n) vs. CR-LF (\r\n)? All source files should be LF-only anyway. Current git seems clean in that way. We could consider adding/extending |
Yes correct, and this run still had a difference with the "alignment" problem. Which seems to have to do with the placing if the "clang-format off/on". (I have a later commit changing these clang-format off/on positions, and that one solved the problem.)
Yet but a manual
I totally agree, but it's worth nothing to verify if embedded tools use the correct clang-format config. Using
Is there a way to guarantee LF-only using clang-format ? Since creating a new file on Windows will default to CR/LF ! |
So... I'm a bit lost -- is there still some unexplainable thing to investigate in this context? If so, which?
I agree. Can you add a suggestion or comment to @ann0see's #2561?
I don't think we should advise against using tool-integrated formatting. It has to match what clang-format does, but the recent two PRs have been the only instances where we had actual confusions/problems around this area at all (and it isn't related to tool integrations, but to different clang-format versions, it seems).
Yes, it seems like the following config should work, but is only supported as of clang-format 11, so we could only do that after bumping the version, e.g. via #2559.
I'm happy to open a PR for this, but it requires a decision on #2559 first. Other than that:
I'd assume that this depends on the IDE/editor and its config. |
And, most important gitconfig ! |
Closing as I think this is fixed. #3020 |
Describe the bug
@pljones and @pgScorpio experienced unexpected clang format failures: see #2550 and #2551
To Reproduce
?
Expected behavior
Clang format on Windows should format the same as on the CI. I expect some unknown incompatibility.
Screenshots
Operating system
Windows and Linux
Version of Jamulus
N/A
Additional context
@hoffie
The text was updated successfully, but these errors were encountered: