LWN.net Logo

Clang builds a working 2.6.36 Kernel

Clang builds a working 2.6.36 Kernel

Posted Oct 26, 2010 14:01 UTC (Tue) by juliank (subscriber, #45896)
In reply to: Clang builds a working 2.6.36 Kernel by jwakely
Parent article: Clang builds a working 2.6.36 Kernel

In any case, I simplified it to C and posted it to my blog at http://juliank.wordpress.com/2010/10/26/simple-code-clang-creates-1600x-faster-executable-than-gcc/


(Log in to post comments)

Clang builds a working 2.6.36 Kernel

Posted Oct 26, 2010 14:12 UTC (Tue) by rahulsundaram (subscriber, #21946) [Link]

You might want to report this to the GCC developers via mailing list or bugzilla.

Clang builds a working 2.6.36 Kernel

Posted Oct 26, 2010 14:35 UTC (Tue) by jwakely (subscriber, #60262) [Link]

Clang builds a working 2.6.36 Kernel

Posted Oct 26, 2010 14:32 UTC (Tue) by tzafrir (subscriber, #11501) [Link]

It also becomes way faster in gcc (4.4.5 here) once you remove "__attribute__((noinline))". This looks like a simpler explanation for the simpler code you posted there.

I didn't check it with clang.

And just to provide a working link:

http://juliank.wordpress.com/2010/10/26/simple-code-clang...

Clang builds a working 2.6.36 Kernel

Posted Oct 26, 2010 14:37 UTC (Tue) by juliank (subscriber, #45896) [Link]

> It also becomes way faster in gcc (4.4.5 here) once
> you remove "__attribute__((noinline))". This looks
> like a simpler explanation for the simpler code you posted there.

Then gcc calculates the result of f() at compile-time and just has a constant integer in the assembler code. Clang does not appear to do this (there's callq f in clang's assembly)

Clang builds a working 2.6.36 Kernel

Posted Oct 26, 2010 16:29 UTC (Tue) by gmaxwell (subscriber, #30048) [Link]

"Clang 100x faster than GCC!"

"But.. why did you handicap GCC?"

"Cause if I didn't GCC was much faster!"

(just saying… :) )

Clang builds a working 2.6.36 Kernel

Posted Oct 26, 2010 16:31 UTC (Tue) by juliank (subscriber, #45896) [Link]

> "Clang 100x faster than GCC!"
> "But.. why did you handicap GCC?"
> "Cause if I didn't GCC was much faster!"
> (just saying… :) )

GCC 4.5 at -O3 is as fast as clang, although not if you call the function via a pointer. GCC 4.4 has the same slow speed at -O2, -O3, -O4, -O9.

Clang builds a working 2.6.36 Kernel

Posted Oct 27, 2010 9:27 UTC (Wed) by jwakely (subscriber, #60262) [Link]

-O4 and -O9 don't exist, no surprise they aren't any better than -O3

GCC 4.5 has apparently already improved. Are you also comparing with a version of Clang from 18 months ago, when GCC 4.4 was released?

Clang builds a working 2.6.36 Kernel

Posted Oct 26, 2010 21:47 UTC (Tue) by tzafrir (subscriber, #11501) [Link]

To make this "handicap" more realistic, replace the constant with a command-line parameter.

Copyright © 2013, Eklektix, Inc.
Comments and public postings are copyrighted by their creators.
Linux is a registered trademark of Linus Torvalds