Qtアプリのバイナリサイズを削減する(4)

Qtアプリのバイナリサイズを削減する(3) ではリンク時の最適化を有効にした結果で10%程度サンプルアプリのバイナリサイズを削減することができました。

configure のオプションを設定するだけで、半分以下のサイズになって素晴らしいですね。

Qt ではさらにバイナリサイズを削減することが可能ですが、ここから先は、試行錯誤のコンパイル沼です。Qt 自体の知識もかなり要求されますので、あまりオススメはしません。

Qt Lite

Qt Lite は、Qt 5.8 で導入された「新しい configure の仕組み」の一部です。

概要は、Qt Blog の Qt 5.8 をリリースしました をご覧ください。

詳細が知りたい方は、QtCon 2016 の Lars の New configuration system in Qt 5.8 の動画がおそらく唯一の資料になります。

New configuration system in Qt 5.8

この Qt の configure のリファクタリングで、以前は qconfig と呼ばれて誰もメンテを指定なかった(ので私が密かにチマチマ直していた)Qt から一部の機能を取り除く仕組みが、今後はちゃんとメンテされるということになりました。(多分)

Qt の機能の一覧

$ mkdir -p ~/io/qt/code/qt/dev/lite
$ cd $_
$ ../qt5/configure --list-features
abstractbutton .......... Widgets: Abstract base class of button widgets, providing functionality common to buttons.
abstractslider .......... Widgets: Common super class for widgets like QScrollBar, QSlider and QDial.
accessibility ........... Utilities: Provides accessibility support.
action .................. Kernel: Provides widget actions.
animation ............... Utilities: Provides a framework for animations.
appstore-compliant ...... Disables code that is not allowed in platform app stores
bearermanagement ........ Networking: Provides bearer management for the network stack.
big_codecs .............. Internationalization: Supports big codecs, e.g. CJK.
buttongroup ............. Widgets: Supports organizing groups of button widgets.
calendarwidget .......... Widgets: Provides a monthly based calendar widget allowing the user to select a date.
checkbox ................ Widgets: Provides a checkbox with a text label.
clipboard ............... Kernel: Provides cut and paste operations.
codecs .................. Internationalization: Supports non-unicode text conversions.
colordialog ............. Dialogs: Provides a dialog widget for specifying colors.
colornames .............. Painting: Supports color names such as "red", used by QColor and by some HTML documents.
columnview .............. ItemViews: Provides a model/view implementation of a column view.
combobox ................ Widgets: Provides drop-down boxes presenting a list of options to the user.
commandlineparser ....... Utilities: Provides support for command line parsing.
commandlinkbutton ....... Widgets: Provides a Vista style command link button.
completer ............... Utilities: Provides completions based on an item model.
concatenatetablesproxymodel . ItemViews: Supports concatenating source models.
concurrent .............. Kernel: Provides a high-level multi-threading API.
contextmenu ............. Widgets: Adds pop-up menus on right mouse click to numerous widgets.
cssparser ............... Kernel: Provides a parser for Cascading Style Sheets.
cups .................... Painting: Provides support for the Common Unix Printing System.
cursor .................. Kernel: Provides mouse cursors.
d3d12 ................... Qt Quick: Provides a Direct3D 12 backend for the scenegraph.
datawidgetmapper ........ ItemViews: Provides mapping between a section of a data model to widgets.
datestring .............. Data structures: Provides convertion between dates and strings.
datetimeedit ............ Widgets: Supports editing dates and times.
datetimeparser .......... Utilities: Provides support for parsing date-time texts.
desktopservices ......... Utilities: Provides methods for accessing common desktop services.
dial .................... Widgets: Provides a rounded range control, e.g., like a speedometer.
dialog .................. Dialogs: Base class of dialog windows.
dialogbuttonbox ......... Dialogs: Presents buttons in a layout that is appropriate for the current widget style.
dirmodel ................ ItemViews: Provides a data model for the local filesystem.
dnslookup ............... Networking: Provides API for DNS lookups.
dockwidget .............. Widgets: Supports docking widgets inside a QMainWindow or floated as a top-level window on the desktop.
dom ..................... File I/O: Supports the Document Object Model.
draganddrop ............. Kernel: Supports the drag and drop mechansim.
dtls .................... Networking: Provides a DTLS implementation
effects ................. Kernel: Provides special widget effects (e.g. fading and scrolling).
errormessage ............ Dialogs: Provides an error message display dialog.
filedialog .............. Dialogs: Provides a dialog widget for selecting files or directories.
filesystemiterator ...... File I/O: Provides fast file system iteration.
filesystemmodel ......... File I/O: Provides a data model for the local filesystem.
filesystemwatcher ....... File I/O: Provides an interface for monitoring files and directories for modifications.
fontcombobox ............ Widgets: Provides a combobox that lets the user select a font family.
fontdialog .............. Dialogs: Provides a dialog widget for selecting fonts.
formlayout .............. Widgets: Manages forms of input widgets and their associated labels.
freetype ................ Fonts: Supports the FreeType 2 font engine (and its supported font formats).
fscompleter ............. Utilities: Provides file name completion in QFileDialog.
ftp ..................... Networking: Provides support for the File Transfer Protocol in QNetworkAccessManager.
future .................. Kernel: Provides QFuture and related classes.
gestures ................ Utilities: Provides a framework for gestures.
graphicseffect .......... Widgets: Provides various graphics effects.
graphicsview ............ Widgets: Provides a canvas/sprite framework.
groupbox ................ Widgets: Provides widget grouping boxes with frames.
gssapi .................. Networking: Enable SPNEGO authentication through GSSAPI
highdpiscaling .......... Kernel: Provides automatic scaling of DPI-unaware applications on high-DPI displays.
http .................... Networking: Provides support for the Hypertext Transfer Protocol in QNetworkAccessManager.
iconv ................... Internationalization: Provides internationalization on Unix.
identityproxymodel ...... ItemViews: Supports proxying a source model unmodified.
im ...................... Kernel: Provides complex input methods.
image_heuristic_mask .... Images: Supports creating a 1-bpp heuristic mask for images.
image_text .............. Images: Supports image file text strings.
imageformat_bmp ......... Images: Supports Microsoft's Bitmap image file format.
imageformat_jpeg ........ Images: Supports the Joint Photographic Experts Group image file format.
imageformat_png ......... Images: Supports the Portable Network Graphics image file format.
imageformat_ppm ......... Images: Supports the Portable Pixmap image file format.
imageformat_xbm ......... Images: Supports the X11 Bitmap image file format.
imageformat_xpm ......... Images: Supports the X11 Pixmap image file format.
imageformatplugin ....... Images: Provides a base for writing a image format plugins.
inputdialog ............. Dialogs: Provides a simple convenience dialog to get a single value from the user.
itemmodel ............... ItemViews: Provides the item model for item views
itemmodeltester ......... Provides a utility to test item models.
itemviews ............... ItemViews: Provides the model/view architecture managing the relationship between data and the way it is presented to the user.
keysequenceedit ......... Widgets: Provides a widget for editing QKeySequences.
label ................... Widgets: Provides a text or image display.
lcdnumber ............... Widgets: Provides LCD-like digits.
library ................. File I/O: Provides a wrapper for dynamically loaded libraries.
lineedit ................ Widgets: Provides single-line edits.
listview ................ ItemViews: Provides a list or icon view onto a model.
listwidget .............. Widgets: Provides item-based list widgets.
localserver ............. Networking: Provides a local socket based server.
mainwindow .............. Widgets: Provides main application windows.
mdiarea ................. Widgets: Provides an area in which MDI windows are displayed.
menu .................... Widgets: Provides popup-menus.
menubar ................. Widgets: Provides pull-down menu items.
messagebox .............. Dialogs: Provides message boxes displaying informative messages and simple questions.
mimetype ................ Utilities: Provides MIME type handling.
movie ................... Images: Supports animated images.
multiprocess ............ Utilities: Provides support for detecting the desktop environment, launching external processes and opening URLs.
networkdiskcache ........ Networking: Provides a disk cache for network resources.
networkinterface ........ Networking: Supports enumerating a host's IP addresses and network interfaces.
networkproxy ............ Networking: Provides network proxy support.
ocsp .................... Networking: Provides OCSP stapling support
paint_debug ............. Painting: Enabled debugging painting with the environment variables QT_FLUSH_UPDATE and QT_FLUSH_PAINT.
pdf ..................... Painting: Provides a PDF backend for QPainter.
picture ................. Painting: Supports recording and replaying QPainter commands.
printdialog ............. Dialogs: Provides a dialog widget for specifying printer configuration.
printer ................. Painting: Provides a printer backend of QPainter.
printpreviewdialog ...... Dialogs: Provides a dialog for previewing and configuring page layouts for printer output.
printpreviewwidget ...... Widgets: Provides a widget for previewing page layouts for printer output.
process ................. File I/O: Supports external process invocation.
processenvironment ...... File I/O: Provides a higher-level abstraction of environment variables.
progressbar ............. Widgets: Supports presentation of operation progress.
progressdialog .......... Dialogs: Provides feedback on the progress of a slow operation.
properties .............. Kernel: Supports scripting Qt-based applications.
proxymodel .............. ItemViews: Supports processing of data passed between another model and a view.
pushbutton .............. Widgets: Provides a command button.
qml-animation ........... QML: Provides support for animations and timers in QML.
qml-debug ............... QML: Provides infrastructure and plugins for debugging and profiling.
qml-delegate-model ...... QML: Provides the DelegateModel QML type.
qml-devtools ............ QML: Provides the QmlDevtools library and various utilities.
qml-jit ................. QML: Provides a JIT for QML and JavaScript
qml-list-model .......... QML: Provides the ListModel QML type.
qml-locale .............. QML: Provides support for locales in QML.
qml-network ............. QML: Provides network transparency.
qml-object-model ........ QML: Provides the ObjectModel and Instantiator QML types.
qml-preview ............. QML: Updates QML documents in your application live as you change them on disk
qml-profiler ............ QML: Supports retrieving QML tracing data from an application.
qml-sequence-object ..... QML: Supports mapping sequence types into QML.
qml-table-model ......... QML: Provides the TableModel QML type.
qml-worker-script ....... QML: Enables the use of threads in QML.
qml-xml-http-request .... QML: Provides support for sending XML http requests.
quick-animatedimage ..... Qt Quick: Provides the AnimatedImage item.
quick-canvas ............ Qt Quick: Provides the Canvas item.
quick-designer .......... Qt Quick: Provides support for the Qt Quick Designer in Qt Creator.
quick-flipable .......... Qt Quick: Provides the Flipable item.
quick-gridview .......... Qt Quick: Provides the GridView item.
quick-listview .......... Qt Quick: Provides the ListView item.
quick-particles ......... Qt Quick: Provides a particle system.
quick-path .............. Qt Quick: Provides Path elements.
quick-pathview .......... Qt Quick: Provides the PathView item.
quick-positioners ....... Qt Quick: Provides Positioner items.
quick-repeater .......... Qt Quick: Provides the Repeater item.
quick-shadereffect ...... Qt Quick: Provides Shader effects.
quick-sprite ............ Qt Quick: Provides the Sprite item.
quick-tableview ......... Qt Quick: Provides the TableView item.
radiobutton ............. Widgets: Provides a radio button with a text label.
raster-64bit ............ Painting: Internal painting support for 64 bit (16 bpc) rasterization.
regularexpression ....... Kernel: Provides an API to Perl-compatible regular expressions.
resizehandler ........... Widgets: Provides an internal resize handler for dock widgets.
rubberband .............. Widgets: Supports using rubberbands to indicate selections and boundaries.
scrollarea .............. Widgets: Supports scrolling views onto widgets.
scrollbar ............... Widgets: Provides scrollbars allowing the user access parts of a document that is larger than the widget used to display it.
scroller ................ Widgets: Enables kinetic scrolling for any scrolling widget or graphics item.
sessionmanager .......... Kernel: Provides an interface to the windowing system's session management.
settings ................ File I/O: Provides persistent application settings.
sha3-fast ............... Utilities: Optimizes SHA3 for speed instead of size.
sharedmemory ............ Kernel: Provides access to a shared memory segment.
shortcut ................ Kernel: Provides keyboard accelerators and shortcuts.
sizegrip ................ Widgets: Provides corner-grips for resizing top-level windows.
slider .................. Widgets: Provides sliders controlling a bounded value.
socks5 .................. Networking: Provides SOCKS5 support in QNetworkProxy.
sortfilterproxymodel .... ItemViews: Supports sorting and filtering of data passed between another model and a view.
spinbox ................. Widgets: Provides spin boxes handling integers and discrete sets of values.
splashscreen ............ Widgets: Supports splash screens that can be shown during application startup.
splitter ................ Widgets: Provides user controlled splitter widgets.
sqlmodel ................ Provides item model classes backed by SQL databases.
sspi .................... Networking: Enable NTLM/SPNEGO authentication through SSPI
stackedwidget ........... Widgets: Provides stacked widgets.
standarditemmodel ....... ItemViews: Provides a generic model for storing custom data.
statemachine ............ Utilities: Provides hierarchical finite state machines.
statusbar ............... Widgets: Supports presentation of status information.
statustip ............... Widgets: Supports status tip functionality and events.
stringlistmodel ......... ItemViews: Provides a model that supplies strings to views.
style-stylesheet ........ Styles: Provides a widget style which is configurable via CSS.
syntaxhighlighter ....... Widgets: Supports custom syntax highlighting.
systemsemaphore ......... Kernel: Provides a general counting system semaphore.
systemtrayicon .......... Utilities: Provides an icon for an application in the system tray.
tabbar .................. Widgets: Provides tab bars, e.g., for use in tabbed dialogs.
tabletevent ............. Kernel: Supports tablet events.
tableview ............... ItemViews: Provides a default model/view implementation of a table view.
tablewidget ............. Widgets: Provides item-based table views.
tabwidget ............... Widgets: Supports stacking tabbed widgets.
temporaryfile ........... File I/O: Provides an I/O device that operates on temporary files.
testlib_selfcover ....... Gauges how thoroughly testlib's selftest exercises testlib's code
textbrowser ............. Widgets: Supports HTML document browsing.
textcodec ............... Internationalization: Supports conversions between text encodings.
textdate ................ Data structures: Supports month and day names in dates.
textedit ................ Widgets: Supports rich text editing.
texthtmlparser .......... Kernel: Provides a parser for HTML.
textmarkdownreader ...... Kernel: Provides a Markdown (CommonMark and GitHub) reader
textmarkdownwriter ...... Kernel: Provides a Markdown (CommonMark) writer
textodfwriter ........... Kernel: Provides an ODF writer.
thread .................. Kernel: Provides QThread and related classes.
timezone ................ Utilities: Provides support for time-zone handling.
toolbar ................. Widgets: Provides movable panels containing a set of controls.
toolbox ................. Widgets: Provides columns of tabbed widget items.
toolbutton .............. Widgets: Provides quick-access buttons to commands and options.
tooltip ................. Widgets: Supports presentation of tooltips.
topleveldomain .......... Utilities: Provides support for extracting the top level domain from URLs.
translation ............. Internationalization: Supports translations using QObject::tr().
transposeproxymodel ..... ItemViews: Provides a proxy to swap rows and columns of a model.
treeview ................ ItemViews: Provides a default model/view implementation of a tree view.
treewidget .............. Widgets: Provides views using tree models.
tuiotouch ............... Provides the TuioTouch input plugin.
udpsocket ............... Networking: Provides access to UDP sockets.
undocommand ............. Utilities: Applies (redo or) undo of a single change in a document.
undogroup ............... Utilities: Provides the ability to cluster QUndoCommands.
undostack ............... Utilities: Provides the ability to (redo or) undo a list of changes in a document.
undoview ................ Utilities: Provides a widget which shows the contents of an undo stack.
validator ............... Widgets: Supports validation of input text.
whatsthis ............... Widget Support: Supports displaying "What's this" help.
wheelevent .............. Kernel: Supports wheel events.
widgettextcontrol ....... Widgets: Provides text control functionality to other widgets.
wizard .................. Dialogs: Provides a framework for multi-page click-through dialogs.
xmlstream ............... Kernel: Provides a simple streaming API for XML.
xmlstreamreader ......... Kernel: Provides a well-formed XML parser with a simple streaming API.
xmlstreamwriter ......... Kernel: Provides a XML writer with a simple streaming API.

