r/programming • • Apr 22 '14

GCC 4.9.0 Released

http://gcc.gnu.org/ml/gcc/2014-04/msg00195.html
607 Upvotes

140 comments sorted by

143

u/the-fritz Apr 22 '14 edited Apr 22 '14

Some pretty amazing changes: http://gcc.gnu.org/gcc-4.9/changes.html

Shameless promotion: For people interested in GCC related developments: /r/gcc (or @gnutools on Twitter)

Memory usage building Firefox with debug enabled was reduced from 15GB to 3.5GB; link time from 1700 seconds to 350 seconds.

That's a huge improvement!

45

u/katieberry Apr 22 '14 edited Apr 22 '14

(with LTO enabled in both cases.)

0

u/[deleted] Apr 22 '14

[deleted]

15

u/katieberry Apr 22 '14

(that would be nice. we gave up on trying to use it before.)

26

u/signfang Apr 22 '14

(why are we keep whispering)

65

u/shotgun_ninja Apr 22 '14

(because there's a Gnu loose in here)

33

u/BonzaiThePenguin Apr 22 '14

(phew, at least it's not Unix)

→ More replies (5)

46

u/srguapo Apr 22 '14

You were eaten by a Gnu.

5

u/ponton Apr 23 '14

(A Gnu once bit my sister ...)

7

u/Camarade_Tux Apr 22 '14

Wasn't that more than half a decade ago?

→ More replies (3)

7

u/cybercobra Apr 23 '14

(or @gnutools on Twitter)

I thought GNU used a libre alternative (Identica?) to Twitter because fundamentalism?

2

u/cozzyd Apr 23 '14

From what I understand, there is no strong objection to Twitter like there is to e.g. Facebook (due to privacy concerns). I believe they use the API to avoid running non-free javascript though.

-8

u/StrmSrfr Apr 23 '14

15GB of memory to build a web browser....

38

u/DeltaBurnt Apr 23 '14

Web browsers are probably the most complicated applications that people use on a daily basis.

2

u/[deleted] Apr 23 '14

Besides, well, OSes. Depends on your definition of application I guess.

13

u/[deleted] Apr 23 '14

In debug. It's important.

5

u/mavere Apr 23 '14

Not anymore!

1

u/skulgnome Apr 23 '14

16 gigs for a laptop costs about $120 these days. Not exactly a huge expense compared to the developer time spent waiting for a linker to finish.

1

u/StrmSrfr Apr 23 '14

I'm not sure why you would be comparing those things.

1

u/rowboat__cop Apr 23 '14

16 gigs for a laptop costs about $120 these days.

Depends on what hardware you own.

-4

u/[deleted] Apr 23 '14

Can GCC compile itself? Or do you need another compiler to compile it? How do you prevent a trojan in the other compiler putting code into the GCC compiler as it's being compiled so that anything compiled with GCC also contains a trojan?

7

u/the-fritz Apr 23 '14

What do you mean by "compile itself"? Of course GCC can compile another GCC. If you mean whether you can build it on a system without any other compiler then no. You need a C compiler (like GCC itself) to start. This process is called "bootstrapping" if you want to know more.

The compiler trojan thing is of course an interesting thought experiment (Ken Thompson introduced it 30 years ago). This of course could happen but could be discovered by comparing binaries on different systems. You could also start bootstrapping with a small C compiler (e.g., TCC or PCC) which you could manually verify.

→ More replies (4)

3

u/[deleted] Apr 23 '14 edited Apr 23 '14

You mean as in Reflections on Trusting Trust, I guess. Ultimately, there's no perfect solution to that - even if you use a different compiler (which is certainly possible for GCC), that compiler may have been compromised so that it dumps a trojan in GCC when it compiles it anyway. A guaranteed clean build of a compiler isn't trivial, though in practice it's not really an issue (for most of us, assuming you take basic precautions). There's easier and more reliable ways to compromise a system than targeting a compiler.

As for how GCC builds, IIRC it can be built using any C compiler to start with, but (probably depending on what the configure script finds) it can also builds a simple version of itself then uses that to build the full final compiler. That's probably so that some GCC-specific features can be used for the compiler.

I should strongly emphasize that I'm just half-remembering something from something I read online a long time ago. It could be mis-remembered, or something that happened in the past but not now.

Anyway, the main defense from reflections-on-trusting-trust trojans is that you can do hash-checks on the binaries you build and compare them with known-good versions. Except, of course, that maybe your hash utility is compromised too.

I'm pretty sure I read about a proof somewhere that said it's impossible to have either perfect security or a perfect exploit - whatever your move on either side, there's always a counter-move.

1

u/[deleted] Apr 28 '14

This a solved problem - in theory. The solution is using proof carrying code. Of course, the PCC verifier itself still has to be verified manually, but then you get the benefit of automatic verification for all other software.

→ More replies (3)

2

u/ratatask Apr 23 '14

You need a C compiler to compile gcc. That C compiler can be gcc.

Using that existing C compiler, the gcc build creates a minimal C compiler, which it uses to compile itself.[1]

There's no active prevention of a trojan compiler. You'd have to build gcc using several compilers and compare the result.

[1] It might work a bit differently these days, as they now allow gcc to be coded in C++ too. Also that minimal (bootstrap) compiler stage can be skipped.

-57

u/RiotingPacifist Apr 22 '14

Who cares about compile time, that's for developer chumps, as a user chump how much faster will my Firefox run?

36

u/[deleted] Apr 22 '14

Less bugs, since it makes running the debugger easier?

8

u/[deleted] Apr 22 '14

You run the debugger with link time optimizations enabled? You know that requires stripping the debugging symbols out, right?

12

u/[deleted] Apr 22 '14

I was going by this quoted improvement higher up in this thread, which is related to building with debug enabled and thus would seem to benefit developers and thus users indirectly:

Memory usage building Firefox with debug enabled was reduced from 15GB to 3.5GB; link time from 1700 seconds to 350 seconds.

→ More replies (2)

11

u/404fucksnotavailable Apr 22 '14

Why the hell are you in /r/programming if you don't care about programming?

49

u/pwningod Apr 22 '14

At last the warnings and errors will be colored! Compiling right now!

0

u/[deleted] Apr 23 '14

[deleted]

3

u/rowboat__cop Apr 23 '14

Next up: The GCC static analysis toolkit.

36

u/Maristic Apr 22 '14

See also this thread from nine days ago when /u/grepsedawk jumped the gun and claimed it'd been released.

Also, based on these previous links, it seems like one of the features people are most excited about is GCC's catching up with clang in having colorized diagnostics.

36

u/the-fritz Apr 22 '14

I personally think the LTO improvements, OpenMP 4.0 support, almost all of C11 and C++14, and C++11 <regex> are more exciting. Colourizing the diagnostics is something most editors and IDEs are doing already anyway. (I wonder how many of those will actually run into trouble with this new feature.)

21

u/AnAirMagic Apr 22 '14

Most shell commands can detect whether they are running in a terminal by themselves or as a pipeline and can color output accordingly. I suspect gcc is no different.

9

u/mer_mer Apr 22 '14

I asked this in the previous thread, but OpenMP 4.0 is supposed to have accelerator (gpu) support. Do you know if this is the case in gcc 4.9.0?

-9

u/el_muchacho Apr 22 '14 edited Apr 23 '14

I think the gcc team should concentrate on creating an industrial strength static code analyzer rather than the Nth iteration of C++. Security issues like the OpenSSL issue are marring open source as well as commercial projects because of a lack of such a tool.

6

u/WELFARE_NIGGER_ Apr 22 '14 edited Apr 23 '14

They should try and go the Roslyn/Clang way turning the various parts of the compiler modular and allowing them to be used as libraries, e.g. the parser, syntax tree creator, semantic models etc. They should also add support for a framework for writing custom analyzer/refactor modules which can be dynamically loaded by projects, like Roslyn has now but without recompiling the actual compiler.

GCC already has a plugin interface but it isn't tuned for code refacoring and analysis.

1

u/notlostyet Apr 24 '14 edited Apr 24 '14

So 2 significant iterations of C++ in 14 years is too much for you?

And no, OpenSSL sucks because it's written in unmaintainable C and it's massively under resourced. There are bunches of security engineers out there with expensive, world-class static analyzers at their disposal that didn't catch Heartbleed, despite it being a trivial example of an ancient bug class in public code for some 2 years. It took Google to audit the code with human eyeballs.

If anything we need C++ to modernise as quickly as possible, treat its major warts, and get people away from working in the gutter in C.

→ More replies (1)

25

u/[deleted] Apr 22 '14

[removed] — view removed comment

3

u/matthieum Apr 23 '14

And I believe gcc also supports ASan and TSan from previous releases, which also help a lot. There was an article from Chromium yesterday stating that TSan had caught a couple hundreds bugs for them already.

→ More replies (2)

45

u/minno Apr 22 '14

And now, I wait for the MinGW team to catch up.

20

u/Camarade_Tux Apr 22 '14

mingw.org or mingw-w64?

In any case, keep in mind that validating a compiler takes some time.

edit: and .0 releases are not always perfect. :)

10

u/minno Apr 22 '14

I'm using the original mingw right now, but I've been considering switching to /u/STL's pre-packaged distribution.

15

u/Camarade_Tux Apr 22 '14

Mingw-w64 is much much closer to upstream. Actually it is part of upstream and usually much more up-to-date. The fact that it takes some time to build and validate still applies though (even more so for Windows).

12

u/Suitecake Apr 22 '14

Hijacking to ask, since you seem like someone who knows:

I (a mere plebe) always feel weird using MinGW and especially MinGW-w64, as it feels dirty and impure. I don't have any real confidence that what I'm using on Windows is anything like what I'm using on Linux. Is that suspicion misplaced? Should I fearlessly use MinGW-w64?

21

u/Camarade_Tux Apr 22 '14

Mingw.org and Mingw-w64 are GCC on Windows with a set of headers to use the Win32 API (and soonish WinRT).

The headers are built either from public documentation or, in the case of mingw-w64, reverse engineering too; the headers in Visual Studio are not free and cannot be used in this context.

The libraries used at runtime are Microsoft's and the ones you might have built in addition to these.

Mingw* projects don't provide additional libraries except when needed for language conformance (C11/C++11 threads, C99 printf functions which fully conform, ...).

So you get GCC and its language support but the libraries are purely from Windows and have nothing to do with (e)glibc/musl/uclibc/... (*) Then, of course, you can have other libraries on top of the system ones provided they're able to handle Windows or use a layer that can handle it.

(*) some code derives from some of the BSD libcs.

6

u/[deleted] Apr 22 '14

Should I fearlessly use MinGW-w64?

I sort of use it on smaller stuff but it's not nearly as smooth as using GCC on Linux. It really is impure and dirty and third party libraries never seem to just work unless you're willing to hack through them, which introduces more uncertainty which is why I simply don't dare use it for any production stuff, only for hacking around with C++ functionality on Windows. I can't even recall getting boost to work with MingW, and boost is a pretty freaking core C++ library.

Ugh... if Microsoft just had a standard compliant C compiler and shipped a version of the Win32 API that respected those standards the situation would be much much better.

5

u/Rapptz Apr 22 '14

Are you doing something wrong? I've been using MinGW for years and I haven't had an issue. And considering /u/STL has a distribution for MinGW with many libraries, I'm convinced that MinGW isn't the problem here.

→ More replies (1)
→ More replies (1)

3

u/CSSFerret Apr 22 '14

You could always use Cygwin. That's as close as you can get to Linux AFAIK.

2

u/fabzter Apr 22 '14

Which is that?

10

u/minno Apr 22 '14

This. It comes with mingw-w64 and a ton of libraries and unix command line utilities. I have Cygwin for all my command line needs, but I guess it's nice to not have to install Boost myself.

3

u/shillbert Apr 22 '14

I've used that for a long time. Never realized it was made by someone with the initials STL; pretty neat coincidence.

8

u/Sqeaky Apr 22 '14

Who is also the lead developer of microsoft's version of the STL they ship with visual studio.

→ More replies (1)
→ More replies (2)

8

u/Tringi Apr 22 '14

You are not alone :)

