Skip to content

Commit 09ac6c8

Browse files
committed
Merge bitcoin/bitcoin#23862: build, qt: Hardcode last modified timestamp in Qt RCC
11736db build, qt: Hardcode last modified timestamp in Qt RCC (Hennadii Stepanov) Pull request description: Our Guix build system sets the [`SOURCE_DATE_EPOCH`](https://reproducible-builds.org/specs/source-date-epoch/) and propagates it to the depends build subsystem. Its [default value](https://github.com/bitcoin/bitcoin/blob/master/contrib/guix/README.md#recognized-environment-variables) is the top commit timestamp. After bumping Qt version up to 5.15.2, due to [this](qt/qtbase@1ffcca4) change, every time they are going to make new Guix builds for another branch/commit they must ensure that the `qt` package will be rebuilt from scratch. Otherwise, Bitcoin Core GUI binaries will be non-deterministic. Such behavior makes working with Guix builds suboptimal. This PR fixes the described issue by patching Qt RCC and hardcoding last modified timestamps with `1`. It's worth to mention that this change is compatible with a possible future [improvement](bitcoin/bitcoin#21995) which makes each dependency package reproducible. A drawback of such an approach is not currently applied to our project, as it effectively makes [QML cache files](https://bugreports.qt.io/browse/QTBUG-57182) useless. I can't say it's a problem for the https://github.com/bitcoin-core/gui-qml project. --- **A note for thinkers:** For now this change is enough as only Qt source contains `SOURCE_DATE_EPOCH`. But in general we should re-think about treating the `SOURCE_DATE_EPOCH` variable in the depends build subsystem. For instance, its default value could be the output of `git log --format=%at -1 -- depends`. ACKs for top commit: fanquake: ACK 11736db Tree-SHA512: 31f104010a0a78d217aafcc5bc4606351f9060fc2a827277935b85fc8ced9f3d90a31d812c7db8c2711fb6daccd279cf0945dc1d7a7199e0eb0ade451cdbcd5d
2 parents 6a36372 + 11736db commit 09ac6c8

File tree

2 files changed

+26
-0
lines changed

2 files changed

+26
-0
lines changed

depends/packages/qt.mk

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ $(package)_patches += dont_use_avx_android_x86_64.patch dont_hardcode_x86_64.pat
1313
$(package)_patches += fix_android_jni_static.patch dont_hardcode_pwd.patch
1414
$(package)_patches += qtbase-moc-ignore-gcc-macro.patch fix_limits_header.patch
1515
$(package)_patches += fix_bigsur_style.patch use_android_ndk23.patch
16+
$(package)_patches += rcc_hardcode_timestamp.patch
1617

1718
$(package)_qttranslations_file_name=qttranslations-$($(package)_suffix)
1819
$(package)_qttranslations_sha256_hash=d5788e86257b21d5323f1efd94376a213e091d1e5e03b45a95dd052b5f570db8
@@ -237,6 +238,7 @@ define $(package)_preprocess_cmds
237238
patch -p1 -i $($(package)_patch_dir)/fix_montery_include.patch && \
238239
patch -p1 -i $($(package)_patch_dir)/fix_bigsur_style.patch && \
239240
patch -p1 -i $($(package)_patch_dir)/use_android_ndk23.patch && \
241+
patch -p1 -i $($(package)_patch_dir)/rcc_hardcode_timestamp.patch && \
240242
mkdir -p qtbase/mkspecs/macx-clang-linux &&\
241243
cp -f qtbase/mkspecs/macx-clang/qplatformdefs.h qtbase/mkspecs/macx-clang-linux/ &&\
242244
cp -f $($(package)_patch_dir)/mac-qmake.conf qtbase/mkspecs/macx-clang-linux/qmake.conf && \
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
Hardcode last modified timestamp in Qt RCC
2+
3+
This change allows the already built qt package to be reused even with
4+
the SOURCE_DATE_EPOCH variable set, e.g., for Guix builds.
5+
6+
7+
--- old/qtbase/src/tools/rcc/rcc.cpp
8+
+++ new/qtbase/src/tools/rcc/rcc.cpp
9+
@@ -227,14 +227,7 @@ void RCCFileInfo::writeDataInfo(RCCResourceLibrary &lib)
10+
11+
if (lib.formatVersion() >= 2) {
12+
// last modified time stamp
13+
- const QDateTime lastModified = m_fileInfo.lastModified();
14+
- quint64 lastmod = quint64(lastModified.isValid() ? lastModified.toMSecsSinceEpoch() : 0);
15+
- static const quint64 sourceDate = 1000 * qgetenv("QT_RCC_SOURCE_DATE_OVERRIDE").toULongLong();
16+
- if (sourceDate != 0)
17+
- lastmod = sourceDate;
18+
- static const quint64 sourceDate2 = 1000 * qgetenv("SOURCE_DATE_EPOCH").toULongLong();
19+
- if (sourceDate2 != 0)
20+
- lastmod = sourceDate2;
21+
+ quint64 lastmod = quint64(1);
22+
lib.writeNumber8(lastmod);
23+
if (text || pass1)
24+
lib.writeChar('\n');

0 commit comments

Comments
 (0)