m-ab-s / media-autobuild_suite

This Windows Batchscript helps setup a Mingw-w64 compiler environment for building ffmpeg and other media tools under Windows.
GNU General Public License v3.0
1.52k stars 264 forks source link

Qt5: qmlcachegen.exe: Bad address #1584

Open LigH-de opened 4 years ago

LigH-de commented 4 years ago

Sometimes when compiling a Qt5 project for the first time, one of the projects fails creating cache files. One example:

...
ccache g++ -c -fno-keep-inline-dllexport -O2 -std=c++1z -fno-exceptions -Wall -Wextra -Wextra -Wvla -Wdate-time -Wshift-overflow=2 -Wduplicated-cond -Wno-stringop-overflow -Wno-format-overflow -ffunction-sections -fdata-sections -DUNICODE -D_UNICODE -DWIN32 -DMINGW_HAS_SECURE_API=1 -DWINVER=0x0601 -D_WIN32_WINNT=0x0601 -DQT_NO_LINKED_LIST -DQT_NO_FOREACH -DQT_NO_JAVA_STYLE_ITERATORS -DQT_NO_LINKED_LIST -DQT_NO_CAST_TO_ASCII -DQT_NO_CAST_FROM_ASCII -DQT_NO_NARROWING_CONVERSIONS_IN_CONNECT -DQT_PLUGIN_RESOURCE_INIT_FUNCTION=qtquickcontrols2imaginestyleplugin_plugin_resource_init -DQT_NO_EXCEPTIONS -DQT_NO_DEBUG -DQT_STATICPLUGIN -DQT_PLUGIN -DQT_QUICK_LIB -DQT_GUI_LIB -DQT_QMLMODELS_LIB -DQT_QML_LIB -DQT_NETWORK_LIB -DQT_CORE_LIB -DQT_QUICKTEMPLATES2_LIB -DQT_QUICKCONTROLS2_LIB -DQT_QUICK_LIB -DQT_GUI_LIB -DQT_QMLMODELS_LIB -DQT_QML_LIB -DQT_NETWORK_LIB -DQT_CORE_LIB -I. -isystem E:/MABS/local32/include/QtQuick -isystem E:/MABS/local32/include/QtGui -isystem E:/MABS/local32/include/QtQmlModels -isystem E:/MABS/local32/include/QtQml -isystem E:/MABS/local32/include/QtNetwork -isystem E:/MABS/local32/include/QtCore -I../../../../include/QtQuickTemplates2/5.14.2 -I../../../../include/QtQuickTemplates2/5.14.2/QtQuickTemplates2 -I../../../../include -I../../../../include/QtQuickTemplates2 -I../../../../include/QtQuickControls2/5.14.2 -I../../../../include/QtQuickControls2/5.14.2/QtQuickControls2 -I../../../../include/QtQuickControls2 -isystem E:/MABS/local32/include/QtQuick/5.14.2 -isystem E:/MABS/local32/include/QtQuick/5.14.2/QtQuick -isystem E:/MABS/local32/include/QtGui/5.14.2 -isystem E:/MABS/local32/include/QtGui/5.14.2/QtGui -isystem E:/MABS/local32/include/QtQmlModels/5.14.2 -isystem E:/MABS/local32/include/QtQmlModels/5.14.2/QtQmlModels -isystem E:/MABS/local32/include/QtQml/5.14.2 -isystem E:/MABS/local32/include/QtQml/5.14.2/QtQml -isystem E:/MABS/local32/include/QtCore/5.14.2 -isystem E:/MABS/local32/include/QtCore/5.14.2/QtCore -I.moc/release -IE:/MABS/local32/mkspecs/win32-g++  -o .obj/release/Popup_qml.o .qmlcache/release/Popup_qml.cpp
'E:\MABS\local32\bin\qmlcachegen.exe' --resource-file-mapping=E:/MABS/build/qtquickcontrols2-git/src/imports/controls/imagine/.rcc/release/qmake_QtQuick_Controls_2_Imagine.qrc=E:/MABS/build/qtquickcontrols2-git/src/imports/controls/imagine/.rcc_release_qmake_QtQuick_Controls_2_Imagine_qmlcache.qrc -o .qmlcache/release/qmlcache_loader.cpp .rcc/release/qmake_QtQuick_Controls_2_Imagine.qrc
make[4]: E:\MABS\local32\bin\qmlcachegen.exe: Bad address
make[4]: *** [Makefile.Release:387: .qmlcache/release/qmlcache_loader.cpp] Error 127
make[4]: Leaving directory '/build/qtquickcontrols2-git/src/imports/controls/imagine'
make[3]: *** [Makefile:55: release-install] Error 2
make[3]: Leaving directory '/build/qtquickcontrols2-git/src/imports/controls/imagine'
make[2]: *** [Makefile:194: sub-controls-imagine-imagine-pro-install_subtargets] Error 2
make[2]: Leaving directory '/build/qtquickcontrols2-git/src/imports'
make[1]: *** [Makefile:115: sub-imports-install_subtargets] Error 2
make[1]: Leaving directory '/build/qtquickcontrols2-git/src'
make: *** [Makefile:64: sub-src-install_subtargets] Error 2

