Originally posted by Zoll
View Post
Announcement
Collapse
No announcement yet.
Linux 5.15's New "-Werror" Behavior Is Causing A Lot Of Pain
Collapse
X
-
Last edited by andreano; 08 September 2021, 04:18 PM.
- Likes 3
-
Some part of this discussion seems to be about if it is ok to write code that produces warnings. However for the kernel, that was already decided long ago and this decision has not changed. The policy is still "no warnings" without ifs and buts.
So to me it seems that for those cases like very old or very new compilers, or unusual configurations, it just needs to be possible to change the default without too much difficulty. Perhaps including a permanent setting per machine/user. Otherwise it is just a matter of getting from A to B, since there still seem to be areas where warnings occur during normal work (and it doesn't seem obvious if there is a specific reason other than lack of attention). So it seems that takes a few smaller steps instead of a single big one, but so far I haven't heard a convincing reason why -Werror shouldn't be the default for the kernel eventually. Certainly there should be something in place that prevents the situation where Linus and other maintainers too often have to deal with warnings that are not theirs to fix.
- Likes 3
Comment
-
Originally posted by lyamc View PostThis should be a net positive. A warning that is a nuisance either shouldn't be a warning (compiler should be fixed), or, it is a warning and the code should be fixed.
No, this doesn't fix all problems, it just addresses the simpler ones, which are still important to address.
- Likes 1
Comment
-
Originally posted by indepe View PostSome part of this discussion seems to be about if it is ok to write code that produces warnings. However for the kernel, that was already decided long ago and this decision has not changed. The policy is still "no warnings" without ifs and buts.
So to me it seems that for those cases like very old or very new compilers, or unusual configurations, it just needs to be possible to change the default without too much difficulty. Perhaps including a permanent setting per machine/user. Otherwise it is just a matter of getting from A to B, since there still seem to be areas where warnings occur during normal work (and it doesn't seem obvious if there is a specific reason other than lack of attention). So it seems that takes a few smaller steps instead of a single big one, but so far I haven't heard a convincing reason why -Werror shouldn't be the default for the kernel eventually. Certainly there should be something in place that prevents the situation where Linus and other maintainers too often have to deal with warnings that are not theirs to fix.
That code was getting to Linus (presumably signed off by the appropriate maintainers) but still had warnings demonstrates just how hard it is to know that a piece of code *never* emits warning for all kernel configurations and architectures.
if Linus wants -Werror by default then they first need CI build bots to test build against many different kernel configurations, target architectures and supported compilers/versions. Tossing it in during the middle of a release after a day of frustration was not ideal.
Eventually, they’ll end up merging code that turns out has build errors when options X/Y/Z are enabled and GCC or LLVM A.B.C is used.
the most aggressive long term strategy I can see working out without massive downstream pushback is where the only configurations and compiler versions where Werror gets enabled by default would be ones that have said build bots explicitly testing each one.
seems that they’ve rightly demoted the config to only trigger for BUILD_TESTING. I’m curious if any distributions will actually enable Werror for their own build servers. Would be great if they could get their eventually.
- Likes 2
Comment
-
Originally posted by perpetually high View PostThey should *not* be fighting the compiler. They should spend their time writing awesome code. (which the compiler "warnings" are there to help assist). I think we're overthinking this.
- Likes 4
Comment
-
Originally posted by lumks View PostLike in 5.15 builds 5.15.1 builds 5.15.2 wont build because there was a llvm update that now creates a feature deprecation warning. Badumm.
- Likes 1
Comment
-
Originally posted by Markopolo View PostThat code was getting to Linus (presumably signed off by the appropriate maintainers) but still had warnings demonstrates just how hard it is to know that a piece of code *never* emits warning for all kernel configurations and architectures.
- Likes 1
Comment
-
Originally posted by andreano View PostCompilers absolutely warn about language-defined behavior too, and it's not even all that useful. Example: -Wsign-compare: It's not like integer promotion rules aren't perfectly defined by the language. I would go as far as to say that when it comes to equality comparisons (where signedness of comparison is not even a thing), this warning is 100% detrimental: There is only one interpretation – the intended one, so there is nothing to whine about, all seasoned programmers know the integer promotion rules anyway, and it is detrimental, because "fixing" the code by adding explicit casts makes it not just less readable but more brittle.
andreano there are a lot of C warnings like sign-compare that happen to be about items that are undefined in the C standard some of them are things you would not think of that sign integer binary form is not defined in the C standard.
https://en.wikipedia.org/wiki/Protocol_Buffers from google was designed on a LSB signed platform.
They give it a cool name zig zag encoding. But it really LSB signed. Yes -2=3 as zig zag encoding does is a valid thing to happen when you do a sign to unsigned compare in C just people are not use to seeing this because they don't use LSB signed platforms. Sign-compare warning is in the same class as different warnings about endianness.
There is a problem here a lot of your seasoned programmers are only taught about MSB based signed never taught about LSB signed or the other odd ball forms. andreano you are one of them there is not a solid integer promotion rule. There is a dominate signed int type being MSB signed but the C standard does not mandate this. Neither does gcc or llvm there are architectures with gcc and llvm that are LSB signed.
So yes sign-compare is about undefined behaviour in the C standard that can catch you out.
- Likes 1
Comment
Comment