This project has been on hold since 2016
All the data on this site is still available (and will stay available) but not up-to-date anymore
You might like to check Dmitry Moskalchuk's portfolio for his other projects
GCC 6 - now for Android
02/26/2016 12:24 PM

As you may know, GCC 6 is coming. There are many new features, including experimental support of the new C++17 features (Concepts, std::invoke, std::shared_mutex, etc) and many new warnings, helping developers to write safe and reliable code. In fact, GCC 6, with all enabled warnings, makes some static code analyzers just irrelevant anymore.

It is meaningless to describe all GCC 6 features here, so I won't. Those who are interested in that can read about them on other sites, spreading information about the upcoming GCC 6 release (for example, here or here). However, I'd like to tell you about GCC 6 for Android development and, in particular, about the future of the GCC in CrystaX NDK.

As you may know, Google's latest Android NDK (r10e at this moment) includes both GCC- and Clang-based toolchains. However, both GCC and Clang are a bit outdated now: GCC is at version 4.9 and Clang is at version 3.6. There was significant activity in Google's NDK open repository during the last half of 2015, and it looks like Google is preparing to change NDK significantly. In particular, there would not be GCC anymore, and the only supported toolchain for Android development will remain one based on Clang. It's clearly expressed in the CHANGELOG.md:

  • GCC in the NDK is now deprecated.
    • Time to start using Clang if you haven’t already. If you have problems with Clang, please file bugs!
    • The NDK will not be upgrading to 5.x, nor will we be accepting non-critical backports.
    • Maintenance for miscompiles and internal compiler errors in 4.9 will be handled on a case by case basis.

Well, Google can do what it wants to do, in particular, drop GCC support. However, we don't think it's the right thing to do, especially taking into account how GCC has progressed with time - so we definitely are not intending to drop GCC support in the CrystaX NDK. In fact, there are still many areas where GCC has something to say, compared to Clang, even though LLVM/Clang is a very good project and already provides really good quality. Life teaches us that it's always better for users to have competing products rather than to rely on just one. It's exactly the case for the GCC/Clang competition - both become better with time, and we only win from that.

Keeping that in mind, we already included the latest GCC 5.3 into the latest CrystaX NDK 10.3.1 release, allowing our users to use all the latest GCC features when developing for Android; now, it seems to be the time for including GCC 6, even though it's not yet released. GCC 6 is in regression and documentation fixes stage, so we've tried to integrate it to the CrystaX NDK, and now, after passing all of our automated tests, we're happy to say that GCC 6 is almost fully working for Android development too!

The only two regressions we see are #1292 and #1293. Here are some explanations of them:

ICE when building test-gabi++ ( #1292 )

This is clearly a regression in GCC 6, compared to GCC 5. As far as we see, the regression has nothing to Android, so we expect it to be fixed in the upstream GCC. A similar bug, #68730, is already filed, but it's closed now, so it's unclear if our bug, #1292, has something to the GCC's #68730 or if it's just a correlation. Anyway, we're working on this and soon we will file proper ticket to the GCC's bug tracker so we'll have the good chances to get it fixed by the GCC 6 release time.

GOT_PREL optimization doesn't work in gcc-6 ( #1293 )

This is our regression, compared to GCC 5. Generally speaking, GCC generates inefficient code for accessing global variables in position-independent code. This bug is filed to the GCC bug tracker but still remains open for the long term. In 2011, Guozhi Wei provided a fix for it on Google's GCC fork, so it was fixed in the Google's GCC. We're maintaining our GCC fork in the CrystaX NDK, trying to keep it as close as possible to the FSF's, but with some important additions from Google's GCC. This patch had such important additions that we've ported it to the GCC 5.3 released in CrystaX NDK 10.3.1. However, this time it was much more difficult to apply it on top of the GCC 6 because of significant changes in GCC's optimizer code. Being applied as is (with resolving of the obvious conflicts), it just doesn't compiles anymore because of changes in internal GCC structures and optimization passes.

Long story short: This is definitely the regression, so we'll work on fixing it and expect it to be fixed soon. However, even though it's not yet fixed, it will not affect your applications too much, unless you're using global variables a lot (which is bad practice anyway).

Conclusions

So, taking the above into account, it makes sense to start using GCC 6 right now, not waiting for the full release. We're sure using GCC 6 for your projects will improve the quality of the code because of the above-mentioned smart algorithms of the code analysis added to the GCC 6. And don't forget about C++17 - it is going to be a very promising standard for the C++ world, with many important features, making C++ development even more powerful than it is now. So it makes sense to start using its abilities right now and not wait when it would be too late.

We're going to release new CrystaX NDK version soon, and GCC 6 will be included there. In the meantime, you can use our daily builds from https://dl.crystax.net/builds/. Please note that build #810 or higher is needed for getting GCC 6 supported. Feel free to contact us in case of any problem; we'd be happy to help!

Back
Home
Map
Back
Home
Map

Our contributors: