Bug 245452 - net-im/telegram-desktop: Fails to build with ccache: fatal error: file '*' has been modified since the precompiled header '*'
Summary: net-im/telegram-desktop: Fails to build with ccache: fatal error: file '*' ha...
Status: Closed FIXED
Alias: None
Product: Ports & Packages
Classification: Unclassified
Component: Individual Port(s) (show other bugs)
Version: Latest
Hardware: Any Any
: --- Affects Some People
Assignee: Gleb Smirnoff
URL:
Keywords: needs-qa
Depends on:
Blocks:
 
Reported: 2020-04-08 10:54 UTC by Roman Bogorodskiy
Modified: 2021-11-18 03:44 UTC (History)
6 users (show)

See Also:
bugzilla: maintainer-feedback? (henry.hu.sh)


Attachments
disable ccache (392 bytes, patch)
2020-04-10 04:53 UTC, Roman Bogorodskiy
henry.hu.sh: maintainer-approval+
Details | Diff
remove NO_CCACHE (392 bytes, patch)
2020-05-12 14:58 UTC, Roman Bogorodskiy
novel: maintainer-approval?
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Roman Bogorodskiy freebsd_committer freebsd_triage 2020-04-08 10:54:54 UTC
FreeBSD 13-CURRENT amd64, clang version 10.0.0

Builds fails with:

/usr/local/libexec/ccache/c++  -DDESKTOP_APP_DISABLE_CRASH_REPORTS -DDESKTOP_APP_USE_PACKAGED -DDESKTOP_APP_USE_PACKAGED_FONTS -DNDEBUG -DQT_CORE_LIB -DQT_DBUS_LIB -DQT_GUI_LIB -DQT_NETWORK_LIB -DQT_NO_DEBUG -DQT_WIDGETS_LIB -DQ_OS_FREEBSD -DQ_OS_LINUX64 -I/wrkdirs/usr/ports/net-im/telegram-desktop/work/tdesktop-2.0.1-full/Telegram/lib_spellcheck -ITelegram/lib_ui/gen -I/wrkdirs/usr/ports/net-im/telegram-desktop/work/tdesktop-2.0.1-full/Telegram/lib_ui -I/wrkdirs/usr/ports/net-im/telegram-desktop/work/tdesktop-2.0.1-full/Telegram/lib_ui/emoji_suggestions -I/wrkdirs/usr/ports/net-im/telegram-desktop/work/tdesktop-2.0.1-full/Telegram/lib_base -I/wrkdirs/usr/ports/net-im/telegram-desktop/work/tdesktop-2.0.1-full/Telegram/lib_rpl -I/wrkdirs/usr/ports/net-im/telegram-desktop/work/tdesktop-2.0.1-full/Telegram/lib_crl -isystem /usr/local/include/hunspell -isystem /usr/local/include/qt5/QtCore/5.13.2 -isystem /usr/local/include/qt5/QtCore/5.13.2/QtCore -isystem /usr/local/include/qt5/QtGui/5.13.2 -isystem /usr/local/include/qt5/QtGui/5.13.2/QtGui -isystem /usr/local/include/qt5 -isystem /usr/local/include/qt5/QtCore -isystem /usr/local/lib/qt5/mkspecs/freebsd-clang -isystem /usr/local/include/qt5/QtGui -isystem /usr/local/include -isystem /usr/local/include/qt5/QtWidgets -isystem /usr/local/include/qt5/QtNetwork -isystem /usr/local/include/qt5/QtDBus -isystem /wrkdirs/usr/ports/net-im/telegram-desktop/work/tdesktop-2.0.1-full/Telegram/ThirdParty/variant/include -O2 -pipe -fstack-protector-strong -fno-strict-aliasing -O2 -pipe -fstack-protector-strong -fno-strict-aliasing   -fno-strict-aliasing -pipe -Wall -W -fPIC -Wno-unused-variable -Wno-unused-parameter -Wno-unused-function -Wno-switch -Wno-comment -Wno-unused-but-set-variable -Wno-missing-field-initializers -Wno-sign-compare -Wno-attributes -Wno-parentheses -Wno-stringop-overflow -Wno-maybe-uninitialized -Wno-error=class-memaccess -std=gnu++2a -Xclang -include-pch -Xclang /wrkdirs/usr/ports/net-im/telegram-desktop/work/.build/Telegram/lib_spellcheck/CMakeFiles/lib_spellcheck.dir/cmake_pch.hxx.pch -MD -MT Telegram/lib_spellcheck/CMakeFiles/lib_spellcheck.dir/spellcheck/third_party/hunspell_controller.cpp.o -MF Telegram/lib_spellcheck/CMakeFiles/lib_spellcheck.dir/spellcheck/third_party/hunspell_controller.cpp.o.d -o Telegram/lib_spellcheck/CMakeFiles/lib_spellcheck.dir/spellcheck/third_party/hunspell_controller.cpp.o -c /wrkdirs/usr/ports/net-im/telegram-desktop/work/tdesktop-2.0.1-full/Telegram/lib_spellcheck/spellcheck/third_party/hunspell_controller.cpp
warning: unknown warning option '-Wno-unused-but-set-variable'; did you mean '-Wno-unused-const-variable'? [-Wunknown-warning-option]
warning: unknown warning option '-Wno-stringop-overflow'; did you mean '-Wno-shift-overflow'? [-Wunknown-warning-option]
warning: unknown warning option '-Wno-maybe-uninitialized'; did you mean '-Wno-uninitialized'? [-Wunknown-warning-option]
warning: unknown warning option '-Werror=class-memaccess'; did you mean '-Werror=class-varargs'? [-Wunknown-warning-option]
fatal error: file '/wrkdirs/usr/ports/net-im/telegram-desktop/work/.build/Telegram/lib_spellcheck/CMakeFiles/lib_spellcheck.dir/cmake_pch.hxx' has been modified since the precompiled header '/wrkdirs/usr/ports/net-im/telegram-desktop/work/.build/Telegram/lib_spellcheck/CMakeFiles/lib_spellcheck.dir/cmake_pch.hxx.pch' was built: mtime changed
note: please rebuild precompiled header '/wrkdirs/usr/ports/net-im/telegram-desktop/work/.build/Telegram/lib_spellcheck/CMakeFiles/lib_spellcheck.dir/cmake_pch.hxx.pch'
4 warnings and 1 error generated.

