top | item 8089321

GCC 4.9 is doing “some seriously crazy shit” according to Linus Torvalds

213 points| jdoliner | 11 years ago |lkml.org

238 comments

order
[+] userbinator|11 years ago|reply
As a long-time Asm programmer who has read a lot of compiler-generated code (usually for RE purposes), I completely sympathise with Linus - despite all the research and improvements, compilers are still very stupid, and will routinely generate code that no sane human would. The widespread notion that compilers can almost always generate better (faster or smaller) code than a human is probably closer to myth than reality. The one thing that is certainly true is they can compile orders of magnitude faster than a human can, and that's usually the main reason for using them.

I think the x86-64 ABI is also partly to blame for this mess - IMHO it's far too complex (e.g. the "red zone") and makes it easy for these bizarre edge-case-bugs to occur.

"Spilling a constant" is something I've never seen before and I'd probably WTF the first time I saw it, but thinking about it more carefully, it might actually be a wise choice in some cases - x86-64 unfortunately allows very few instructions with 64-bit immediate values, and those few instructions are very long (opcode + 8-byte immediate), so it could make sense to store some constant in memory, on the stack, for a while and put it in a register when it's needed with some moves - 64-bit r/m move with 8-bit displacement is 3/4 bytes. Of course that's not what GCC is doing here; that last move instruction is 6 bytes alone (mov + mod/rm + disp32.)

[+] e40|11 years ago|reply
More and interesting conversation happens here:

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=61904

[+] HCIdivision17|11 years ago|reply
The tone difference is certainly stark! The bug report feels like a process is in play, while the mail has a tone of a rant in a closed room.

I often take it for granted the compiler is always right (and it darn well just about is), but bugs like this look exactly like mis-cast magic to me. Learning how the compiler makes decisions seems like a rabbit hole, but may be fascinating enough to be worth it. (And think about being a maintainer of such a complex beast!)

[+] wfunction|11 years ago|reply
"Here's a small (auto-)reduced testcase for this specific issue"

Do you happen to know how that is done? How is a test case "auto"-reduced? I've never done that before.

[+] frik|11 years ago|reply
> The bad compiler versions are 4.5.0 (when debug_insn came in) to 4.8.3 and 4.9.0 and 4.9.1.
[+] rwmj|11 years ago|reply
I think it's a case of "bugs happen". They fixed this one pretty quickly.
[+] quarterto|11 years ago|reply
Can anyone give a layperson's explanation of what exactly GCC 4.9 is doing wrong here? I'm not fluent in Assembly and/or compiler internals. What's changed from 4.8?
[+] kazinator|11 years ago|reply
I've noticed it also has idiotic warnings. I have some code with macrology that generates lexically scoped typedefs, which are sometimes not used. I do not wish to be warned about these, damn it! Who cares about a typedef at lexical scope that is not used? It's compile-time only. What's next; a warning about every file-scope typedef that has not been used? "Hey you included <stddef.h> but never used ptrdiff_t!"
[+] jonahx|11 years ago|reply
Whatever you think of his language and attitude, the guy deserves some love for working a Goonies reference into a complaint about the GCC compiler.
[+] andrey-p|11 years ago|reply
I really enjoyed reading this even I don't understand any of what the bug is actually about. There's something about people who have taken swearing to a virtuosic level.
[+] Aardwolf|11 years ago|reply
What's up with the many insults? A bit of professionalism amongst developers would be nice...
[+] recalibrator|11 years ago|reply
Linus is just being Linus. I've been following him since Red Hat 5.2 and the open source culture has always been "colourful".

His words shouldn't be taken too personally, just as getting bitten by a grizzly bear shouldn't be taken personal.

[+] caf|11 years ago|reply
You'll notice that the insults are entirely directed at an inanimate piece of software.
[+] smcl|11 years ago|reply
I initially felt the same, but imagine if you'd spent countless hours getting to the bottom of an obscure bug that turned out to be a completely bone-headed compiler problem outside your control. Sometimes I think Linus goes a bit far, but this time I think he's justified in his venting his irritation
[+] rsynnott|11 years ago|reply
As in, Torvalds being mean about the compiler, or something else? That seems pretty par for the course in the context of a badly-broken thing that people tend to expect never to be broken.
[+] Svip|11 years ago|reply
So it will get posted on HN and other news websites.[0] Notice how no one else in the thread cares about Linus' language.

[0] He is after all warning about the use of gcc-4.9.0

