Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Build failure: sioyek on darwin (issue in QT dependencies?) #366069

Closed
b-fein opened this issue Dec 18, 2024 · 3 comments
Closed

Build failure: sioyek on darwin (issue in QT dependencies?) #366069

b-fein opened this issue Dec 18, 2024 · 3 comments
Labels
0.kind: build failure A package fails to build 6.topic: darwin Running or building packages on Darwin

Comments

@b-fein
Copy link
Contributor

b-fein commented Dec 18, 2024

Steps To Reproduce

Steps to reproduce the behavior:

  1. build sioyek

Build log

Build Log
       > /nix/store/l8n4jk7l60yb7jag3i17bz57s7rvf0rd-clang-wrapper-16.0.6/bin/clang++ -stdlib=libc++ -headerpad_max_install_names  -arch arm64 -isysroot /nix/store/bbwmxj5wv6nh3cydiyijp80zn30q5svf-apple-sdk-11.3/Platforms/MacOSX.platform/Developer/SDKs/MacOSX11.3.sdk -mmacosx-version-min=11 -o sioyek.app/Contents/MacOS/sioyek  TouchSlider.o TouchCheckbox.o TouchListView.o TouchCopyOptions.o TouchRectangleSelectUI.o TouchRangeSelectUI.o TouchPageSelector.o TouchConfigMenu.o TouchTextEdit.o TouchSearchButtons.o TouchDeleteButton.o TouchHighlightButtons.o TouchSettings.o TouchAudioButtons.o TouchMarkSelector.o TouchDrawControls.o TouchMacroEditor.o TouchGenericButtons.o TouchMainMenu.o book.o config.o database.o document.o document_view.o input.o main.o main_widget.o pdf_renderer.o pdf_view_opengl_widget.o checksum.o new_file_checker.o coordinates.o sqlite3.o ui.o path.o utils.o mysortfilterproxymodel.o RunGuard.o OpenWithApplication.o fzf.o synctex_parser.o synctex_parser_utils.o macos_specific.o qrc_resources.o moc_TouchSlider.o moc_TouchCheckbox.o moc_TouchListView.o moc_TouchCopyOptions.o moc_TouchRectangleSelectUI.o moc_TouchRangeSelectUI.o moc_TouchPageSelector.o moc_TouchConfigMenu.o moc_TouchTextEdit.o moc_TouchSearchButtons.o moc_TouchDeleteButton.o moc_TouchHighlightButtons.o moc_TouchSettings.o moc_TouchAudioButtons.o moc_TouchMarkSelector.o moc_TouchDrawControls.o moc_TouchMacroEditor.o moc_TouchGenericButtons.o moc_TouchMainMenu.o moc_main_widget.o moc_pdf_renderer.o moc_ui.o moc_mysortfilterproxymodel.o moc_RunGuard.o moc_OpenWithApplication.o   -F/nix/store/y49q5fdmygz3jpwzxlrh0khqismcx89q-qtdeclarative-6.8.0/lib -F/nix/store/3la8b8fg6s9awj2adhqm1zvcq7v6jyyv-qtbase-6.8.0/lib -F/nix/store/sxnj63iybx2307i0mha8qm7yrn8n7kbm-qt3d-6.8.0/lib -F/nix/store/a2bdag3c252mn9ayny15c78991n2q26i-qtsvg-6.8.0/lib -F/nix/store/mb907xjzb0y16720qbj4a9aw4hsxpl8d-qtspeech-6.8.0/lib -F/nix/store/azzryfg5p4hfrpp2f33xr9zfa8lp4zcv-qtmultimedia-6.8.0/lib -ldl -L/private/tmp/nix-build-sioyek-2.0.0-unstable-2024-09-29.drv-0/source/mupdf/build/release -lmupdf -lgumbo -lharfbuzz -lfreetype -ljbig2dec -ljpeg -lopenjp2 -lz -framework QtQuickWidgets -framework QtQuick -framework QtOpenGLWidgets -framework QtOpenGL -framework QtWidgets -framework Qt3DInput -framework Qt3DCore -framework QtSvg -framework QtTextToSpeech -l/nix/store/azzryfg5p4hfrpp2f33xr9zfa8lp4zcv-qtmultimedia-6.8.0/lib/QtMultimedia.framework/Versions/A/QtMultimedia -framework QtMultimedia -framework QtGui -framework AppKit -framework ImageIO -framework Metal -framework QtQmlMeta -framework QtQmlModels -framework QtQmlWorkerScript -framework QtQml -framework QtNetwork -framework QtConcurrent -framework QtCore -framework IOKit -framework DiskArbitration -framework UniformTypeIdentifiers -framework AGL -framework OpenGL
       > ld: warning: directory not found for option '-L/private/tmp/nix-build-sioyek-2.0.0-unstable-2024-09-29.drv-0/source/mupdf/build/release'
       > ld: library not found for -l/nix/store/azzryfg5p4hfrpp2f33xr9zfa8lp4zcv-qtmultimedia-6.8.0/lib/QtMultimedia.framework/Versions/A/QtMultimedia

Additional context

In #348045 there already has been some investigation regarding this issue. The Qmake project files for QtSpeech seem to pull in QtMultimedia for linking with an unnecessary -l argument.

#348045 (comment) (@booxter)

The immediate failure comes from the fact that the QtMultimedia framework is passed as: -l/nix/store/nc8h7dspiyybxfd03g2iysnnr3iycc8j-qtmultimedia-6.8.0/lib/QtMultimedia.framework/Versions/A/QtMultimedia -framework QtMultimedia and I think only the -framework is needed (I was able to link the file once I remove the -l argument from Makefile).

