{"action":"created","issue":{"url":"https://api.github.com/repos/android-ndk/ndk/issues/21","repository_url":"https://api.github.com/repos/android-ndk/ndk","labels_url":"https://api.github.com/repos/android-ndk/ndk/issues/21/labels{/name}","comments_url":"https://api.github.com/repos/android-ndk/ndk/issues/21/comments","events_url":"https://api.github.com/repos/android-ndk/ndk/issues/21/events","html_url":"https://github.com/android-ndk/ndk/issues/21","id":140979097,"number":21,"title":"Clang produces much larger binaries than GCC","user":{"login":"DoDoENT","id":158844,"avatar_url":"https://avatars.githubusercontent.com/u/158844?v=3","gravatar_id":"","url":"https://api.github.com/users/DoDoENT","html_url":"https://github.com/DoDoENT","followers_url":"https://api.github.com/users/DoDoENT/followers","following_url":"https://api.github.com/users/DoDoENT/following{/other_user}","gists_url":"https://api.github.com/users/DoDoENT/gists{/gist_id}","starred_url":"https://api.github.com/users/DoDoENT/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/DoDoENT/subscriptions","organizations_url":"https://api.github.com/users/DoDoENT/orgs","repos_url":"https://api.github.com/users/DoDoENT/repos","events_url":"https://api.github.com/users/DoDoENT/events{/privacy}","received_events_url":"https://api.github.com/users/DoDoENT/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":{"login":"stephenhines","id":17790020,"avatar_url":"https://avatars.githubusercontent.com/u/17790020?v=3","gravatar_id":"","url":"https://api.github.com/users/stephenhines","html_url":"https://github.com/stephenhines","followers_url":"https://api.github.com/users/stephenhines/followers","following_url":"https://api.github.com/users/stephenhines/following{/other_user}","gists_url":"https://api.github.com/users/stephenhines/gists{/gist_id}","starred_url":"https://api.github.com/users/stephenhines/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/stephenhines/subscriptions","organizations_url":"https://api.github.com/users/stephenhines/orgs","repos_url":"https://api.github.com/users/stephenhines/repos","events_url":"https://api.github.com/users/stephenhines/events{/privacy}","received_events_url":"https://api.github.com/users/stephenhines/received_events","type":"User","site_admin":false},"milestone":null,"comments":3,"created_at":"2016-03-15T13:54:25Z","updated_at":"2016-03-16T09:04:08Z","closed_at":null,"body":"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).\r\n\r\nCurrently, binaries produced by Clang are up to 15% larger than binaries produced by GCC.\r\n\r\nHere are sizes of our [barcode library](https://github.com/PDF417/pdf417-android) when compiled with GCC 4.9 and when compiled with default Clang in r11 (both use `gnustl_static` as c++ library):\r\n\r\n```\r\n$ ls -lh libs_clang/*\r\nlibs_clang/arm64-v8a:\r\ntotal 6616\r\n-rwxr-xr-x  1 dodo  staff   3.2M Mar 15 14:12 libBlinkBarcode.so\r\n\r\nlibs_clang/armeabi-v7a:\r\ntotal 4904\r\n-rwxr-xr-x  1 dodo  staff   2.4M Mar 15 14:12 libBlinkBarcode.so\r\n[dodo@mujcek: androidJni (feature/ndk-r11)]$ ls -lh libs_gcc/*\r\nlibs_gcc/arm64-v8a:\r\ntotal 6096\r\n-rwxr-xr-x  1 dodo  staff   3.0M Mar 15 14:07 libBlinkBarcode.so\r\n\r\nlibs_gcc/armeabi-v7a:\r\ntotal 4304\r\n-rwxr-xr-x  1 dodo  staff   2.1M Mar 15 14:07 libBlinkBarcode.so\r\n```\r\n\r\nCan this be looked into in r11b or in r12?\r\n\r\nCompile options used for Clang (armeabi-v7a target):\r\n```\r\n -fpic -ffunction-sections -funwind-tables -fstack-protector-strong -Wno-invalid-command-line-argument -Wno-unused-command-line-argument -no-canonical-prefixes -fno-integrated-as -target armv7-none-linux-androideabi -march=armv7-a -mfloat-abi=softfp -mfpu=vfpv3-d16 -fno-exceptions -fno-rtti -mthumb -Os -g -DNDEBUG -fomit-frame-pointer -fno-strict-aliasing -mfpu=neon -Wno-parentheses-equality -Wno-invalid-command-line-argument -Wno-unused-command-line-argument -Qunused-arguments -Wno-unknown-warning-option -Wno-psabi -Wno-unknown-pragmas -Werror -Wno-error=deprecated-declarations -Wno-error=cpp -Wall -Os -Wconversion -Wno-sign-conversion -Wno-write-strings -Wno-pragmas -Wvla -Wformat-security -Wextra -Wno-unused-parameter -Wno-ignored-qualifiers -Wno-type-limits -fvisibility=hidden -ffunction-sections -fstack-protector-all -Wa,--noexecstack -Wformat -Werror=format-security  -std=c++11 -Wno-overloaded-virtual -fvisibility-inlines-hidden  -fexceptions\r\n```\r\n\r\nand GCC (armeabi-v7a target - some warning flags are different or missing because those are not supported under GCC):\r\n```\r\n-fpic -ffunction-sections -funwind-tables -fstack-protector-strong -no-canonical-prefixes -march=armv7-a -mfpu=vfpv3-d16 -mfloat-abi=softfp -fno-exceptions -fno-rtti -mthumb -Os -g -DNDEBUG -fomit-frame-pointer -fno-strict-aliasing -finline-limit=64 -mfpu=neon -Wno-psabi -Wno-unknown-pragmas -Werror -Wno-error=deprecated-declarations -Wno-error=cpp -Wall -Os -Wconversion -Wno-sign-conversion -Wno-write-strings -Wno-pragmas -Wvla -Wformat-security -Wextra -Wno-unused-parameter -Wno-ignored-qualifiers -Wno-type-limits -fvisibility=hidden -ffunction-sections -fstack-protector-all -Wa,--noexecstack -Wformat -Werror=format-security  -std=c++11 -Wno-overloaded-virtual -fvisibility-inlines-hidden  -fexceptions\r\n```\r\n\r\nGenerally, you can see that both Clang and GCC use `-Os` optimisation flag.\r\n\r\nIf 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."},"comment":{"url":"https://api.github.com/repos/android-ndk/ndk/issues/comments/197218424","html_url":"https://github.com/android-ndk/ndk/issues/21#issuecomment-197218424","issue_url":"https://api.github.com/repos/android-ndk/ndk/issues/21","id":197218424,"user":{"login":"stephenhines","id":17790020,"avatar_url":"https://avatars.githubusercontent.com/u/17790020?v=3","gravatar_id":"","url":"https://api.github.com/users/stephenhines","html_url":"https://github.com/stephenhines","followers_url":"https://api.github.com/users/stephenhines/followers","following_url":"https://api.github.com/users/stephenhines/following{/other_user}","gists_url":"https://api.github.com/users/stephenhines/gists{/gist_id}","starred_url":"https://api.github.com/users/stephenhines/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/stephenhines/subscriptions","organizations_url":"https://api.github.com/users/stephenhines/orgs","repos_url":"https://api.github.com/users/stephenhines/repos","events_url":"https://api.github.com/users/stephenhines/events{/privacy}","received_events_url":"https://api.github.com/users/stephenhines/received_events","type":"User","site_admin":false},"created_at":"2016-03-16T09:04:08Z","updated_at":"2016-03-16T09:04:08Z","body":"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."}}