[+] droopyEyelids|11 years ago|reply
He isn't a peer though. It's like how the hermit at the top of the mountain will smack the novice martial artist for making little mistakes. That doesn't make the novice resentful. Instead, he's glad for the training.
[+] test1235|11 years ago|reply
Sounds like regular ol' Linus to me ...
[+] tonfa|11 years ago|reply
If you read the gcc bug, he is rather professional.
[+] walshemj|11 years ago|reply
Non native speakers often don't have the instinctual grasp of slang and swearwords in English and so tend to use the F C and S words a lot without fully understanding the severity of the words.

"seriously crazy shit" seems a bit restrained for Linus though

[+] gkya|11 years ago|reply
Professionalism? Torvalds is a teenager with too much privileges.
[+] AgathaTheWitch|11 years ago|reply
Linus Torvalds says something thread on HN.

Prediction before clicking: Half of the thread, or more, will not be about what he says, but about his tone and "professionalism."

Never change HN. Never change.

[+] dang|11 years ago|reply
This comment has added far more off-topic gunk to the thread than anyone else's.

Please don't.

[+] nabla9|11 years ago|reply
I'm really baffled about this. Maybe I'm from older hacker generation (and I'm also a Finn). I just did not see personal insults going on. I would like to see more neutral discussion about cultural differences (between hackers and nations) and not opinions and own cultural biases stated as normative.

Here is my personal cultural bias:

1. Insulting people personally is not same thing as insulting their ideas or their actions. If someone insults my actions or my ideas, I may get emotional, but I don't take it as an insult. For me it means that I'm being challenged.

2. Cursing is not unprofessional or insulting in itself. Cursing is to be used for emphasis and to get people involved emotionally (good thing). Cursing has its place to signal frustration and get trough people. Too much cursing is like underlining everything.

3. (Anglo American) business culture is not necessarily something to be emulated. Being overly polite invites all kinds of side stepping, passive aggressive behavior and ineffectiveness. I feel that "being professional" is used here as thought terminating cliche.

4. Some hacker cultures can be both fiercely competitive and cooperative at the same time. Being heavily criticized and challenged is part of that process. Kernel hackers compete to get their ideas incorporated into the same codebase. Javascript hackers borrow snippets from each other and do their own things (no need to be as competitive as forking is easier). This might lead to different hacker cultures. What is accepted in one culture is not accepted in other.

5. Management by perkele[1] is management strategy that can be very effective with the 'Shut Up and Show Them the Code' hacker culture.

6. Pacabel may have a point. Younger generations may no be used to their work or behavior being harshly criticized and take it as personal insult. https://news.ycombinator.com/item?id=8089706

[1]: https://en.wikipedia.org/wiki/Management_by_perkele#Examples...

[+] danford|11 years ago|reply
It's like people don't think the same stuff is happening behind closed doors at other large tech companies.

Forget to turn off a mic at a political conference? You get worse stuff than this.

[+] peterwwillis|11 years ago|reply
My theory about this is that Linus treats his mailing list like a semi-public IRC chatroom (I mean, it is his mailing list for his kernel, so it makes sense) and HNers are not accustomed to that kind of cross-over if they've even ever idled on an irc channel run by hackers. It usually gets much more crass in there, so in that context these kind of comments make sense.

But when you consider Linus is responsible for, I dunno, billions? trillions? in spending on technology based on his OS, it's also easy to understand people getting nervous or offended by IRC-style banter. It's like seeing the CEO of a large company make jokes about retards. Pretty off-putting.

(And no, of course Linus is not a "CEO of Linux" and he doesn't owe anybody anything, i'm just saying I get how people could feel shocked or offended by his behavior)

[+] 1ris|11 years ago|reply
Seriously. If a community/somebodey cares more about how something is said more than what is said, said community/person lacks the allegedly so important professionalism.
[+] aeberbach|11 years ago|reply
Linus has earned the right to that tone, care about Linux or not. Now when some unknown emulates it, that's the time to take note (and ignore that person ever after).
[+] GFK_of_xmaspast|11 years ago|reply
This is deep into 'dog bites man' territory; Torvalds NOT being an asshole is the newsworthy story.
[+] parax|11 years ago|reply
Just use LLVM: http://llvm.org/
[+] keeperofdakeys|11 years ago|reply
Unfortunately the linux kernel still relies on some gnu C extensions for some low-level control of the output. I don't know if comparable stuff exists in llvm and clang, and if so, if linus has any plans on supporting them. However this is just bugs in a new compiler, and the Linux kernel is probably one of those things that hits cornercases.
[+] kzrdude|11 years ago|reply
And if you find one bug in llvm, switch back?
[+] userbinator|11 years ago|reply
The optimiser in LLVM does some even more "seriously crazy shit" - usually revolving around obscure edge cases involving officially undefined behaviour. Linus would definitely not be happy with that.