Complete log attached.
Comment 1 Roman Bogorodskiy freebsd_committer freebsd_triage 2020-04-08 11:44:06 UTC
Apparently, the log file is too big for attachment, so here it goes: https://people.freebsd.org/~novel/misc/telegram-desktop-2.0.1.log
Comment 2 Henry Hu 2020-04-08 23:25:25 UTC
Interestingly, I tried to use clang10 on 12.1-STABLE (make CC=clang10 CXX=clang++10), and it works. Thus, maybe it's not clang, but something else.
However, I don't have -CURRENT installed, so I can't test how it works there.
Meanwhile, can you check the mtime of 

'/wrkdirs/usr/ports/net-im/telegram-desktop/work/.build/Telegram/lib_spellcheck/CMakeFiles/lib_spellcheck.dir/cmake_pch.hxx'

and

'/wrkdirs/usr/ports/net-im/telegram-desktop/work/.build/Telegram/lib_spellcheck/CMakeFiles/lib_spellcheck.dir/cmake_pch.hxx.pch'

(stat -f %m, etc.) to check if the .hxx file is really modified after .pch?
Comment 3 Fernando Apesteguía freebsd_committer freebsd_triage 2020-04-09 17:17:37 UTC
I've seen this sometimes when ccache is enabled (with Qt moc files for example).

Roman, I see you have ccache enabled. Would you try disabling it?
Comment 4 Roman Bogorodskiy freebsd_committer freebsd_triage 2020-04-10 03:08:21 UTC
(07:04) novel@romashka:/usr/local/poudriere/data/wrkdirs/current-local/local/work %> stat -f %m .build/Telegram/lib_spellcheck/CMakeFiles/lib_spellcheck.dir/cmake_pch.hxx
1586487036
(07:04) novel@romashka:/usr/local/poudriere/data/wrkdirs/current-local/local/work %> stat -f %m .build/Telegram/lib_spellcheck/CMakeFiles/lib_spellcheck.dir/cmake_pch.hxx.pch
1586487040
(07:04) novel@romashka:/usr/local/poudriere/data/wrkdirs/current-local/local/work %> 