これが、Qt からビルド時に削除できる機能の(そして実は不完全な)一覧です。configure のオプションに、-no-feature-機能名 を渡すことで、その機能が削除されたビルドが出来上がります。

Qt Lite の実態

いくつかのパターンがありますが、基本は2つで、

.pro/.pri ファイルから対象のソースコードを除くケース

qtdeclarative/src/qml/debugger/debugger.pri

qtConfig(qml-debug) {
    HEADERS += \
        $$PWD/qqmlabstractprofileradapter_p.h \
        $$PWD/qqmlconfigurabledebugservice_p.h \
        $$PWD/qqmldebugpluginmanager_p.h \
        $$PWD/qqmldebugservice_p.h \
        $$PWD/qqmldebugservicefactory_p.h \
        $$PWD/qqmldebugserver_p.h \
        $$PWD/qqmldebugserverconnection_p.h \
        $$PWD/qqmlprofilerdefinitions_p.h

    SOURCES += \
        $$PWD/qqmldebug.cpp \
        $$PWD/qqmldebugconnector.cpp \
        $$PWD/qqmldebugservice.cpp \
        $$PWD/qqmlabstractprofileradapter.cpp \
        $$PWD/qqmlmemoryprofiler.cpp \
        $$PWD/qqmlprofiler.cpp \
        $$PWD/qqmldebugserviceinterfaces.cpp
}