3

u/timwoj Apr 22 '14

And now I wait for the Redhat/Scientific Linux devtoolset teams to catch up.

8

u/seruus Apr 22 '14

2016 is close, don't sweat it.

4

u/timwoj Apr 22 '14

Well, they do have one based on gcc 4.8.2 out already, so I can hold a little hope.

-2

u/hrefchef Apr 22 '14

Still faster than waiting for it in Debian.

11

u/karavelov Apr 23 '14

gcc-4.9 is already in debian sid

8

u/stillalone Apr 22 '14

Does anyone know if LTO works with statically linked libraries?

10

u/morth Apr 22 '14

Don't see why it wouldn't. LTO is basically just compiling halfway when creating the .o and then fully for the final binary.

1

u/skulgnome Apr 23 '14

And it works when some of the objects being linked don't contain the LTO intermediate representation, such as ones generated from assembly or with LLVM.

1

u/ratatask Apr 23 '14

It does. The objects in the static library must be compiled with the -flto flag, and so must the code of the app, and you pass the -flto flag when them.

7

u/jagt Apr 22 '14

Anyone using the Go front end in gcc? It's the first time I heard of it.

15

u/pdq Apr 22 '14

I've used gccgo in the past. It's pretty good, albeit it's lagged the Go mainline for a while, but now that it supports 1.2.1, it should be good to try out again.

