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

gdk-pixbuf: fix loader.cache on darwin #41559

Merged
merged 3 commits into from Jun 6, 2018
Merged

Conversation

orivej
Copy link
Contributor

@orivej orivej commented Jun 6, 2018

Motivation for this change

gdk-pixbuf-query-loaders looks for .so files even on darwin, but after the switch to meson the loaders are installed with .dylib extension.

Things done
  • Tested using sandboxing (nix.useSandbox on NixOS, or option sandbox in nix.conf on non-NixOS)
  • Built on platform(s)
    • NixOS
    • macOS
    • other Linux distributions
  • Tested via one or more NixOS test(s) if existing and applicable for the change (look inside nixos/tests)
  • Tested compilation of all pkgs that depend on this change using nix-shell -p nox --run "nox-review wip"
  • Tested execution of all binary files (usually in ./result/bin/)
  • Fits CONTRIBUTING.md.

Tested compilation of gdk_pixbuf, gtk2 (reported to fail in #41314).

This reverts commit 6d3b976.

See the next commit.
gdk-pixbuf-query-loaders looks for .so files even on darwin, but after the
switch to meson the loaders are installed with .dylib extension.

Fixes NixOS#41314
@orivej orivej requested review from LnL7 and jtojnar June 6, 2018 10:10
@GrahamcOfBorg GrahamcOfBorg added the 6.topic: darwin Running or building packages on Darwin label Jun 6, 2018
orivej referenced this pull request Jun 6, 2018
Meson produces faulty loaders on Darwin, building them into the library bypasses that.

4b2f397
# Their @rpath has to be replaced before gdk-pixbuf-query-loaders looks at them.
stdenv.lib.optionalString stdenv.isDarwin ''
for f in $out/${passthru.moduleDir}/*.dylib; do
install_name_tool -change @rpath/libgdk_pixbuf-2.0.0.dylib $out/lib/libgdk_pixbuf-2.0.0.dylib $f
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should not the install_name also have so extension?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No, it is a normal lib, not a GLib module, and it was .dylib in gdk-pixbuf-2.36.7.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh, I thought the install_name needs to match the filename.

Copy link
Contributor Author

@orivej orivej Jun 6, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure that you got this right. The old libs looked like this:

/nix/store/bkw80djwwgi868v02nd9xhizbxbj6f22-gdk-pixbuf-2.36.7/lib
├── gdk-pixbuf-2.0
│   └── 2.10.0
│       ├── loaders
…
│       │   ├── libpixbufloader-png.la
│       │   ├── libpixbufloader-png.so
…
│       └── loaders.cache
├── libgdk_pixbuf-2.0.0.dylib
├── libgdk_pixbuf-2.0.dylib -> libgdk_pixbuf-2.0.0.dylib
…

and the new libs look like this:

/nix/store/xr59fg3v6js0kkpbvsdvfn8382fsqqz0-gdk-pixbuf-2.36.12/lib
├── gdk-pixbuf-2.0
│   └── 2.10.0
│       ├── loaders
…
│       │   ├── libpixbufloader-png.dylib (after this PR becomes .so)
…
│       └── loaders.cache
├── libgdk_pixbuf-2.0.0.dylib
├── libgdk_pixbuf-2.0.dylib -> libgdk_pixbuf-2.0.0.dylib
…

install_name_tool updates libpixbufloader-png.dylib et al. to load $out/lib/libgdk_pixbuf-2.0.dylib.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Of course, you are right, I was misreading that.

@orivej
Copy link
Contributor Author

orivej commented Jun 6, 2018

@GrahamcOfBorg eval

@orivej orivej merged commit 57d35bb into NixOS:master Jun 6, 2018
@LnL7
Copy link
Member

LnL7 commented Jun 6, 2018

Was this tested? From my debugging it looked like the meson build was generating invalid loader libraries.

@orivej
Copy link
Contributor Author

orivej commented Jun 6, 2018

Yes, I "built on platform(s): macOS", "tested compilation of gdk_pixbuf, gtk2 (reported to fail in #41314)", and manually checked that loader.cache was empty (except comments) before this PR and now it looks like loader.cache on Linux. The only issue with the meson build that I noticed is .dylib loader extensions unexpected by module loader: https://gitlab.gnome.org/GNOME/gdk-pixbuf/blob/2.36.12/gdk-pixbuf/queryloaders.c#L41, https://developer.gnome.org/glib/stable/glib-Dynamic-Loading-of-Modules.html#G-MODULE-SUFFIX:CAPS

@orivej
Copy link
Contributor Author

orivej commented Jun 6, 2018

This has fixed librsvg: https://hydra.nixos.org/eval/1461585#tabs-now-succeed

@LnL7
Copy link
Member

LnL7 commented Jun 6, 2018

Ok, just wanted to make sure because the loader libraries still look weird. They don't have a LC_ID_DYLIB entry, but it's possible that doesn't matter with dlopen.

$ otool -D /nix/store/46p4pwysjj536xyxb9f61n4c8j7rl54d-gdk-pixbuf-2.36.12/lib/gdk-pixbuf-2.0/2.10.0/loaders/libpixbufloader-png.so
/nix/store/46p4pwysjj536xyxb9f61n4c8j7rl54d-gdk-pixbuf-2.36.12/lib/gdk-pixbuf-2.0/2.10.0/loaders/libpixbufloader-png.so:

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

Successfully merging this pull request may close these issues.

None yet

4 participants