I think this -l argument comes from /nix/store/5sb3jk5jagkx0lhj0szi1xj19scmgcbr-qtspeech-6.8.0/lib/QtTextToSpeech.framework/Resources/QtTextToSpeech.prl or some other prl file

[…] Someone with some knowledge around qmake may have some insight...

Metadata

  • system: "aarch64-darwin"
  • host os: Darwin 24.2.0, macOS 15.2
  • multi-user?: yes
  • sandbox: no
  • version: nix-env (Nix) 2.24.10
  • nixpkgs: /nix/store/g9bw874w67bfsvg93szwnxxjxp4lphby-source

Notify maintainers

@xyven1 @stephen-huan


Note for maintainers: Please tag this issue in your PR.


Add a 👍 reaction to issues you find important.

@b-fein b-fein added the 0.kind: build failure A package fails to build label Dec 18, 2024
@SigmaSquadron SigmaSquadron added the 6.topic: darwin Running or building packages on Darwin label Dec 18, 2024
pitkling added a commit to pitkling/nixpkgs that referenced this issue Dec 21, 2024
Fixes issue NixOS#366069 (broken sioyek darwin build) by adapting an upstream change when Qt was updated from 6.7.2 to 6.7.3 in PR NixOS#344928. MIght fix other similar issues (e.g., for packages depending on `qt6.qtspeech`).

Not sure whether this just shadows a deeper underlying problem (already present before).

# Details

(Note: Take the following with a grain of salt, as I've not much experience with cmake/qmake/Qt.)

[This upstream commit](qt/qtbase@ea0f00d) changed how Qt treats linker flags without a suffix (like `.so`) when generating `.pri`/`.prl` files. Until 6.7.2, a linker flag like `ws2_32` was left untouched. The above commit changed it such that such flags are converted to `-lws2_32` (seemingly in order to better support FFmpeg, according to the commit message).

Now, nixpkgs on darwin links some libraries, like `QtMultimedia` via framwork paths like `/nix/store/wmm6s68wk9ygg84ibzdf95yp22lcg4ay-qtmultimedia-6.7.3/lib/QtMultimedia.framework/Versions/A/QtMultimedia`. As long as these are part of the current build dir or of Qt's `$prefix/lib` dir, they [are recognized as frameworks](https://github.com/qt/qtbase/blob/b839e9b36db3a4e50dfb34521d8ef8de1fd01969/cmake/QtFinishPrlFile.cmake#L48-L53) and handled accordingly. This works, e.g., for something like `/nix/store/rdjd1nqlr1ncr4616dcyqdf6ymqy82xc-qtbase-6.7.3/lib/QtGui.framework/Versions/A/QtGui` since it is part of `qt6.qtbase`.

However, QtMultimedia is not part of `qt6.qtbase`, so `/nix/store/wmm6s68wk9ygg84ibzdf95yp22lcg4ay-qtmultimedia-6.7.3/lib/QtMultimedia.framework/Versions/A/QtMultimedia` is not recognized as a framework path and, instead, treated like a [non-Qt library](https://github.com/qt/qtbase/blob/b839e9b36db3a4e50dfb34521d8ef8de1fd01969/cmake/QtFinishPrlFile.cmake#L54-L61). Now, before the [above mentioned upstream commit](qt/qtbase@ea0f00d), the linker flag was handed over to `clang++` unchanged. After the upstream commit, it is transformed into `-l/nix/store/wmm6s68wk9ygg84ibzdf95yp22lcg4ay-qtmultimedia-6.7.3/lib/QtMultimedia.framework/Versions/A/QtMultimedia`, which causes a linker error (since it's a directory and not a library).

This commit adds a patch that slightly adapts the [upstream commit](qt/qtbase@ea0f00d). Namely, it only prepends flags without a suffix (like `ws2_32`) with an `-l` if they are not given as an absolute path.

# Additional Remarks

WIth this fix, the generated `prl` files look again exactly as before the update from Qt 6.7.2 to 6.7.3 and linking of packages like sioyek works again. However, I'm not sure whether this is actually the correct way to fix the issue.

It seems to me that instead of handing `/nix/store/wmm6s68wk9ygg84ibzdf95yp22lcg4ay-qtmultimedia-6.7.3/lib/QtMultimedia.framework/Versions/A/QtMultimedia` through to `clang++`, it should be converted into `-framework QtMultimedia` (with a suitable `-F …` flag). In fact,  somehow these flags do end up in the actual linker command, not sure how though. Also, I am surprised that `clang++` does not choke on getting simply a directory as an argument.
@pitkling
Copy link
Member

pitkling commented Dec 21, 2024

I investigated this and found what's causing the problematic -l argument in /nix/store/5sb3jk5jagkx0lhj0szi1xj19scmgcbr-qtspeech-6.8.0/lib/QtTextToSpeech.framework/Resources/QtTextToSpeech.prl. See my draft PR #367206 for details and a potential fix.

@pitkling
Copy link
Member

The PR with the fix got merged and is currently in staging (status) and backported to staging-24.11 (status), so I'm closing this.

@b-fein
Copy link
Contributor Author

b-fein commented Dec 31, 2024

Thank you!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
0.kind: build failure A package fails to build 6.topic: darwin Running or building packages on Darwin
Projects
None yet
Development

No branches or pull requests

3 participants