gccgo can generate really small binaries (in the kilobyte range for a hello world app), because it links to libc, whereas the standard Go compiler makes static binaries, and a hello world app is multiple MBs.

One thing I am curious of is whether you can use gdb with gccgo. That would be a big win.

0

u/[deleted] Apr 22 '14

[deleted]

7

u/pdq Apr 22 '14

To my knowledge, only static.

You can link to additional dynamic libraries, like libpng, but the rest is static.

10

u/AdminsAbuseShadowBan Apr 22 '14

The benefit is of course that it is possible to distribute binaries without going insane.

36

u/parla Apr 22 '14

The insanity comes later, when you need to figure out which go programs you need to recompile to get rid of the next heartbleed bug.

0

u/AdminsAbuseShadowBan Apr 22 '14

I've never really thought about it but I think that's actually a terrible argument. Apps come in two ways:

  1. Binary distributions (e.g. all Windows/Mac apps, commercial Linux apps, etc.)

  2. From a package manager.

The binary apps will always come with their own copies of libraries - they can't rely on OpenSSL being included on the host system so they use their own copy. Therefore these will need to be updated even if they are dynamically linked because they will be dynamically linked with a private copy of the vulnerable library.

The distro apps will can easily be updated with the vulnerable library is updated. It might use more data, but that is plentiful these days.

