11 ms·
GCC 4.9 is doing “some seriously crazy shit” according to Linus Torvalds
- e40 12y agoMore and interesting conversation happens here: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=61904 https://gcc.gnu.org/bugzilla/show_bug.cgi?id=61904
- frik 12y ago> 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.
- wfunction 12y ago"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.
- kzrdude 12y agoFor example http://embed.cs.utah.edu/creduce/ http://embed.cs.utah.edu/creduce/ ; the slides from a presentation in 2012 are interesting: http://embed.cs.utah.edu/creduce/pldi12_talk.pdf http://embed.cs.utah.edu/creduce/pldi12_talk.pdf
- a3_nm 12y agohttps://gcc.gnu.org/wiki/A_guide_to_testcase_reduction https://gcc.gnu.org/wiki/A_guide_to_testcase_reduction
- wfunction 12y agoThank you!
- dochtman 12y agoThe LLVM project recommends delta: http://delta.tigris.org/ http://delta.tigris.org/
- CyberShadow 12y agoFor D we use DustMite (disclaimer: I'm the author). It also works to some extent with C/C++ (thanks to the languages' syntax being similar enough). https://github.com/CyberShadow/DustMite/wiki https://github.com/CyberShadow/DustMite/wiki
- rwmj 12y agoI think it's a case of "bugs happen". They fixed this one pretty quickly.
- HCIdivision17 12y agoThe 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!)
- davidgerard 12y agoFixed in tree: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=61904 https://gcc.gnu.org/bugzilla/show_bug.cgi?id=61904
- reidrac 12y agoI find interesting that the tone in the bug report is completely different (no "colourful language").
- Aardwolf 12y agoWhat's up with the many insults? A bit of professionalism amongst developers would be nice...
- test1235 12y agoSounds like regular ol' Linus to me ...
- stickydink 12y agoThis is just Linus, unfortunately
- Svip 12y agoSo 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
- Argorak 12y ago> Notice how no one else in the thread cares about Linus' language. Except Sarah Sharp and others.
- Svip 12y agoI cannot seem to find her mail or the others' in this thread. Am I missing something or are you referring to previous instances of Linus' outbursts? I guessing on the latter, in which case I specifically wrote 'the thread' for this reason.
- Argorak 12y agoMeh, yes. Shouldn't post replies like that at 40 degrees celsius outside ;). You are right.
- rsynnott 12y agoAs 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.
- parax 12y agoJust use LLVM: http://llvm.org/ http://llvm.org/
- kzrdude 12y agoAnd if you find one bug in llvm, switch back?
- LeoNatan25 12y agoMove to MSVC++ :P
- a3_nm 12y agoPeople are working on it http://llvm.linuxfoundation.org http://llvm.linuxfoundation.org but it is not a trivial thing to do.
- keeperofdakeys 12y agoUnfortunately 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.
- exDM69 12y agoI'm not sure which C extensions do you mean, but Clang supports most of the same GNU extensions that GCC does. Indeed, it's one of the goals of Clang to be compatible with GCC whenever possible. However, there might be some things that are not (yet?) supported. And the kernel can be compiled using LLVM and Clang, but not quite in all configurations. But compiling mainline kernel for x86 using LLVM was achieved some years ago.
- gillianseed 12y agoA lot (if not the majority) of GCC extensions used by Linux exist in GCC because the Linux kernel developers requested them in order to have a great level of control in terms of the generated machine code, so it's not exactly surprising that the Linux kernel relies on a lot of said GCC extensions. Many of these extensions which the Linux kernel relies on have been added to LLVM, but obviously not all, and from the looks of it some never will, which means either Linux needs to refrain from using said extensions, or building Linux using LLVM will continue to require patching.
- lodewijkadlp 12y agoTo be fair, that does seem like crazy shit. A bug free compiler is really essential, and it was really quite messed up.
- AgathaTheWitch 12y agoLinus 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.
- aeberbach 12y agoLinus 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).
- currysausage 12y agoQuod licet Iovi, non licet bovi.
- themartorana 12y agoWell quoted. It's always fascinated (and worried) me how the human brain allows for the elevation of certain people to God-like status, and then excuses behavior they would normally find abhorrent.
- michaelcampbell 12y agoErik Naggum and Tom Christiansen come to mind.
- hollerith 12y agoThe important thing to note about Erik's behavior is that occurred on Usenet, and unlike the mailing list or places like HN, on Usenet, there were (I have not looked closely at Usenet for about 12 years) no "owners" or moderators for a newsgroup and no way for the newsgroup considered as a "community" or a "collective" to enforce behavioral norms (e.g., around politeness) on individual posters. Individuals regularly complained about Erik's nastiness, saying (correctly, IMHO) that he was scaring people away from Lisp. Also, I never saw any of the intense admiration for Erik on comp.lang.lisp when Erik was alive that I have seen on Hacker News. The quality of his Lisp code and the insightfulness of his posts won him respect from many on comp.lang.lisp (specifically, those who accepted that there were almost no limits on speech on Usenet), but he would definitely not have been tolerated for long in most places on the internet where technical subjects are seriously discussed today (particularly HN, which has higher politeness bars than most such places) if he were posting with the same hostility that he did on comp.lang.lisp.
- quarterto 12y agoCan 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?
- kryptiskt 12y agoIt is doing two things wrong, it is moving a constant value to the stack and it's doing it before increasing the stack pointer, so it's momentarily outside the stack area. If an interrupt hits during the instructions the stack is broken, the interrupt service routine will increase the stack for its own use and overwrite that value.
- masklinn 12y agoSee the bug report linked by e40[0] for explanations. Interestingly, the bug actually exists since 4.5.0, it just doesn't trigger because of different optimisations being applied elsewhere. [0] https://gcc.gnu.org/bugzilla/show_bug.cgi?id=61904 https://gcc.gnu.org/bugzilla/show_bug.cgi?id=61904
- deleted 12y ago[deleted]
- andrey-p 12y agoI 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.
- jonahx 12y agoWhatever you think of his language and attitude, the guy deserves some love for working a Goonies reference into a complaint about the GCC compiler.
- deleted 12y ago[deleted]
- kazinator 12y agoI'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!"
- userbinator 12y agoAs 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.)
- GFK_of_xmaspast 12y agoThis is deep into 'dog bites man' territory; Torvalds NOT being an asshole is the newsworthy story.