<table><tr><td style="">vkrause added a subscriber: arojas.<br />vkrause added a comment.
</td><a style="text-decoration: none; padding: 4px 8px; margin: 0 8px 8px; float: right; color: #464C5C; font-weight: bold; border-radius: 3px; background-color: #F7F7F9; background-image: linear-gradient(to bottom,#fff,#f1f0f1); display: inline-block; border: 1px solid rgba(71,87,120,.2);" href="https://phabricator.kde.org/D13816">View Revision</a></tr></table><br /><div><div><blockquote style="border-left: 3px solid #8C98B8;
color: #6B748C;
font-style: italic;
margin: 4px 0 12px 0;
padding: 8px 12px;
background-color: #F8F9FC;">
<div style="font-style: normal;
padding-bottom: 4px;">In <a href="https://phabricator.kde.org/D13816#289594" style="background-color: #e7e7e7;
border-color: #e7e7e7;
border-radius: 3px;
padding: 0 4px;
font-weight: bold;
color: black;text-decoration: none;">D13816#289594</a>, <a href="https://phabricator.kde.org/p/lepagevalleeemmanuel/" style="
border-color: #f1f7ff;
color: #19558d;
background-color: #f1f7ff;
border: 1px solid transparent;
border-radius: 3px;
font-weight: bold;
padding: 0 4px;">@lepagevalleeemmanuel</a> wrote:</div>
<div style="margin: 0;
padding: 0;
border: 0;
color: rgb(107, 116, 140);"><blockquote style="border-left: 3px solid #a7b5bf; color: #464c5c; font-style: italic; margin: 4px 0 12px 0; padding: 4px 12px; background-color: #f8f9fc;"><p>That bug report is more what I'm looking at here. I disagree with your assessment though that this is undefined behavior or broken in the current dynamic code. Static construction is actually a pattern used all over the place, among them are qrc, the qml compiler and the ECM qm catalog loader, as well as custom code as you found in KConfig, or as this patch tries to support in KItinerary. So I think we need a proper solution for this.</p></blockquote>
<p>Static construction is fine. The issue here is a lot more subtle. Let's take a similar case. Back when the distributions started to use the <tt style="background: #ebebeb; font-size: 13px;">--as-needed</tt> LDFLAGS, there was a lot of this issue too. If a library is not used, then you can't "trust" that the static code will get executed because the linker has the "right" to drop whole .so. When using LTO, you get this issue on the compilation unit level. So a <tt style="background: #ebebeb; font-size: 13px;">.o</tt> can be dropped entirely if nothing points to that CU, even if static init from that CU point to other CU. This is why static code needs to be handled with care on them. It isn't forbidden, it just can't be "trusted" to be executed. In the case of the kconfig bug, it clearly isn't executed with very bad consequences. It is not a gold linker bug, it's just how LTO dead code elimination works.</p></div>
</blockquote>
<p>Yep, and that's what this patch proposes a solution for. Not a pretty one, but it at least addresses this reliably and platform-independent.</p>
<blockquote style="border-left: 3px solid #a7b5bf; color: #464c5c; font-style: italic; margin: 4px 0 12px 0; padding: 4px 12px; background-color: #f8f9fc;"><blockquote style="border-left: 3px solid #a7b5bf; color: #464c5c; font-style: italic; margin: 4px 0 12px 0; padding: 4px 12px; background-color: #f8f9fc;"><p>Most of those patches seem to be dealing with the Qt5::Test dependency or other dependency-related changes, ie. this should be pretty harmless to integrate?</p></blockquote>
<p>Yes and no. The majority is easy, but there is a very hard minority of changes that will be enormously controversial.</p>
<p>The easy basic:</p>
<ul class="remarkup-list">
<li class="remarkup-list-item">Allow to disable Qt::Test because LTO-ing test takes too much resources to be ran in every CI build</li>
</ul></blockquote>
<p><a href="https://phabricator.kde.org/p/arojas/" style="
border-color: #f1f7ff;
color: #19558d;
background-color: #f1f7ff;
border: 1px solid transparent;
border-radius: 3px;
font-weight: bold;
padding: 0 4px;">@arojas</a> is currently integrating a large set of patches for this I think.</p>
<blockquote style="border-left: 3px solid #a7b5bf; color: #464c5c; font-style: italic; margin: 4px 0 12px 0; padding: 4px 12px; background-color: #f8f9fc;"><ul class="remarkup-list">
<li class="remarkup-list-item">Stop using "SHARED" in add_library and always use the "BUILD_SHARED_LIBS ON" option</li>
<li class="remarkup-list-item">Fix all cmake "targets" to have the correct dependencies exported to avoid adding manual <tt style="background: #ebebeb; font-size: 13px;">-lkf5foo</tt> due to misexported deps</li>
<li class="remarkup-list-item">For the framework that are Qt plugins, add the necessary MOC arguments
<br /><br />
The much harder parts:</li>
<li class="remarkup-list-item">There is some new classes of bugs like dead code elimination having side effects</li>
<li class="remarkup-list-item">Some things like Kio "hard" dependencies have to go or undergo large redesign because they often are used in a single line of code (file picker widget) and pull 10 frameworks that make no sense for static binaries.</li>
<li class="remarkup-list-item">Everything using client-daemon or multi-process model become very impractical on Android and other bundles</li>
<li class="remarkup-list-item">Everything that uses dlopen is potentially broken</li>
<li class="remarkup-list-item">All KDE deamons like kdeinit5/kded5/knotify need to be reconsidered because they make no sense in sandboxes and have bad side effects like increased binary size instead of a reduction due to each binary having its own Qt</li>
<li class="remarkup-list-item">Things like the icon theme and resource should to have some ways of getting bundled to have "portable" binaries</li>
<li class="remarkup-list-item">Some external customization like icon theme, color scheme and theme break</li>
</ul></blockquote>
<p>Valid points but mostly affecting tier 3(+) frameworks I think, most tier 1/2 frameworks are at most affected by static construction. So I think we can look at this independently, as for some use-cases you don't need the full set of frameworks (e.g. newly written applications targeting Android from the start).</p>
<blockquote style="border-left: 3px solid #a7b5bf; color: #464c5c; font-style: italic; margin: 4px 0 12px 0; padding: 4px 12px; background-color: #f8f9fc;"><p>Ideally / eventually / hopefully:</p>
<ul class="remarkup-list">
<li class="remarkup-list-item">The kconfig kcfg compiler need either to be rewritten without Qt or exposed as web service because it is "incompatible"/"impractical" with cross-compilation</li>
<li class="remarkup-list-item">The breeze icon pack generator and translation compiler also need some work to be easier to integrate</li>
<li class="remarkup-list-item">We need a CI to validate the result and detect regression otherwise it will break again after 1 week
<br /><br />
For the last 2, I mix static builds with "container driven cross compilation" issues. It's not fully relevant to static libs, but rather the use case for them,
<br /><br />
So in the end, it's not simple and will make some people very unhappy. The patches I maintain is the strict minimum for ring-kde to link and work. It isn't a clean job and it isn't the complete picture. I felt like this isn't something I can just start submitting patches and eventually finish. It needs buy-in from a lot of people and I am not sure it can happen without face to face discussion at Akademy or something.</li>
</ul></blockquote>
<p>That's why I'm not trying to look at this as one monolithic change, but one piece at a time :) I don't think we need to wait until Akademy to discuss e.g. this proposed solution for the static construction problem.</p></div></div><br /><div><strong>REPOSITORY</strong><div><div>R1003 KItinerary: Travel Reservation handling library</div></div></div><br /><div><strong>REVISION DETAIL</strong><div><a href="https://phabricator.kde.org/D13816">https://phabricator.kde.org/D13816</a></div></div><br /><div><strong>To: </strong>vkrause, Frameworks<br /><strong>Cc: </strong>arojas, mart, lepagevalleeemmanuel, apol, kde-pim, dvasin, rodsevich, winterz, vkrause, mlaurent, knauss, dvratil<br /></div>