GCC 4.0.0 Released 680
busfahrer writes "Version 4.0.0 of the GNU Compiler Collection has been released. You can read the changelog or you can download the source tarball. The new version finally features SSA for trees, allowing for a completely new optimization framework." The changelog is pretty lengthy, and there's updates for every language supported from Ada to Java in addition to the usual flavors of C.
Sweetness (Score:5, Informative)
Re:Is anyone else curious what SSA trees are? (Score:5, Informative)
Re:Is anyone else curious what SSA trees are? (Score:4, Informative)
Re:Great Timing (Score:4, Informative)
Re:Is anyone else curious what SSA trees are? (Score:5, Informative)
To put it simply, SSA is an intermediate representation where each variable in a block is defined only *once*. If a variable is defined multiple times, the target of any subsequent definitions of the same variable is replaced by a new variable name.
SSA helps to simplify later optimizations passes of a compiler (for example: eliminating unused definitions, etc) as described in greater detail (with examples and flowcharts) in the article linked to.
That's the SSA form in short. Now I need to ask somebody the difference between the standard SSA form and "SSA for trees".
Re:Great Timing (Score:2, Informative)
Re:Testing the old girl out... (Score:4, Informative)
FYI: Red Hat has a guy working full-time on building OOo on GCJ. His blog. [linux.ie]. Not that everything works straight out-of-the-box. But it's not like nothing works either.
(And from what I've heard, you can't expect it to work out of the box either. Sun's coders have done a terrible job and adding all kinds of dependencies on undocumented Sun-internal classes. So it probably doesn't work on Apple's JDK either, and that one is Sun-approved!)
Re:Lisp? (Score:5, Informative)
Re:Great Timing (Score:2, Informative)
From Feburary: http://lwn.net/Articles/124798/ [lwn.net]
That article includes the question/answer:
- Does that mean Fedora Core 4 will ship with a pre-release compiler?
We're not *that* crazy. If GCC 4.0 is delayed, we will either revert, or slip.
Re:Figured this had to happen (Score:5, Informative)
Well, you're wrong because GCC doesn't follow Apple's schedule, or anyone else's for that matter. Even a cursory glance at the GCC mailing list will tell you that.
The reason Apple can promise this is that they're not actually shipping GCC 4. They're shipping their own fork of the GCC 4 code. It's probably about 99% the same code, but don't make the mistake of thinking they're shipping exactly what the FSF is distributing.
Re:Moving fast (Score:3, Informative)
gcc -v on Fedora 4 test 2 (Score:4, Informative)
Using built-in specs.
Target: i386-redhat-linux
Configured with:
Thread model: posix
gcc version 4.0.0 20050405 (Red Hat 4.0.0-0.40)
Re:Readme.SCO (Score:1, Informative)
Re:Moving fast (Score:2, Informative)
Re:Is anyone else curious what SSA trees are? (Score:2, Informative)
does this mean executables compiled with GCC 4 and optimized properly will run faster?
In the long run, yes. But for now, I'd imagine that because the SSA form is so new to the GCC codebase, the GCC maintainers are waiting for latent bugs to surface and be fixed before squeezing the most wizardly optimizations out of the SSA tree.
Re:Autovectorization (Score:2, Informative)
You are. Most packagers have assumed for at least a couple of years that everybody has a 486 or better. Some are so bold to assume you have a 586 or better. If you don't meet those requirements, you can compile it yourself (it's open-source).
Re:What a coincidence (Score:5, Informative)
While it is true the syntax has changed (much for the better: templates are now supported in managed C++ code and so are generics, keywords replace ugly __gc, and more), support for the old syntax is still in the compiler (/clr:oldSyntax), and IntelliSense.
However, you will be unable to mix new syntax and old syntax code in the same project without taking some penalties (IntelliSense will break, at the least). The designer will even spit out old syntax code when designing an old form or control.
While the old syntax is definitely on its last legs, the VC++ team was very concerned about not screwing over those (early) adopters of C++ code for the CLR thus far.
A good resource to read up more on the subject would be Herb Sutter's Blog [msdn.com], Stan Lippman's Blog [msdn.com], or any of the other VC++ team member's blogs.
Take this from a former VC++ teammate who left during the Whidbey product cycle (posting AC since I've never bothered to get a slashdot account).
Re:Is anyone else curious what SSA trees are? (Score:5, Informative)
Trying to recall my knowledge of optimizing compilers:
SSA makes optimization easier, since it is obvious where a variable was assigned (since it was assigned in only one location) and what value it contains (since there is only one value being assigned to it). The complexity moves to register allocation, where there can be many more variables to allocate because of SSA. Register allocation is Hard, but doing an ok job is quite possible. Most optimizations are impossible unless you can prove various properties about the variables involved, which is often much easier with variables in SSA form.
Re:Compatibility? Linux testing? (Score:5, Informative)
Re:Is anyone else curious what SSA trees are? (Score:2, Informative)
I wanted to know the differences in the optimization levels, so I made up a script[1] that compiled zlib and libpng with various optimizations on various archs and timed how long it took to run the test suite with 4 various images[2][3][4][5].
I ran this test on a 2.8GHz Intel P4 HT proc, with 512MB Kingston HyperX DDR-400. Results are here [brantleyonline.com].
The X axis, is in the format "L-Z", where "L" is the libpng optimization level (3, 2, 1, 0, or s (size)), and "Z" is the zlib optimization level (3, 2, 1, 0, or s (size)). The Y axis is in seconds, and for precise values, look at the graph data vs the visual graph.
The google logo[3] was useless, it's far too small to give me accurate results. However, if you compare the comic[5], the difference is 0.665 seconds... while this may not seem *huge*, in the case of a server where every tenth of a second counts, multiply the time by requests and compare the two. In the simple case of a libpng test case (opens a PNG image, re-writes it, compares the old to the new), optimizations matter, and a lot.
Of course, some code can be optimized more than others, and there is a large number of variables to take into account, but I'd hope that booting into single user mode and running this in a terminal should remove as much of that as possible.
The thing is, very few people are going to notice the 2/3rds of a second optimizations give you, vs the hours spent compiling OpenOffice.
Not linked due to bandwidth reasons (384kbps upstream = teh suck)
[1]http://www.brantleyonline.com/sf.sh
[2] Tranqulity - @ gallery.artofgregmartin.com - down due to bandwidth, but it's a 1.4MB file (PNG format), 1600x1200, using a large variety of blues and blacks.
[3]http://www.google.com/intl/en/images/logo.gif
[4]Screenshot of OSX on dual monitors, large amount of windows, varied transparancies, 1440x576, 570.2kb. (not linked due to bandwidth)
[5]http://www.applegeeks.com/comic_archive/viewco
Note: if you use the script, please, PLEASE, mirror the images LOCALLY and use that instead...
Re:Is anyone else curious what SSA trees are? (Score:5, Informative)
Hmm. Funny. Seems like perfect timing, in retrospect. I just held a presentation on SSA (and efficiently transforming code into SSA) today.
Get the slides here [udel.edu].
HTH
Re:Autovectorization (Score:4, Informative)
Fedora Core, for example, relies on the improved instructions for atomic operations found in 486 and newer processors, necessary for certain threading libraries. The rpm program itself requires a 586, if I don't remember wrong.
Fedora Core also compiles all binaries optimized for P4. It was decided to use P4 optimizations, since these generally work just as well on Athlon processors, while Ahtlon optimizations is rather slow on a P4.
Furthermore, for CPU intensive applications such as many audio and video applications, CPU optimizations such as MMX and SSE are automatically activated at runtime if the CPU supports it.
The 'i386' in the name should really be called 'x86'. Of course, then there's also 'i686' packages, which basically mean 'x86 processors that support the CMOV instruction'. That is also wrong, as there are i686 processors which do not support CMOV, such as certain VIA and Cyrix variants.
CMOV is basically the only useful addition to the x86 instruction set since the i486 for general purpose programs. And programs not fitting into that category, already have hand written asm for time critical sections, which can take advantage of MMX, SSE, 3DNow, Altivec or VIS.
Re:works great! (Score:2, Informative)
Re:Something fun with compiling... (Score:2, Informative)
GCC 4.0's biggest winner is probably KDE (Score:5, Informative)
Re:Readme.SCO (Score:2, Informative)
SCO is so not a threat they decided to delete the page. (404 Not Found)
oh, wait. here it is [fsf.org]
Re:Is anyone else curious what SSA trees are? (Score:5, Informative)
1) Tokenize the input. For example, if you were compiling perl, you might choose to turn "print $foo" into three tokens; KEYWORD_PRINT, TYPE_SCALAR, and IDENTIFIER('foo'). The output is typically a stream of tokens. This step might be done by lex or flex.
2) Parse the sequence of tokens using a set of rules called a grammar. For example, "TYPE_SCALAR" followed by "IDENTIFIER()" is might match a rule to generate a variable called "$foo", and "KEYWORD_PRINT" followed by a variable means call the function print on the contents of the variable. The output is typically an abstract syntax tree (AST); a high-level data structure representing the program. This step might be done by yacc or bison.
3) Match the AST against a series of rules to output the final code. This might actually be two steps; you might generate something into a low-level register transfer language (RTL) that looks very much like assembly, and then turn THAT into actual machine instructions.
At each stage, you might choose to optimize the output. You might also insert optimizations passes between steps. (For example, you might insert a pass between 2 and 3 to optimize the AST into a simpler AST.)
Before SSA, GCC sort of skipped making any high-level AST; it used to go from parsing almost immediately into a RTL. You can still optimize RTL, but since it's pretty low-level, it misses out on higher-level context and made some optimizations really difficult.
SSA is simply a form used for the high-level AST. Why SSA? It is a very nice form to optimize. Read the wikipedia article for more details on why SSA is particularly useful for some optimizations.
Page 181 of this PDF file [linux.org.uk] from the 2003 GCC Summit explains the flow of the GCC compiler.
Re:Is anyone else curious what SSA trees are? (Score:1, Informative)
If I understand it correctly, tree-ssa is just the parse tree, where each block has been converted to SSA. It's just the internal name for the SSA infrastructure.
Of course, there's a link in the article summary to the GCC wiki page on tree-ssa. You might as well RTFA
Patent issues (Score:5, Informative)
They mean this patent [uspto.gov] owned by this company [microsoft.com]. What a surprise.
Getoo forum thread on gcc 4 (Score:4, Informative)
Re:how much java comaptibility (Score:1, Informative)
#
# There have been many improvements to the class library. Here are some highlights:
* Much more of AWT and Swing exist.
* Many new packages and classes were added, including java.util.regex, java.net.URI, javax.crypto, javax.crypto.interfaces, javax.crypto.spec, javax.net, javax.net.ssl, javax.security.auth, javax.security.auth.callback, javax.security.auth.login, javax.security.auth.x500, javax.security.sasl, org.ietf.jgss, javax.imageio, javax.imageio.event, javax.imageio.spi, javax.print, javax.print.attribute, javax.print.attribute.standard, javax.print.event, and javax.xml
* Updated SAX and DOM, and imported GNU JAXP
Now, go and test it. Report your results
Re:how much java comaptibility (Score:2, Informative)
"There have been many improvements to the class library. Here are some highlights:
Much more of AWT and Swing exist.
Many new packages and classes were added, including java.util.regex, java.net.URI, javax.crypto, javax.crypto.interfaces, javax.crypto.spec, javax.net, javax.net.ssl, javax.security.auth, javax.security.auth.callback, javax.security.auth.login, javax.security.auth.x500, javax.security.sasl, org.ietf.jgss, javax.imageio, javax.imageio.event, javax.imageio.spi, javax.print, javax.print.attribute, javax.print.attribute.standard, javax.print.event, and javax.xml
Updated SAX and DOM, and imported GNU JAXP"
http://gcc.gnu.org/gcc-4.0/changes.html [gnu.org]
Re:debian (Score:5, Informative)
You're right. (Score:3, Informative)
The different languages ARE separated into different compilers.
Re:stupid dumb moronic question (Score:4, Informative)
Does all this extraneous language support make gcc bloated for single-language compilation?
Short answer: No.
Long answer: pretty much every compiler around goes through the following steps: (a) make an abstract syntax tree from the source code, (b) optimize it, and (c) output machine code. No matter what language you're using, these steps must be performed; a multi-language compiler simply provides many ways of doing (a). But since optimization happens after (a) anyway, it doesn't matter.
That's oversimplifying, since if a compiler were tuned to a single language it could probably use a slightly simpler abstract syntax tree format. But the benefits would be slight; it's far more useful to support tons of languages at little extra effort than to drop all alternate languages for a minor performance gain.
people use -fweb (Score:3, Informative)
So the choice has been:
Re:Moving fast (Score:1, Informative)
Apple wasn't, but NexT sure was. Objective C was a hacked up gcc.
Re:debian (Score:1, Informative)
Re:Moving fast (Score:3, Informative)
in terms of technology, SSA is far more important as it optimizes "the big picture".
Gentoo with GCC 4 (Score:2, Informative)
Then be prepared to switch between gcc 3.4 and 3 a lot because many packages, especially multimedia packages, fail to build.
Re:vectorization very rarely works (Score:3, Informative)
> and found out that tuning for 686 with gcc only
> provides 1-2% improvements in the best case.
Uh what? It is true that i386 code runs in the ballpark on a Pentium IV, but this most definitely was not true for the Pentium III and is not true for the Pentium M. Those processors have the 4-1-1 rule, which is to say that you'll stall concurrent execution of instructions unless you arrange a complex instructions (4) with two simple ones (1). This is because there aren't enough execution units to handle any kind of instruction.
TR1 included! (Score:5, Informative)
Re:debian (Score:3, Informative)
As Debian sid is the unstable branch of Debian, the release cycle is pretty unimportant for gcc's inclusion. Looking at the experimental branch, you'll find gcc 4.0 already included: http://packages.debian.org/experimental/devel/
(
In sid itself exists a snapshot of gcc as of 20050319.
Re:"Paltry" is probably a poor choice of words (Score:5, Informative)
Mac OS X itself is compiled with GCC 4. That was the point. Hence, all Mac users depend on GCC 4. That's 40 million and counting according to the latest figures.
Re:Autovectorization (Score:5, Informative)
Also, there aren't nearly enough people using MOVNTDQ to avoid polluting the instruction pipeline and dumping useless garbage into the system cache. If you're copying stuff into main memory and you aren't going to use it for a while, use MOVNTDQ to get a big speed win. If you do need it cached, use MOVDQA to get both caching and 128 bit transfers in one instruction! We all paid for these fancy schmancy new instructions in our processors, and it's extremely annoying to see programmers not use them.
Re:Objective-C++...? (Score:4, Informative)
Fact is, demand for Objective-C++ from our developers is so close to zero as to be completely insigificant. Seriously, there's more demand for Python than Objective-C++. Honest to God, Python!
All the ISVs who are still using C++ are building their apps with Core Foundation, not with Cocoa. That's fine. Core Foundation is a first-class application platform in Mac OS X. It's just so much more of a pain in the ass to use, developers are flocking away from C and C++ to reimplement in Objective-C, not even bothering with Objective-C++ along the way.
So it's not that we don't have the time. It's that we don't see the point.
Re:vectorization very rarely works (Score:2, Informative)
The changes between 386 and 686 in instruction sets alone make optimizing for specific platforms more than worth it. In fact, at the performance lab at [big chip manufacturer where I work as an electrical engineer], we have observed as much as a 43% speed gain in compiled applications using a platform-optimized compiler!
Granted these optimizations would be compiler-specific, and were obviously not made using GCC. However, your assertion that "tuning for 686 with gcc only provides 1-2% improvements in the best case" is simply absurd. Please get a clue before you post nonsense.
Re:Figured this had to happen (Score:5, Informative)
According to http://gcc.gnu.org/install/specific.html#powerpc-
i.e. you're using a forked version of GCC, and definitely not 4.0.0 out of the box.
the whole notion of "a fork" runs 100% counter to all that open-source stuff
No, actually, the importance of the ability to fork and wisdom to know when to fork is very important to "that open-source stuff".
Re:GCC 4.0's biggest winner is probably KDE (Score:5, Informative)
-a GNOME/KDE agnostic fluxbox user
Re:stupid dumb moronic question (Score:1, Informative)
Re:Pascal (Score:3, Informative)
GNU Pascal supports building with a number of versions of GCC, and work on GNU Pascal is with a released version of GCC. The GCC developers want GNU Pascal as just another frontend; changes should go to GCC head, and there shouldn't be #ifdefs to get it to compile with different versions of the compiler backend. That's a large problem that has stopped GPC from being merged.
Re:Lisp? (Score:5, Informative)
Yes, gcl (formerly known as kyoto common lisp). But it doesn't need the assembler/linker part of the toolchain so it's packaged separately. But I think it is "Part of the GNU Compiler Collection", for what that's worth, and it does depend on GCC.
Re:Why? (Score:3, Informative)
Man... I'd almost forgotten. the 5/6 libc switch was horrendous, much worse than the 2/3 gcc switch.
Another big problem was that a lot of the early proprietary Linux software vendors hopped on board right before both of those switches, so there were a boatload of closed-source apps requiring ecgs and a patched libc5 or some other bizarre combination.
Re:No hope for named warnings (Score:4, Informative)
Maybe I'm missing something, but this warning is GCC telling you that it's not going to compile that code.. so you can't possibly "need" it because GCC doesn't even compile it.
uint8_t i=0;
if (i>300)
{
printf("hello");
}
Compile that, and then see for yourself.. strings a.out | grep hello will return nothing. gcc optimizes your useless check right out.
Found it: ISO C standard, sections 5.2.1 and 7.9.2 (Score:3, Informative)
Cheers,
Ian
Re:Found it: ISO C standard, sections 5.2.1 and 7. (Score:2, Informative)
-pedantic
Issue all the warnings demanded by strict ISO C and ISO C++; reject all programs that use forbidden extensions, and some other programs that do not follow ISO C and ISO C++.For ISO C, follows the version of the ISO C standard specified by any -std option used.
Valid ISO C and ISO C++ programs should compile properly with or without this option (though a rare few will require -ansi or a -std option specifying the required version of ISO C).However, without this option, certain GNU extensions and traditional C and C++ features are supported as well.With this option, they are rejected.
-pedantic does not cause warning messages for use of the alternate keywords whose names begin and end with __.Pedantic warnings are also disabled in the expression that follows "__extension__".However, only system header files should use these escape routes; application programs should avoid them.
Some users try to use -pedantic to check programs for strict ISO C conformance.They soon find that it does not do quite what they want: it finds some non-ISO practices, but not all---only those for which ISO C requires a diagnostic, and some others for which diagnostics have been added.
A feature to report any failure to conform to ISO C might be useful in some instances, but would require considerable additional work and would be quite different from -pedantic.We don't have plans to support such a feature in the near future.
Where the standard specified with -std represents a GNU extended dialect of C, such as gnu89 or gnu99, there is a corresponding base standard, the version of ISO C on which the GNU extended dialect is based.Warnings from -pedantic are given where they are required by the base standard.(It would not make sense for such warnings to be given only for features not in the specified GNU C dialect, since by definition the GNU dialects of C include all features the compiler supports with the given option, and there would be nothing to warn about.)
"pendantic" is a ironic way of call it.
Re:vectorization very rarely works (Score:2, Informative)
Re:Figured this had to happen (Score:3, Informative)
Wrong.
A fork is a branch from the primary codebase of ANY size.
No, a fork is where a second set of developers take the original codebase at one well-defined point and use it as the base for their own project.
OpenBSD and NetBSD are forks of the original BSD because they have taken the BSD code and turned it into their own divergent systems, both based on the same base but heading in different directions. A Linux kernel with one of the various non-Linus patchsets applied is not a fork, because the "non-standard" part is utterly dependent on the main kernel sources.
Apple's GCC builds fall into the latter category, and therefore do not constitute forks.
I repeat: Red Hat have not forked the Linux kernel, and therefore Apple have not forked GCC.
Re:Why? (Score:3, Informative)
It frustrates me because I don't think older open source projects should just mysteriously break. For example, I have an older sublaptop which I got pretty cheaply on Ebay. There is some someware I would like to try on this machine, such as the last pre-Gecko version of Mozilla (which had a not of Netscape 4 code in it), that I can't get to compile in Gcc 3.4 because too much has changed since then.
I don't like the fact the gcc breaks code the used to compile fine just two years ago. Another example: Abiword 1.x. Compiled just fine in 2002. Won't compile in 2005.
The big advantage of open source licenses is that anyone can pick up some old open-source code which has been abandoned a few years back and make something useful out of it. Or would be able to, except for the fact that the people who write GCC continue to insist on breaking older code.
I'm quite frustrated because I wasted hours trying to compile older code a few weeks ago and constantly hit a wall because of GCC's breakage.
I think a well-written "How to fix things that don't compile" guide would be nice; I can usually make an educated guess and compile the code again, but obscure things like old-style variable-number-of-arguments code stump me.
I think this is a general trend with some open source developers; they break code or configuration files without any regard for how much inconvenience they cause end users.
Re:TR1 included! (Score:3, Informative)
Re:perl fork bug (Score:3, Informative)
Re:Why? (Score:3, Informative)
While the standards compliance of pre-.net VC++ releases (and the C99 support of *any* VC++ releases) indicate that might well be the case, I'm inclined to think that it is not.
I think it is much more sensable to conclude from your post that you are a) confused about the GPL, b) intentionally misrepresenting the situation, c) not the sharpest knife in the drawer or d) some combination of the above.
Putting the gcc code under GPL doesn't put the language extensions under GPL.
Re:Any bechmarks (Score:2, Informative)
Re:Is anyone else curious what SSA trees are? (Score:1, Informative)
While this is what gcc does, most modern compilers don't because it's a bit slow. gcc only uses AST matching because (formerly) it tried to combine optimization and code generation. Once you're in SSA you don't need the codegen to optimize, so most modern SSA-based compilers generate simple correct but hideously inefficient code directly from the AST. All the real intelligence about the machine ISA is in the optimizer.
gcc is kind of mid-way to becoming modern, since it has a module that uses SSA but it's shoehorned into the old classical architecture.
SSA is simply a form used for the high-level AST.
This is incorrect. SSA is a form used for the low-level RTL, after the AST has been processed into pseudocode. It comprises nodes that correspond to RTL instructions. The AST, by comparison, represents the type of things that exist in the original language - declaration nodes, for example - which no longer exist in the RTL and have no SSA equivalents.
Re:debian (Score:2, Informative)
For the impatient...
Re:Moving fast (Score:3, Informative)
[Slack 5 was the name it held in the beta or "current", which was later released as 7.0]
Re:MINGW? (Score:3, Informative)
As for the speed of GCC, the compilation speed is often a bit disappointing compared to commertial compilers. Dead code elimination is an optimization which GCC already does for a very long time.
Marcel
Re:perl fork bug (Score:3, Informative)
It's not supposed to fork the file pointer.
Read data in from a 'while()' statement and store it into an array. When it reaches a certain size, fork the process, kill the array and start filling it up from STDIN. Next time you fork your data is partially duplicated in Solaris and not at all duplicated under Linux.
Re:No hope for named warnings (Score:2, Informative)
template <class T> class safeint {
template <class FromT> safeint (FromT const number) {
if (number < numeric_limits<T>::min()) {
throw "You stink!";
}
};
};
If FromT is an unsigned int, and T is an int, the check will never be true and should be optimized away. However, if it's the other way around, we need that check, or there can be overflow.
Also, I'd like to have the warning only disabled for that one line of code, so that if I make a mistake elsewhere the compiler will help me find it.
Visual C++ can do it, come on GNU!
Re:Moving fast (Score:2, Informative)