logs.zip

You can find this issue reported for MSYS2 in several locations, one is "monero". They made an interesting discovery and created a workaround by including a shell script as source. One suspects the reason in the MinGW version of make.

LigH-de commented 4 years ago

Please advise how to make progress here. I tried mentioning this in #msys2 IRC but got no reply at that time.

1480c1 commented 4 years ago

I'm not sure atm as I haven't had time to test and debug anything, one thing you might want to do if you have time and will power to look at qt stuff is find any mention of qmlcache under the qt folders or under the local folder and look for a file that ends or begins with pf, it's been a while since I looked for it to fix the same error for another qml* program

LigH-de commented 4 years ago

I guess you might mean: local32/mkspecs/features/qmlcache.prf

selsta commented 4 years ago

You can find this issue reported for MSYS2 in several locations, one is "monero".

We weren’t able to properly fix this yet. The workaround does not work in all cases.

1480c1 commented 4 years ago

based on my guesses, the main reason why this occurs is that upstream qt does not consider msys2+mingw-w64 a supported configuration, so they hardcode assumptions for the windows platform

1480c1 commented 4 years ago

Rather they even mislabeled mingw-w64 as MinGW, which can be considered an offense to both projects.

https://doc.qt.io/qt-5/windows.html#supported-configurations

selsta commented 4 years ago

We mostly had this problem with Windows CI. As a workaround we disabled qtquickcompiler: https://github.com/monero-project/monero-gui/pull/2921/

1480c1 commented 4 years ago

Now I wonder if we can do that with qt5 and vlc

NewEraCracker commented 4 years ago

There may be some other workarounds. I'll share what I tried so far and works in other project where I use Qt and I have the same error message

One way: Standalone build of the loader with command below and then re-running the build process

cd build && make -f Makefile.Release compiler_qmlcache_loader_make_all && cd ..

Another way: Add a small delay before calling qmlcachegen

Find in the build\Makefile.Release

release/qmlcache_loader.cpp: ../qml.qrc

Replace:

/C/msys64/mingw64/bin/qmlcachegen.exe

With:

sleep .5 && /C/msys64/mingw64/bin/qmlcachegen.exe
1480c1 commented 4 years ago

Are the makefiles that bad?

Do they not have the target dependencies properly set?

NewEraCracker commented 4 years ago

Seems to be an issue with Qt running on MSYS.

Also as an update, the sleep hack isn't working sometimes either. What I've seen working is either running the failing command manually or doing it through the compiler_qmlcache_loader_make_all task.

LigH-de commented 4 years ago

Maybe some background task in Windows (e.g. Defender or an Explorer extension) blocks access to files just long enough to annoy an MSYS2 task.

1480c1 commented 3 years ago

I think I might have a fix for this, by making qt5 build those tools as static as mentioned https://wiki.qt.io/Building_a_static_Qt_for_Windows_using_MinGW

I think it might be that those tools were loading the wrong dlls

lazka commented 3 years ago

similar error here: https://github.com/msys2/MINGW-packages/issues/7528#issuecomment-751473282 so likely a msys2 runtime bug

export MSYS2_ARG_CONV_EXCL='--resource-file-mapping=' might work around it