それから、ソースコードから、機能を取り除くケースになります。

qtdeclarative/src/quick/items/qquickitem.h

#if QT_CONFIG(cursor)
    QCursor cursor() const;
    void setCursor(const QCursor &cursor);
    void unsetCursor();
#endif

Qt とアプリケーションのビルド -static -optimize-size -ltcg -no-feature-…

どの機能が必要で、どの機能が必要なくて、さらに、どの機能は外してもビルドが正常に完了するか、を踏まえ、以下のオプションでビルドをすることにしました。

特に一番最後はとても重要で、Qt Lite系のビルドはあまりちゃんとメンテされてないので、全ての機能が正常に外せるわけではありません。その辺のノウハウや詳細は別途記事を書くことにして、とりあえず以下のオプションで試してみましょう。

$ ../qt5/configure -opensource -confirm-license -release -make libs -no-widgets -no-pch -prefix /opt/qt-lite -hostprefix $PWD/root -ccache -opengl es2 -device linux-rasp-pi3-g++ -device-option CROSS_COMPILE=~/org/buildroot/raspberry-pi3/host/bin/arm-buildroot-linux-uclibcgnueabihf- -sysroot ~/org/buildroot/raspberry-pi3/host/arm-buildroot-linux-uclibcgnueabihf/sysroot/ -static -optimize-size -ltcg -no-feature-accessibility -no-feature-accessibility-atspi-bridge -no-feature-action -no-feature-alloca -no-feature-alloca_h -no-feature-alloca_malloc_h -no-feature-android-style-assets -no-feature-angle -no-feature-angle_d3d11_qdtd -no-feature-appstore-compliant -no-feature-avx2 -no-feature-bearermanagement -no-feature-big_codecs -no-feature-c++11 -no-feature-c++14 -no-feature-c++1z -no-feature-c++2a -no-feature-c11 -no-feature-c99 -no-feature-clipboard -no-feature-clock-gettime -no-feature-colornames -no-feature-combined-angle-lib -feature-commandlineparser -no-feature-concatenatetablesproxymodel -no-feature-concurrent -feature-cross_compile -no-feature-cssparser -no-feature-cxx11_future -no-feature-cxx14_make_unique -no-feature-d3d12 -no-feature-datetimeparser -no-feature-dbus -no-feature-debug_and_release -no-feature-desktopservices -no-feature-direct2d -no-feature-direct2d1_1 -no-feature-direct3d11 -no-feature-direct3d11_1 -no-feature-direct3d9 -no-feature-directfb -no-feature-dnslookup -no-feature-draganddrop -no-feature-drm_atomic -no-feature-dtls -no-feature-dxgi -no-feature-dxgi1_2 -no-feature-dxguid -feature-egl -no-feature-egl_x11 -feature-eglfs -feature-eglfs_brcm -no-feature-eglfs_egldevice -no-feature-eglfs_gbm -no-feature-eglfs_mali -no-feature-eglfs_openwfd -no-feature-eglfs_rcar -no-feature-eglfs_viv -no-feature-eglfs_viv_wl -no-feature-eglfs_vsp2 -no-feature-eglfs_x11 -no-feature-etw -feature-evdev -no-feature-filesystemiterator -no-feature-filesystemwatcher -no-feature-fontconfig -no-feature-force_asserts -no-feature-framework -no-feature-ftp -no-feature-futimens -no-feature-futimes -no-feature-future -no-feature-gestures -no-feature-getauxval -no-feature-getentropy -feature-gif -no-feature-glib -no-feature-glibc -no-feature-gnu-libiconv -no-feature-gssapi -no-feature-harfbuzz -feature-http -no-feature-ico -no-feature-iconv -no-feature-icu -no-feature-identityproxymodel -no-feature-im -no-feature-image_heuristic_mask -no-feature-image_text -no-feature-imageformat_bmp -no-feature-imageformat_jpeg -no-feature-imageformat_png -no-feature-imageformat_ppm -no-feature-imageformat_xbm -no-feature-imageformat_xpm -feature-imageformatplugin -no-feature-inotify -no-feature-integrityfb -no-feature-integrityhid -no-feature-journald -no-feature-jpeg -no-feature-kms -no-feature-libinput -no-feature-libproxy -no-feature-libudev -no-feature-linkat -no-feature-linux-netlink -no-feature-linuxfb -no-feature-localserver -no-feature-lttng -no-feature-mimetype-database -no-feature-movie -no-feature-mtdev -no-feature-multiprocess -no-feature-networkdiskcache -no-feature-networkinterface -no-feature-ocsp -feature-opengl -feature-opengles2 -no-feature-opengles3 -no-feature-opengles31 -no-feature-opengles32 -no-feature-openssl -no-feature-openssl-linked -no-feature-openvg -no-feature-pdf -no-feature-picture -feature-pkg-config -no-feature-png -no-feature-poll_poll -no-feature-poll_pollts -no-feature-poll_ppoll -feature-poll_select -no-feature-posix-libiconv -no-feature-posix_fallocate -no-feature-process -no-feature-processenvironment -no-feature-qeventtransition -no-feature-qml-debug -feature-qml-devtools -no-feature-qml-jit -feature-qml-list-model -no-feature-qml-locale -feature-qml-network -no-feature-qml-preview -no-feature-qml-profiler -no-feature-qml-sequence-object -no-feature-qml-table-model -no-feature-qml-worker-script -feature-qml-xml-http-request -no-feature-quick-animatedimage -no-feature-quick-canvas -no-feature-quick-designer -no-feature-quick-flipable -feature-quick-listview -no-feature-quick-particles -feature-quick-positioners -feature-quick-repeater -no-feature-quick-tableview -no-feature-raster-64bit -no-feature-reduce_exports -no-feature-reduce_relocations -no-feature-release_tools -no-feature-renameat2 -no-feature-rpath -no-feature-schannel -no-feature-sctp -no-feature-securetransport -no-feature-separate_debug_info -no-feature-sessionmanager -no-feature-sha3-fast -no-feature-sharedmemory -no-feature-shortcut -no-feature-simulator_and_device -no-feature-slog2 -no-feature-socks5 -no-feature-sortfilterproxymodel -no-feature-sql -no-feature-sse2 -no-feature-ssl -no-feature-sspi -no-feature-stack-protector-strong -no-feature-standarditemmodel -no-feature-statemachine -no-feature-statx -no-feature-syslog -no-feature-system-doubleconversion -no-feature-system-freetype -no-feature-system-harfbuzz -no-feature-system-jpeg -no-feature-system-pcre2 -no-feature-system-png -no-feature-system-proxies -no-feature-system-textmarkdownreader -no-feature-system-xcb -no-feature-system-zlib -no-feature-systemsemaphore -no-feature-systemtrayicon -no-feature-tabletevent -no-feature-testlib -no-feature-textmarkdownreader -no-feature-textodfwriter -feature-thread -no-feature-timezone -no-feature-topleveldomain -no-feature-transposeproxymodel -no-feature-tslib -no-feature-tuiotouch -no-feature-udpsocket -no-feature-validator -no-feature-vnc -no-feature-vsp2 -no-feature-vulkan -no-feature-whatsthis -no-feature-wheelevent -no-feature-xkbcommon -no-feature-xlib -no-feature-xml -feature-xmlstreamwriter -no-feature-zstd
$ make -j4
$ make install

$ mkdir -p ~/com/github/task-jp/weather/lite
$ cd $_
$ ~/io/qt/code/qt/dev/lite/root/bin/qmake -r ../weather
$ make -j4

バイナリサイズの確認 -static -optimized-size -ltcg -no-feature-… ………..

$ ls -l weather
-rwxr-xr-x 1 tasuku users 7909972 Jun 23 04:19 weather

まとめ

デフォルトビルド21821596B100%
-static17321224B↩79.4%79.4%
-static -optimize-size11773660B↩68.0%54.0%
-static -optimize-size -ltcg10802948B↩91.8%49.5%
-static -optimize-size -ltcg -no-feature-…7909972B↩73.2%36.2%

今回のデモアプリに必要のない機能を片っ端から削除した結果、なんと、27%もの削減に成功しました。

デフォルトのサイズと比較すると、おおよそ 1/3 になった計算になります。

というわけで、技術的にはこんなことも可能だということを知っていただければと思います。

実際にここまでやるには勘と経験と驚くほどの時間と、運が必要となりますので、もしみなさんが本当にここまでやる必要がある場合は、一度 個別でご相談 いただければ、喜んでお手伝いさせていただきます。

おすすめ