Bug 1228131

Summary: kf6-kirigami qml reproducibility issue
Product: [openSUSE] openSUSE Tumbleweed Reporter: Bernhard Wiedemann <bwiedemann>
Component: KDE Workspace (Plasma)Assignee: E-Mail List <opensuse-kde-bugs>
Status: CONFIRMED --- QA Contact: E-mail List <qa-bugs>
Severity: Normal    
Priority: P5 - None CC: fabian, krinpaus
Version: Current   
Target Milestone: ---   
Hardware: Other   
OS: All   
Whiteboard:
Found By: Development Services Priority:
Business Priority: Blocker: ---
Marketing QA Status: --- IT Deployment: ---
Bug Depends on:    
Bug Blocks: 1102408    

Description Bernhard Wiedemann 2024-07-19 03:06:17 UTC
While working on reproducible builds for openSUSE (sponsored by the NLnet NGI0 fund), I found that our kf6-kirigami package varies, unless both builds happen on an 1-core VM.

I noticed that in the buildroot, there are variations in
/home/abuild/rpmbuild/BUILD/kirigami-6.4.0/build/src/dialogs/.rcc/qmlcache/KirigamiDialogs_PromptDialog_qml.cpp
and resulting .o file, so likely the generator of this file considers input files that might or might not be created at the point in time.
This can probably be solved with better-defined build dependencies.
Comment 1 Bernhard Wiedemann 2024-07-19 03:09:05 UTC
same issue with kf6-qqc2-desktop-style and
/home/abuild/rpmbuild/BUILD/qqc2-desktop-style-6.4.0/build/.rcc/qmlcache/org_kde_desktop_private_org.kde.desktop/private/DefaultSliderHandle_qml.cpp
Comment 2 Fabian Vogt 2024-07-19 19:32:27 UTC
I did a build with "make --shuffle=none" and one with "make --shuffle=reverse" and was able to reproduce a difference in ./src/delegates/.rcc/qmlcache/KirigamiDelegates_IconTitleSubtitle_qml.cpp twice. The build with reversed order was missing a substantial part of the AOT generated code.
Comment 3 Fabian Vogt 2024-07-19 20:08:43 UTC
-DVERBOSE_QML_COMPILER=TRUE shows the cause:

Warning: PromptDialog.qml:11:1: Warnings occurred while importing module "org.kde.kirigami": [import]
import org.kde.kirigami as Kirigami
^^^^^^
---
Warning: QML types file does not exist: /home/fabian/kderepos/kirigami/build2/bin/org/kde/kirigami/Kirigami.qmltypes [import]
Warning: QtQuick.Controls uses optional imports which are not supported. Some types might not be found. [import]
Warning: QML types file does not exist: /home/fabian/kderepos/kirigami/build2/bin/org/kde/kirigami/primitives/KirigamiPrimitives.qmltypes [import]
Warning: QML types file does not exist: /home/fabian/kderepos/kirigami/build2/bin/org/kde/kirigami/delegates/KirigamiDelegates.qmltypes [import]

And various similar other cases. So this is yet another instance of https://bugreports.qt.io/browse/QTBUG-121643, which unfortunately does not have a satisfying resolution so far. Declaring all dependencies manually is a lot of work and too fragile, we need some automatic way.
Comment 4 Fabian Vogt 2024-07-19 20:32:07 UTC
(In reply to Fabian Vogt from comment #3)
> -DVERBOSE_QML_COMPILER=TRUE shows the cause:
> 
> Warning: PromptDialog.qml:11:1: Warnings occurred while importing module
> "org.kde.kirigami": [import]
> import org.kde.kirigami as Kirigami
> ^^^^^^
> ---
> Warning: QML types file does not exist:
> /home/fabian/kderepos/kirigami/build2/bin/org/kde/kirigami/Kirigami.qmltypes
> [import]
> Warning: QtQuick.Controls uses optional imports which are not supported.
> Some types might not be found. [import]
> Warning: QML types file does not exist:
> /home/fabian/kderepos/kirigami/build2/bin/org/kde/kirigami/primitives/
> KirigamiPrimitives.qmltypes [import]
> Warning: QML types file does not exist:
> /home/fabian/kderepos/kirigami/build2/bin/org/kde/kirigami/delegates/
> KirigamiDelegates.qmltypes [import]
> 
> And various similar other cases. So this is yet another instance of
> https://bugreports.qt.io/browse/QTBUG-121643, which unfortunately does not
> have a satisfying resolution so far. Declaring all dependencies manually is
> a lot of work and too fragile, we need some automatic way.

I think I managed to get it mostly fixed for kirigami:

diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt
index 56ebf2a5..20242617 100644
--- a/src/CMakeLists.txt
+++ b/src/CMakeLists.txt
@@ -264,6 +264,8 @@ ecm_add_qml_module(KirigamiPrivatePlugin
     GENERATE_PLUGIN_SOURCE
 )
 
+add_dependencies(Kirigami KirigamiPrivatePlugin)
+
 target_sources(KirigamiPrivatePlugin PRIVATE
     copyhelper.cpp
     copyhelper.h
diff --git a/src/delegates/CMakeLists.txt b/src/delegates/CMakeLists.txt
index 734ad0ae..b4fa71b3 100644
--- a/src/delegates/CMakeLists.txt
+++ b/src/delegates/CMakeLists.txt
@@ -5,6 +5,8 @@ ecm_add_qml_module(KirigamiDelegates URI "org.kde.kirigami.delegates"
     DEPENDENCIES QtQuick org.kde.kirigami.platform org.kde.kirigami.primitives
 )
 
+add_dependencies(KirigamiDelegates KirigamiPrimitives)
+
 ecm_target_qml_sources(KirigamiDelegates SOURCES
     IconTitleSubtitle.qml
     TitleSubtitle.qml
diff --git a/src/dialogs/CMakeLists.txt b/src/dialogs/CMakeLists.txt
index 5688fd48..239e903f 100644
--- a/src/dialogs/CMakeLists.txt
+++ b/src/dialogs/CMakeLists.txt
@@ -6,7 +6,7 @@ ecm_add_qml_module(KirigamiDialogs URI "org.kde.kirigami.dialogs"
     DEPENDENCIES QtQuick org.kde.kirigami.platform
 )
 
-
+add_dependencies(KirigamiDialogs KirigamiPrimitives KirigamiDelegates)
 
 ecm_target_qml_sources(KirigamiDialogs SOURCES
     Dialog.qml

But it's not complete as there is a cyclic dependency as KirigamiPrimitives also depends on KirigamiDialogs.qmltypes.
This needs discussion with Qt upstream.