It does build fine without ccache indeed. However, when it's enabled, the failure doesn't seem to be intermittent, i.e. it failed all 3 or 4 times that I've tried to build it.
Comment 5 Kubilay Kocak freebsd_committer freebsd_triage 2020-04-10 03:56:06 UTC
This issue (clang + ccache + telegram) should probably be reported/resolved upstream
Comment 6 Steve Wills freebsd_committer freebsd_triage 2020-04-10 04:22:26 UTC
(In reply to Kubilay Kocak from comment #5)
That would be ideal, but until then, perhaps we can set NO_CCACHE in net-im/telegram-desktop/Makefile?
Comment 7 Henry Hu 2020-04-10 04:34:07 UTC
(In reply to Kubilay Kocak from comment #5)
I think it's more than that. I'm running 12.1-STABLE and the clang version is 9.0.1. I also have ccache enabled. When I build the telegram-desktop, I don't have this issue.
Maybe it's clang10 + ccache?

I agree that we can temporarily disable ccache to at least make it build.
Comment 8 Roman Bogorodskiy freebsd_committer freebsd_triage 2020-04-10 04:53:50 UTC
Created attachment 213239 [details]
disable ccache

I'm going to test the attached patch that disables ccache and commit it later today if that helps.
Please let me know if you have any objections.

PS As it's quite clear when this issue shows up, I think it's better to disable it unconditionally (rather than checking if compiling with clang10 etc).
Comment 9 Roman Bogorodskiy freebsd_committer freebsd_triage 2020-04-10 11:09:50 UTC
(In reply to Roman Bogorodskiy from comment #8)

Yes, it builds fine with NO_CCACHE.
Comment 10 commit-hook freebsd_committer freebsd_triage 2020-04-11 16:34:28 UTC
A commit references this bug:

Author: novel
Date: Sat Apr 11 16:33:57 UTC 2020
New revision: 531435
URL: https://svnweb.freebsd.org/changeset/ports/531435

Log:
  net-im/telegram-desktop: temporarily disable ccache

  Building with ccache might fail, so disable it for now until it's fixed.

  PR:		245452
  Approved by:	maintainer

Changes:
  head/net-im/telegram-desktop/Makefile
Comment 11 Roman Bogorodskiy freebsd_committer freebsd_triage 2020-04-11 16:35:17 UTC
Thanks, committed the NO_CCACHE change.

I'm leaving this open until it's properly fixed.
Comment 12 Charlie Li freebsd_committer freebsd_triage 2020-05-07 04:08:12 UTC
I just built 2.1.0 twice successfully with ccache enabled. First run to generate the cached objects, second run hit the cache. All on 13-CURRENT amd64 base r360679.
Comment 13 Roman Bogorodskiy freebsd_committer freebsd_triage 2020-05-07 04:26:48 UTC
(In reply to Charlie Li from comment #12)

I plan a regular ports rebuild closer to the end of this week, hopefully I will not forget to test building telegram-desktop with ccache, probably it was fixed in 2.1.0.
Comment 14 Roman Bogorodskiy freebsd_committer freebsd_triage 2020-05-12 14:58:56 UTC
Created attachment 214417 [details]
remove NO_CCACHE

It builds fine now for me.
Attached a patch to remove NO_CCACHE.
Comment 15 Henry Hu 2020-05-12 23:54:12 UTC
Comment on attachment 214417 [details]
remove NO_CCACHE

As I said above, I have no way of testing this. If it builds fine for you, please remove it.
Comment 16 Charlie Li freebsd_committer freebsd_triage 2020-05-13 00:10:52 UTC
I actually built this again with ccache enabled after the __FreeBSD_version bump, and along with me updating x11-toolkits/pango locally to 1.44.7, hit the error again. Updated this locally to 2.1.4, also with ccache enabled, and the build succeeded but as it was a cache-populating run, it doesn't mean too much. So it seems like enabling ccache here is sensitive to changes/updates in dependent libraries, and probably the best cure is to keep up with telegram-desktop's rather rapid releases.
Comment 17 Charlie Li freebsd_committer freebsd_triage 2020-07-02 22:14:13 UTC
After hitting this problem with audio/audacity (which now uses cmake), this is almost entirely a ccache implementation defect. What we're dealing with is how clang handles precompiled headers, which is a bit different than how gcc does it.

Some upstream threads for context:
https://gitlab.kitware.com/cmake/cmake/-/merge_requests/4400
https://github.com/ccache/ccache/issues/539
https://github.com/ccache/ccache/issues/549

With regard to PCHs in ccache generally, ccache(1) has a dedicated section describing how to make it process PCHs properly (because it doesn't by default). Quote the part that needs done in ccache.conf:

   ccache has support for GCC's precompiled headers. However, you have to
   do some things to make it work properly:

   o   You must set sloppiness to pch_defines,time_macros. The reason is
       that ccache can't tell whether __TIME__ or __DATE__ is used when
       using a precompiled header. Further, it can't detect changes in
       #defines in the source code because of how preprocessing works in
       combination with precompiled headers.

Once added, at least on my -CURRENT setup where base LLVM got updated since I last built and cached this port, the error message changes to:

error: PCH file built from a different branch ((git@github.com:llvm/llvm-project.git llvmorg-10.0.0-129-gd24d5c8e308)) than the comp
iler ((git@github.com:llvm/llvm-project.git llvmorg-10.0.1-rc2-0-g77d76b71d7d))

Further tests will need done to find other error messages, ie when base LLVM stays the same.
Comment 18 Gleb Smirnoff freebsd_committer freebsd_triage 2021-11-18 03:44:57 UTC
NO_CCACHE remains in the port with reference to this bug for details