-
Notifications
You must be signed in to change notification settings - Fork 258
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Clang produces much larger binaries than GCC #21
Comments
Do you have evidence of performance not being better for these? This might just be down to inlining decisions. |
@DanAlbert, I haven't measured performance because I am currently just playing around with clang while doing other things. On SGS6 scanning performance of our OCR system is comparable to binary generated by GCC. I still haven't tested on slower phone and enabled timings to determine if there is noticeable performance improvement. So far I can only see larger binary size. I opened this issue because when creating a next release with Clang and r11, I need to somehow justify the larger binary to my clients. Are there any flags besides |
I see that your flags show -g for both clang and gcc. Can you try comparing the stripped sizes of your binaries? Do you actually ship (or intend to ship) binaries that still retain debuginfo? It is also peculiar to see some combinations of flags like both -fno-exceptions and -fexceptions in the same command line. You should probably only specify the one you need. -fno-exceptions might also help cut down on the overall size. |
@stephenhines, I've compared the sizes of stripped binaries (the ones produced inside I do have some conflicting flags, but this is due to build system - I have a macro which adds common flags for all files and then specific files "overwrite" those flags by appending new ones (compiler always uses the last one specified in such cases). Unfortunately, I need to compile with -fexceptions because a 3rd party library I am using requires it. I only noticed that when same compile flags are used with both Clang and GCC, Clang produces larger binary. I think this is an issue. |
Our PhotoMath native library has difference of over 1 MB between GCC and Clang version:
This is becoming a serious issue for us. |
From some analysis I did when we made this decision for the platform:
But yes, the group that did grow is most likely the vast majority of your users. Just wanted to provide the data that this isn't actually always the case. Having examples of cases where we do have the problem is very helpful though, so we'll point someone at your libraries when they look in to this. |
Thanks @DanAlbert, we are still building against GNU STL. We still haven't tried libc++ because lot of dependencies we need are still compiled against GNU STL. Is your data based on clang+gnustl vs gcc+gnustl or clang+libc++ vs gcc+gnustl or are you referring to pure C/C++ code (i.e. no STL)? |
The Android platform uses libc++ exclusively, so that was a Clang+libc++ vs GCC+libc++. We only have to keep one copy of libc++.so though, so that cuts down the size a but compared to the relative cost for an app. Note that it's a shared libc++, and it's actually a different source base than the one in the NDK. the one in the NDK needs a lot of work. Your libs would most likely be larger with libc++ right now because there's no clean way to get the demangler out if your app. Taking libc++ so it's more reliable and we're comfortable recommending it as the default is something we're going to be working on this year, but until we really dig in it's hard to make a schedule estimate. |
So for now (NDK r11) you recommend the GNU STL runtime as a default for most NDK users (regardless if one uses gcc or clang)? |
@DanAlbert, indeed. Clang+libc++ combination produced over 2 MB larger binary for our app than GCC+stdc++ combination (6.5 MB instead of 4.5 MB). The Clang+libc++ was only marginally faster (less than 5%). |
I can confirm this behavior, Qt libs compiled with clang are +10% larger using the same compiler flags. |
@fornwall, correct. |
btw we're trying to get some people to look in to code size issues. One thing that was found quickly was that GCC still defaults to FYI, this is also being discussed on #133. |
is this bug actually different from the |
Unfortunately for us, this is the only reason why we can't move to clang. We really really want to move to it for better C++ support but our final binaries end up being way too big. We also use Qt for our Qt api and if they are forced to clang along with us with this much larger size, then any app would most likely go over the 100mb limit. |
Probably should have duped these the other way around, but #133 has a lot more data on it so I'm closing this in favor of that one. |
Since now GCC is deprecated and Clang is new default, we would like to see Clang building binaries that are of similar size (when using same optimisation parameters).
Currently, binaries produced by Clang are up to 15% larger than binaries produced by GCC.
Here are sizes of our barcode library when compiled with GCC 4.9 and when compiled with default Clang in r11 (both use
gnustl_static
as c++ library):Can this be looked into in r11b or in r12?
Compile options used for Clang (armeabi-v7a target):
and GCC (armeabi-v7a target - some warning flags are different or missing because those are not supported under GCC):
Generally, you can see that both Clang and GCC use
-Os
optimisation flag.If achieving the same binary size as with GCC is not possible, we would like at least then better performance of binary produced by Clang. We need to somehow explain to our clients why our library will be 15% larger when we start using Clang.
The text was updated successfully, but these errors were encountered: