Xpra-org / gtk-osx-build

Build setup to help building the Mac OS X port of GTK+
http://gtk-osx.sourceforge.net/
0 stars 2 forks source link

update to libjpeg-turbo 2.x #19

Closed totaam closed 7 months ago

totaam commented 3 years ago

Not so easy:

Then hit the same issues as https://github.com/Xpra-org/gtk-osx-build/issues/2#issuecomment-765494560:

Cannot find a matching prefix for @rpath/libjpeg.62.dylib
Cannot find a matching prefix for @rpath/libjpeg.62.dylib
Cannot find a matching prefix for @rpath/libjpeg.62.dylib
Cannot find a matching prefix for @rpath/libturbojpeg.0.dylib
Cannot find a matching prefix for @rpath/libjpeg.62.dylib
Cannot find a matching prefix for @rpath/libturbojpeg.0.dylib
Cannot find a matching prefix for @rpath/libjpeg.62.dylib
Cannot find a matching prefix for @rpath/libjpeg.62.dylib
Cannot find a matching prefix for @rpath/libjpeg.62.dylib
Cannot find a matching prefix for @rpath/libturbojpeg.0.dylib
Cannot find a matching prefix for @rpath/libjpeg.62.dylib
Cannot find a matching prefix for @rpath/libturbojpeg.0.dylib
Cannot find a matching prefix for @rpath/libjpeg.62.dylib
Cannot find a matching prefix for @rpath/libjpeg.62.dylib
Cannot find a matching prefix for @rpath/libjpeg.62.dylib
Cannot find a matching prefix for @rpath/libturbojpeg.0.dylib
Cannot find a matching prefix for @rpath/libjpeg.62.dylib
Cannot find a matching prefix for @rpath/libturbojpeg.0.dylib
sh: gtk-query-immodules-2.0: command not found
g_module_open() failed for image/.Xpra.app/Contents/Resources/lib/gdk-pixbuf-2.0/2.10.0/loaders/libpixbufloader-jpeg.so: dlopen(image/.Xpra.app/Contents/Resources/lib/gdk-pixbuf-2.0/2.10.0/loaders/libpixbufloader-jpeg.so, 10): Library not loaded: @rpath/libjpeg.62.dylib
  Referenced from: /Users/macos/xpra/packaging/MacOS/image/.Xpra.app/Contents/Resources/lib/gdk-pixbuf-2.0/2.10.0/loaders/libpixbufloader-jpeg.so
  Reason: image not found
g_module_open() failed for image/.Xpra.app/Contents/Resources/lib/gdk-pixbuf-2.0/2.10.0/loaders/libpixbufloader-tiff.so: dlopen(image/.Xpra.app/Contents/Resources/lib/gdk-pixbuf-2.0/2.10.0/loaders/libpixbufloader-tiff.so, 10): Library not loaded: @rpath/libjpeg.62.dylib
  Referenced from: /Users/macos/gtk/inst/lib/libtiff.5.dylib
  Reason: image not found
Running install name tool
totaam commented 3 years ago

And the problem comes from:

$ otool -L $JHBUILD_PREFIX/lib/libjpeg.62.3.0.dylib 
$JHBUILD_PREFIX/lib/libjpeg.62.3.0.dylib:
    @rpath/libjpeg.62.dylib (compatibility version 62.0.0, current version 62.3.0)
    /usr/lib/libSystem.B.dylib (compatibility version 1.0.0, current version 1281.0.0)
$ otool -L $JHBUILD_PREFIX/lib/libturbojpeg.0.2.0.dylib 
$JHBUILD_PREFIX/lib/libturbojpeg.0.2.0.dylib:
    @rpath/libturbojpeg.0.dylib (compatibility version 0.0.0, current version 0.2.0)
    /usr/lib/libSystem.B.dylib (compatibility version 1.0.0, current version 1281.0.0)

Found that I can set the install name directly without reference to the old install name by passing the -id flag. So this can be fixed with:

install_name_tool -id "$JHBUILD_PREFIX/lib/libjpeg.62.dylib" $JHBUILD_PREFIX/lib/libjpeg.62.3.0.dylib
install_name_tool -id "$JHBUILD_PREFIX/lib/libturbojpeg.0.dylib" $JHBUILD_PREFIX/lib/libturbojpeg.0.2.0.dylib

Then rebuild any library that linked with the broken id. (ie: libtiff, libwebp, gdk-pixbuf, gstreamer, etc)


There must be a way to tell cmake to use this path instead of injecting rpath in there. Which would be a much better solution than patching things up afterwards.

totaam commented 2 years ago

Bumped to 2.1.2 in 66f0aa33baa2a498381865d96658157e1854fe0e

No rush to upgrade to 3.0.x which may well cause us some new problems!

totaam commented 2 years ago

Still had to manually fix things with install_name_tool for libjpeg-turbo 2.1.4 : cc8463d2b9d0674e80cd35048ab4dce064433aa0

totaam commented 1 year ago

Bumped to 2.1.5.1 in b57ba2e9c7abc9a1ffcebeb4b5e4d34c8f9264b3

totaam commented 1 year ago

After a lot of trial and error, well, mostly errors: cc47e60e660714bc8f3335c43d4f44bcf8ef3ea5, 70cd71ba87756eddc340e7cd22494ae1b86d09f5.

These magic incantations override the default cmakeargs and the resulting libjpeg.62.dylib has the correct paths: e0ce1f51d54ba55357f703b1c1229e10381a30f1 + 321c427162f50db74fdb2cd3565f5b64a2c621e7

$ otool -L ${JHBUILD_PREFIX}/lib/libjpeg.62.3.0.dylib 
/Users/macos/gtk/inst/lib/libjpeg.62.3.0.dylib:
    @rpath/libjpeg.62.dylib (compatibility version 62.0.0, current version 62.3.0)
    /usr/lib/libSystem.B.dylib (compatibility version 1.0.0, current version 1281.0.0)
totaam commented 1 year ago

No it doesn't :disappointed: Still needed:

install_name_tool -id "$JHBUILD_PREFIX/lib/libjpeg.62.dylib" $JHBUILD_PREFIX/lib/libjpeg.62.3.0.dylib
install_name_tool -id "$JHBUILD_PREFIX/lib/libturbojpeg.0.dylib" $JHBUILD_PREFIX/lib/libturbojpeg.0.2.0.dylib
totaam commented 1 year ago

Looks finally fixed thanks to CMAKE_MACOSX_RPATH=true in de72485ffc3c204df5cf7e29ad40a57dd582150d.

Recommended reading: Understanding RPATH (With CMake)

This was also causing problems with brotli (which was picked up be freetype if re-building..), now also fixed: 78501f83813125195ee730149fdbfa512439381d

totaam commented 1 year ago

Nope, this might have worked for packaging thanks to rpath support in gtk-mac-bundler but this now causes problems earlier when building gdk-pixbuf... :sob:

totaam commented 10 months ago

Bumped to 3.0.1 in dcc45120f130150077a1d98a12a37e709550342f + fixups in 49dfe00058314959c0d98fd8f1f54df95fd7452b + f0c382ca6a1b83e302114d28aaddc1685fb4e428

The dyld path still needs fixing:

install_name_tool -id "$JHBUILD_PREFIX/lib/libjpeg.62.dylib" $JHBUILD_PREFIX/lib/libjpeg.62.4.0.dylib
install_name_tool -id "$JHBUILD_PREFIX/lib/libturbojpeg.0.dylib" $JHBUILD_PREFIX/lib/libturbojpeg.0.3.0.dylib
totaam commented 8 months ago

Correct solution detailed here: https://github.com/Xpra-org/xpra/issues/4085#issuecomment-1876041460

cpatulea commented 8 months ago

For the rpath issue, I may have found a fix: https://github.com/cpatulea/gtk-osx-build/commit/7841daaf6fc67ee12da813576c78a3f85274a9df

Seems other modules take similar flags: https://github.com/cpatulea/gtk-osx-build/blob/7841daaf6fc67ee12da813576c78a3f85274a9df/jhbuildrc-gtk-osx#L500C1-L500C17

totaam commented 7 months ago

Finally, it works:

$ jhbuild buildone -f libjpeg
(..)
$ jhbuild shell
(..)
$ otool -L $JHBUILD_PREFIX/lib/libjpeg.dylib
/Users/totaam/gtk/inst/lib/libjpeg.dylib:
    /Users/totaam/gtk/inst/lib/libjpeg.62.dylib (compatibility version 62.0.0, current version 62.4.0)
    /usr/lib/libSystem.B.dylib (compatibility version 1.0.0, current version 1319.100.3)

Thanks @cpatulea !