RESOLVED FIXED 270902
[GTK][WPE] Build removing unused sections when supported
https://bugs.webkit.org/show_bug.cgi?id=270902
Summary [GTK][WPE] Build removing unused sections when supported
Miguel Gomez
Reported 2024-03-13 02:37:13 PDT
There are situations in constrained environments where the disk space is really small. In those situations it's interesting that we try to reduce the binary size as much as possible by passing appropriate flags to the compiler.
Attachments
Miguel Gomez
Comment 1 2024-03-13 08:18:47 PDT
Miguel Gomez
Comment 2 2024-03-13 08:24:34 PDT
Building with the proposed optimizations in the PR is broken due to this error: In file included from /app/webkit/Source/WebCore/platform/MediaCapabilitiesDecodingInfo.h:29, from /app/webkit/Source/WebCore/platform/mediastream/gstreamer/GStreamerWebRTCProvider.cpp:28, from /app/webkit/WebKitBuild/WPE/Release/WebCore/DerivedSources/unified-sources/UnifiedSource-3c72abbe-65.cpp:7: In copy constructor ‘constexpr WebCore::MediaDecodingConfiguration::MediaDecodingConfiguration(const WebCore::MediaDecodingConfiguration&)’, inlined from ‘constexpr WebCore::MediaCapabilitiesDecodingInfo::MediaCapabilitiesDecodingInfo(const WebCore::MediaCapabilitiesDecodingInfo&)’ at /app/webkit/Source/WebCore/platform/MediaCapabilitiesDecodingInfo.h:33:8, inlined from ‘constexpr std::_Optional_payload_base<_Tp>::_Storage<_Up, false>::_Storage(std::in_place_t, _Args&& ...) [with _Args = {WebCore::MediaCapabilitiesDecodingInfo&}; _Up = WebCore::MediaCapabilitiesDecodingInfo; _Tp = WebCore::MediaCapabilitiesDecodingInfo]’ at /usr/include/c++/13.2.0/optional:244:8, inlined from ‘constexpr std::_Optional_payload_base<_Tp>::_Optional_payload_base(std::in_place_t, _Args&& ...) [with _Args = {WebCore::MediaCapabilitiesDecodingInfo&}; _Tp = WebCore::MediaCapabilitiesDecodingInfo]’ at /usr/include/c++/13.2.0/optional:126:4, inlined from ‘constexpr std::_Optional_payload<WebCore::MediaCapabilitiesDecodingInfo, true, false, false>::_Optional_payload(std::in_place_t, _Args&& ...) [with _Args = {WebCore::MediaCapabilitiesDecodingInfo&}][inherited from std::_Optional_payload_base<WebCore::MediaCapabilitiesDecodingInfo>]’ at /usr/include/c++/13.2.0/optional:397:42, inlined from ‘constexpr std::_Optional_payload<WebCore::MediaCapabilitiesDecodingInfo, false, false, false>::_Optional_payload(std::in_place_t, _Args&& ...) [with _Args = {WebCore::MediaCapabilitiesDecodingInfo&}][inherited from std::_Optional_payload_base<WebCore::MediaCapabilitiesDecodingInfo>]’ at /usr/include/c++/13.2.0/optional:431:57, inlined from ‘constexpr std::_Optional_base<_Tp, <anonymous>, <anonymous> >::_Optional_base(std::in_place_t, _Args&& ...) [with _Args = {WebCore::MediaCapabilitiesDecodingInfo&}; typename std::enable_if<is_constructible_v<_Tp, _Args ...>, bool>::type <anonymous> = false; _Tp = WebCore::MediaCapabilitiesDecodingInfo; bool <anonymous> = false; bool <anonymous> = false]’ at /usr/include/c++/13.2.0/optional:521:4, inlined from ‘constexpr std::optional<_Tp>::optional(_Up&&) [with _Up = WebCore::MediaCapabilitiesDecodingInfo&; typename std::enable_if<__and_v<std::__not_<std::is_same<std::optional<_Tp>, typename std::remove_cv<typename std::remove_reference<_Iter>::type>::type> >, std::__not_<std::is_same<std::in_place_t, typename std::remove_cv<typename std::remove_reference<_Iter>::type>::type> >, std::is_constructible<_Tp, _Up>, std::is_convertible<_Iter, _Iterator> >, bool>::type <anonymous> = true; _Tp = WebCore::MediaCapabilitiesDecodingInfo]’ at /usr/include/c++/13.2.0/optional:749:47, inlined from ‘virtual std::optional<WebCore::MediaCapabilitiesDecodingInfo> WebCore::GStreamerWebRTCProvider::videoDecodingCapabilitiesOverride(const WebCore::VideoConfiguration&)’ at /app/webkit/Source/WebCore/platform/mediastream/gstreamer/GStreamerWebRTCProvider.cpp:136:19: /app/webkit/Source/WebCore/platform/mediacapabilities/MediaDecodingConfiguration.h:33:8: error: ‘info.WebCore::MediaCapabilitiesDecodingInfo::supportedConfiguration.WebCore::MediaDecodingConfiguration::type’ is used uninitialized [-Werror=uninitialized] 33 | struct MediaDecodingConfiguration : MediaConfiguration { | ^~~~~~~~~~~~~~~~~~~~~~~~~~ /app/webkit/Source/WebCore/platform/mediastream/gstreamer/GStreamerWebRTCProvider.cpp: In member function ‘virtual std::optional<WebCore::MediaCapabilitiesDecodingInfo> WebCore::GStreamerWebRTCProvider::videoDecodingCapabilitiesOverride(const WebCore::VideoConfiguration&)’: /app/webkit/Source/WebCore/platform/mediastream/gstreamer/GStreamerWebRTCProvider.cpp:120:35: note: ‘info’ declared here 120 | MediaCapabilitiesDecodingInfo info; | ^~~~ cc1plus: all warnings being treated as errors The error doesn't happen with the optimizations disabled. I've tested that this is because of the -finline-limit=90 option. The error is about a member of a struct that's not initialized when returning a copy of a local struct in a function. It should happen without the optimizations as well, but the compiler is probably inlining the problematic function, so this copy to return the local value doesn't happen and the warning is not triggered. When -finline-limit=90 is used, the function is not inlined and the error becomes visible. I'll send a fix for the warning once this PR lands.
Miguel Gomez
Comment 3 2024-03-26 07:32:18 PDT
I'm reducing a bit the scope of this to only pass -ffunction-sections -fdata-sections to the compiler and --gc-sections to the linker when available. This reduces the binary size while not causing a performance drop, so it makes sense to have them always enabled.
Michael Catanzaro
Comment 4 2024-03-26 07:57:35 PDT
I'm not familiar with these options, but gcc(1) says: Only use these options when there are significant benefits from doing so. When you specify these options, the assembler and linker create larger object and executable files and are also slower. These options affect code generation. They prevent optimizations by the compiler and assembler using relative locations inside a translation unit since the locations are unknown until link time. An example of such an optimization is relaxing calls to short call instructions.
EWS
Comment 5 2024-03-27 01:52:49 PDT
Committed 276726@main (8603570132a8): <https://commits.webkit.org/276726@main> Reviewed commits have been landed. Closing PR #25819 and removing active labels.
Note You need to log in before you can comment on or make changes to this bug.