musescore / MuseScore

MuseScore is an open source and free music notation software. For support, contribution, bug reports, visit MuseScore.org. Fork and make pull requests!
https://musescore.org
Other
12.29k stars 2.66k forks source link

Link failure against Qt 6.7.2 on Manjaro Linux #24067

Closed kbloom closed 2 months ago

kbloom commented 2 months ago

Issue type

Other type of issue

Description with steps to reproduce

I'm trying to build Musescore 4.4.0 branch (commit 341aa511357688c581b7cf40b6e7ff6ad0fd703e) against my system Qt 6.7.2 on Manjaro linux.

To build, I ran ./ninja_build.sh

The build is failing with

[37/38] Linking CXX executable src/app/mscore
FAILED: src/app/mscore 
: && /usr/bin/c++ -O2  src/app/CMakeFiles/mscore.dir/mscore_autogen/mocs_compilation.cpp.o src/app/CMakeFiles/mscore.dir/qrc_app.cpp.o src/app/CMakeFiles/mscore.dir/main.cpp.o src/app/CMakeFiles/mscore.dir/appfactory.cpp.o src/app/CMakeFiles/mscore.dir/internal/commandlineparser.cpp.o src/app/CMakeFiles/mscore.dir/internal/consoleapp.cpp.o src/app/CMakeFiles/mscore.dir/internal/guiapp.cpp.o -o src/app/mscore  -Wl,-rpath,::::::::  src/framework/global/libmuse_global.a  src/framework/draw/libmuse_draw.a  src/framework/network/libmuse_network.a  src/braille/libbraille.a  src/framework/diagnostics/libmuse_diagnostics.a  src/engraving/libengraving.a  src/framework/actions/libmuse_actions.a  src/framework/accessibility/libmuse_accessibility.a  src/context/libcontext.a  src/framework/shortcuts/libmuse_shortcuts.a  src/framework/workspace/libmuse_workspace.a  src/workspacescene/libworkspacescene.a  src/framework/audio/libmuse_audio.a  src/framework/mpe/libmuse_mpe.a  src/framework/midi/libmuse_midi.a  src/framework/learn/libmuse_learn.a  src/notation/libnotation.a  src/project/libproject.a  src/print/libprint.a  src/commonscene/libcommonscene.a  src/palette/libpalette.a  src/inspector/libinspector.a  src/playback/libplayback.a  src/instrumentsscene/libinstrumentsscene.a  src/framework/stubs/vst/libmuse_vst.a  src/framework/update/libmuse_update.a  src/framework/ui/libmuse_ui.a  src/framework/uicomponents/libmuse_uicomponents.a  src/framework/dockwindow/libmuse_dockwindow.a  src/framework/audioplugins/libmuse_audioplugins.a  src/converter/libconverter.a  src/appshell/libappshell.a  src/framework/cloud/libmuse_cloud.a  src/framework/languages/libmuse_languages.a  src/framework/multiinstances/libmuse_multiinstances.a  src/framework/extensions/libmuse_extensions.a  src/importexport/musicxml/libiex_musicxml.a  src/importexport/bb/libiex_bb.a  src/importexport/bww/libiex_bww.a  src/importexport/capella/libiex_capella.a  src/importexport/guitarpro/libiex_guitarpro.a  src/importexport/midi/libiex_midi.a  src/importexport/musedata/libiex_musedata.a  src/importexport/ove/libiex_ove.a  src/importexport/audioexport/libiex_audioexport.a  src/importexport/imagesexport/libiex_imagesexport.a  src/importexport/mei/libiex_mei.a  src/framework/autobot/libmuse_autobot.a  src/framework/musesampler/libmuse_musesampler.a  src/braille/thirdparty/liblouis/libliblouis.a  src/framework/diagnostics/google_crashpad_client/libgcrashpad.a  src/framework/audio/fluidsynth/libfluidsynth.a  /usr/lib/libsndfile.so.1.0.37  src/framework/audio/lame/liblame.a  src/framework/audio/opusenc/libopusenc.a  src/framework/audio/opusenc/opus/libopus.a  -lm  src/framework/audio/flac/libflac.a  /usr/lib/libasound.so  -lpthread  src/notation/libnotation.a  src/commonscene/libcommonscene.a  src/framework/ui/libmuse_ui.a  src/framework/uicomponents/libmuse_uicomponents.a  src/framework/dockwindow/libmuse_dockwindow.a  src/framework/dockwindow/thirdparty/KDDockWidgets/src/libkddockwidgets-qt6.a  /usr/lib/libxkbcommon.so  src/importexport/capella/rtf2html/librtf2html.a  src/importexport/midi/beatroot/libbeatroot.a  src/engraving/libengraving.a  src/framework/draw/libmuse_draw.a  src/framework/draw/freetype/libfreetype.a  src/framework/draw/_deps/harfbuzz/harfbuzz/libharfbuzz.a  src/framework/global/libmuse_global.a  /usr/lib/libQt6NetworkAuth.so.6.7.2  /usr/lib/libQt6QuickControls2.so.6.7.2  /usr/lib/libQt6QuickTemplates2.so.6.7.2  /usr/lib/libQt6QuickWidgets.so.6.7.2  /usr/lib/libQt6Quick.so.6.7.2  /usr/lib/libQt6QmlModels.so.6.7.2  /usr/lib/libQt6Qml.so.6.7.2  /usr/lib/libQt6Network.so.6.7.2  /usr/lib/libQt6QmlBuiltins.a  /usr/lib/libQt6Xml.so.6.7.2  /usr/lib/libQt6Svg.so.6.7.2  /usr/lib/libQt6PrintSupport.so.6.7.2  /usr/lib/libQt6Widgets.so.6.7.2  /usr/lib/libQt6OpenGL.so.6.7.2  /usr/lib/libQt6Core5Compat.so.6.7.2  /usr/lib/libQt6StateMachine.so.6.7.2  /usr/lib/libQt6Gui.so.6.7.2  /usr/lib/libGLX.so  /usr/lib/libOpenGL.so  /usr/lib/libQt6Concurrent.so.6.7.2  /usr/lib/libQt6DBus.so.6.7.2  /usr/lib/libQt6Core.so.6.7.2  -lz  -ldl && :
/usr/bin/ld: src/engraving/libengraving.a(qrc_fonts_Tabulature.o): copy relocation against non-copyable protected symbol `qt_resourceFeatureZstd@@Qt_6' in /usr/lib/libQt6Core.so.6.7.2
collect2: error: ld returned 1 exit status
ninja: build stopped: subcommand failed.
Build failed

Any idea what's wrong?

Supporting files, videos and screenshots

None

What is the latest version of MuseScore Studio where this issue is present?

Git 4.4.0 branch

Regression

I was unable to check

Operating system

Manjaro Linux

Additional context

No response

Checklist

kbloom commented 2 months ago

I'm really interested in testing whether newer versions of QT can fix issue #15285, but if I can't build against newer versions of Qt, then I can't test it.

Also, I'm generally interested in having my apps run on Qt 6.7 or later, because if my Wayland compositor crashes and restarts, Qt 6.7 apps can survive that and keep running.

kbloom commented 2 months ago

https://github.com/musescore/MuseScore/issues/15285#issuecomment-2206877590 has some relevant information about building against Qt 6.7. I'm not sure if any of that helps with this linker issue, and I haven't tried to figure out how to translate that from Nix to non-Nix yet.

cbjeukendrup commented 2 months ago

As far as I can see, those patches have already been applied (well, a variation).

That's quite a cryptic error, it doesn't ring a bell to me. I entered it into Google and found this, which looks very similar: https://gitlab.manjaro.org/applications/calamares/-/issues/87

One of the links there suggests that position independent code needs to be enabled. However instead of using the solution from there, I would suggest using the -fPIC compiler option, in our SetupBuildEnvironment.cmake file.

I wonder though why this would necessary for your system and apparently not for some other people. Maybe -fPIC is on by default on most compilers and not on yours somehow?

kbloom commented 2 months ago

That did it! Thanks.

cbjeukendrup commented 2 months ago

However instead of using the solution from there, I would suggest using the -fPIC compiler option, in our SetupBuildEnvironment.cmake file.

I did some further research about this, and it turns out that I wasn't right here; using the target property in CMake, or setting CMAKE_POSITION_INDEPENDENT_CODE globally, seems actually the preferred way.

thegreyshadow commented 2 months ago

Confirmed on Slackware64-current. I'm awaiting a new release to upgrade from 4.3x

tstibor commented 2 weeks ago

Just checked the Musescore ARCH Linux PKGBUILD

build() {
  cmake -S MuseScore -B build -G Ninja \
    -DCMAKE_BUILD_TYPE=None \
    -DCMAKE_C_FLAGS_RELEASE="$CFLAGS" \
    -DCMAKE_CXX_FLAGS_RELEASE="$CXXFLAGS" \
    -DCMAKE_INSTALL_PREFIX=/usr \
    -DCMAKE_POSITION_INDEPENDENT_CODE=ON \
    -DCMAKE_SKIP_RPATH=ON \
    -DMUSESCORE_APP_BUILD_MODE=release \
    -DMUSESCORE_BUILD_CONFIGURATION=app \
    -DMUSESCORE_REVISION=$(git rev-parse --short=7 HEAD) \
    -DMUE_BUILD_UNIT_TESTS=OFF \
    -DMUE_COMPILE_USE_SYSTEM_FLAC=ON \
    -DMUE_COMPILE_USE_SYSTEM_FREETYPE=ON \
    -DMUE_COMPILE_USE_SYSTEM_HARFBUZZ=ON \
    -DMUE_COMPILE_USE_SYSTEM_OPUS=ON \
    -DMUE_COMPILE_USE_SYSTEM_OPUSENC=ON \
    -DMUE_COMPILE_USE_SYSTEM_TINYXML=ON \
    -DMUE_ENABLE_FILE_ASSOCIATION=ON \
    -DMUE_INSTALL_SOUNDFONT=ON \
    -Wno-dev
  cmake --build build
}

Probably it makes sense to add the CMAKE_POSITION_INDEPENDENT_CODE=ON persistently in CMakeLists.txt?

cbjeukendrup commented 2 weeks ago

It might, but I'm not sure how desirable it is to set such options in CMakeLists, because obviously it removes the possibility to set a value on the command line, which may be the purpose of such CMake options.

Also, it would be great if we could find a bit more precisely why this would be necessary, and why for us and not for other projects, etc..