-
Notifications
You must be signed in to change notification settings - Fork 298
clang produces larger binaries than gcc for arm7 #133
Description
We've been working on compiling Firefox for Android with clang lately and today I finally got everything to build with NDK r12 and clang today. All the necessary patches aren't committed yet, so replicating this would be a bit tricky at the moment, but the end result is that our main library, libxul.so, compiled with clang is about 10% bigger than when we use gcc (text size, as measured by size(1)). Our mobile team is quite concerned about our APK size already, and telling them that a mandated compiler switch would tack on another 3MB+ of size...well, let's just say they wouldn't be happy. 😉
This result was pretty surprising, as we were expecting similar performance and even hoping for a codesize win. I have verified that the build flags were identical in both builds (same -O options, -fno-exceptions turned on, -ffunction-sections + -Wl,--gc-sections turned on, both builds using libc++, etc.). It is entirely possible that I've missed some key clang option, though I can verify that using -funique-section-names doesn't change the result.
Judging from a quick skim of diff'd nm output, the clang build has many more symbols, especially template methods. I can't tell whether this is an effect of inlining heuristics, or of clang somehow keeping those symbols around when they're not actually used.
I apologize for not being able to provide replication instructions; I'll try to get all the necessary patches committed soon. We had a workweek last week, and that's been a bit disruptive for getting code reviewed and committed.
Is this sort of difference something that you've seen in your own testing as well, or does this sound like an outlier?