
GCC 4.9 is doing “some seriously crazy shit” according to Linus Torvalds - jdoliner
https://lkml.org/lkml/2014/7/24/584
======
userbinator
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
More 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)

~~~
wfunction
"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
For 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)

~~~
jpgvm
This is awesome, thanks mate!

~~~
gwern
If you find this topic interesting, look up everything written by
[http://blog.regehr.org/](http://blog.regehr.org/)

------
davidgerard
Fixed in tree:
[https://gcc.gnu.org/bugzilla/show_bug.cgi?id=61904](https://gcc.gnu.org/bugzilla/show_bug.cgi?id=61904)

~~~
reidrac
I find interesting that the tone in the bug report is completely different (no
"colourful language").

~~~
kuon
Because one don't fuck with bug report!

~~~
reidrac
I think it is more related to the fact that it is an external project (I
assume with different community interactions). So all that "Linux being
himself" it's not that accurate.

------
quarterto
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?

~~~
kryptiskt
It 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.

------
kazinator
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
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
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
What's up with the many insults? A bit of professionalism amongst developers
would be nice...

~~~
recalibrator
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.

~~~
Tyrannosaurs
That may be so but I'm pretty sure that pretty much every study that's been
done on this says insulting people is demotivating and generally destructive
behaviour.

Linus can believe what he likes but the evidence contradicts him.

~~~
Mithaldu
He has not insulted any people though. He has said bad things about the piece
of software called gcc-4.9.0, but he has not once in that email adressed a
person in a negative way.

Plus, the bug report he filed towards gcc is entirely matter-of-fact and
polite.

~~~
Pacabel
As I've worked with more and more younger developers ("Millennials" or
"hipsters" or whatever you want to call them), I've noticed that many of them
consider criticism of somebody's work to be a criticism of the work's creator
himself or herself.

I don't really know for sure why this is. Maybe they're more attached to what
they've created, seeing it more as a work of art or something like that,
instead of just a tool?

~~~
kawsper
Sam Stephenson (Author of Prototype and Rbenv) talks about that here:
[http://sstephenson.us/posts/you-are-not-your-
code](http://sstephenson.us/posts/you-are-not-your-code)

------
AgathaTheWitch
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.

~~~
nabla9
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](https://news.ycombinator.com/item?id=8089706)

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

~~~
kghose
I think that the overly critical culture of many European nations prevents
younger people from trying out or voicing ideas because humans are human and
don't like being humiliated , especially in public. This is something I think
we should not emulate.

~~~
nabla9
>overly critical culture of many European nations prevents younger people from
trying out or voicing ideas

I don't think this is what is happening here.

>humans are human and don't like being humiliated , especially in public.

This is just the cultural difference I'm talking about. Someone criticizing
your work or behavior does not universally signal humiliating you as a person.
I acknowledge that this may be so for you personally or in your culture.

~~~
kghose
Hi nabla9,

I read the bug report thread and that was as professional as I would expect
from grownups. I was responding to your statement about anglo-american
culture.

I have observed this "it's OK to be direct" motto from some parts of modern
Europe and, interestingly for me, Israel.

Everything we interpret depends on our training, but my observation is that
this motto is very commonly interpreted to allow rude, condescending and
arrogant behavior. I spent a lot of time in India. In this respect correct
behavior (as taught to us by our parents) aligns with the Anglo-American view
of politeness in many respects.

I have come to believe that the directness championed by some current European
cultures may perhaps be a modern phenomenon, not so common before the 1940s in
those countries?

I agree that too much politeness can be perverted into passive aggressive
behavior but so can (and I think is) this "Let's be direct" attitude.

There has been much talk on HN and everywhere else of how to develop a code of
conduct that allows honest exchange but maintain civility. I think politeness
and respect is a central part of this code.

People are not computers. You can not kick them when their output does not
please you. You can not kick them when you think you are better than them.

Well, perhaps you can. Perhaps being rude and arrogant leads to a better
world.

I would like, however to live in a world where everyone tries to respect each
other and show that respect.

Best

------
GFK_of_xmaspast
This is deep into 'dog bites man' territory; Torvalds NOT being an asshole is
the newsworthy story.

------
parax
Just use LLVM: [http://llvm.org/](http://llvm.org/)

~~~
keeperofdakeys
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.

~~~
exDM69
I'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.