10

u/parla Apr 22 '14

The distro maintainers will need to figure what to rebuild though. And for the record, OpenSSL is distributed with OS X, so no Mac apps would need to link it statically.

→ More replies (1)

1

u/tavianator Apr 22 '14

3 . Compiled yourself from source.

Edit: why does reddit change "3." to "1."? :P

3

u/[deleted] Apr 22 '14

Markdown list syntax. Escape the dot with a backslash if you don't want to start a list (which starts at 1, no matter what number you use).

→ More replies (2)
→ More replies (2)

1

u/MacASM Apr 23 '14

Distribuite a file size in KBs instead of MBs sometimes does matter too.

→ More replies (22)

8

u/edbluetooth Apr 22 '14

Serious question, if the linux os I am using right now was replaced by the same OS but compiled with this GCC, how much difference in speed (due to the improved optimiser) would I notice?

30

u/asimian Apr 22 '14

The OS kernel itself is almost never a real bottleneck, so I doubt you'd feel any difference at all.

9

u/atakomu Apr 22 '14

The biggest difference when recompiling the kernel comes from compiling only the things you need. In Gentoo my custom compiled kernel had around 2 MB. In Arch stock kernel has 15 MB including initframs image (which wasn't needed in Gentoo).

Boot is maybe a little faster. Problem comes when new gcc or glibc comes and you have to recompile whole system. THis made me switch from Gentoo to Arch I still have the bleeding edge but I don't need to compile stuff every week.

4

u/bit_slayer Apr 22 '14

The biggest difference when recompiling the kernel comes from compiling only the things you need. In Gentoo my custom compiled kernel had around 2 MB. In Arch stock kernel has 15 MB including initframs image (which wasn't needed in Gentoo).

I switched from using Gentoo to Arch for various reasons and was surprised when my boot time actually shrank from minutes to seconds.

5

u/[deleted] Apr 23 '14

Is that from systemd?

1

u/bit_slayer Apr 23 '14

Not sure; perhaps that's all it was.

3

u/atakomu Apr 23 '14

It depends when did you switch. Systemd did noticeably shrank boot time.

8

u/[deleted] Apr 22 '14

Used Arch for a time, switched back to Fedora for a bit more stability. What made me switch was when systemd was rolled out it basically hosed my system (among other issues). Bleeding edge cuts both ways, and I'd rather spend time using my computer than trying to figure out what broke this time. Overall, the updates usually worked ok without too many problems, and are understandable considering the newness of the code, which is more than I can say for Ubuntu releases.

4

u/yentity Apr 22 '14

What made me switch was when systemd was rolled out it basically hosed my system (among other issues)

You switched from a distro moving to systemd to a distro that was already using systemd. Feodra looked safer to you because you went to it after the transition was done.

Fedora is equally bleeding edge as ArchLinux. The only benefits you get out of Fedora is more stuff installed out of the box. Don't for a moment think you are safer on Fedora compared to ArchLinux.

11

u/klusark Apr 22 '14

Only Fedora rawhide is rolling. If you use a numbered Fedora release it's more stable.

4

u/[deleted] Apr 22 '14

Apologies if I was misleading and suggested it was 100% fail proof. For me the the major upgrades on Fedora have worked much smoother than either Arch or Ubuntu.

2

u/KARMA_P0LICE Apr 23 '14

No, you're right. I'm a big supporter of Arch, but the systemd update was nontrivial and I can understand why it would frustrate you into switching. At some point, mucking around with configs and spending an hour to upgrade your system can just get tedious.

1

u/rowboat__cop Apr 23 '14 edited Apr 24 '14

In Arch stock kernel has 15 MB including initframs image (which wasn't needed in Gentoo).

Incorrect. You’re talking about the fallback initramfs which comes with every module you can think of in order to ensure maximum compatibility. The stock kernel is actually 3.7 MB (x86_64) plus a 4 MB initramfs. Besides, I like the fact that you can put any binary you like into the initramfs. Regarding the fallback image, the convenience of a custom compiled Vim is worth the extra 10 MB space it takes in /boot. Being dropped into rootfs is much less intimidating if you’re armed with a full-fledged $EDITOR.

7

u/[deleted] Apr 22 '14

You can answer this question for yourself if you have a free weekend.

Asimian's answer is almost certainly accurate, though :)

5

u/MacASM Apr 22 '14

How long between gcc releases? I have impression it's each time fastest...

15

u/KrzaQ2 Apr 22 '14

They happened around march-april for several years now

11

u/sirin3 Apr 22 '14

Perhaps you are getting older. Changes your time perceptions

9

u/mbetter Apr 23 '14

I had this problem before. Now it's the painting of Richard Stallman in my attic that gets older, not me.

6

u/MacASM Apr 23 '14

Oh, thanks.

2

u/Ono-Sendai Apr 23 '14

It is now possible to call x86 intrinsics from select functions in a file that are tagged with the corresponding target attribute without having to compile the entire file with the -mxxx option. This improves the usability of x86 intrinsics and is particularly useful when doing Function Multiversioning.

finally!

-12

u/[deleted] Apr 23 '14

One word: Clang

0

u/[deleted] Apr 22 '14

[deleted]

9

u/obsa Apr 22 '14

If you're seeing the page rendered in Comic Sans, it's your own local configuration.