Fix msys2 dll paths in GdkPixbuf loaders.cache gen #7842
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
When compiling a program that depends on GTK and GdkPixbuf loaders in msys2 Windows, the loaders.cache generates dlls with an absolute path that is local to the machine it was generated on.
When the resulting compiled program is run on another Windows machine, the local paths of the dlls do not exist and the program crashes.
Example loader.cache snippet
The correct output should be
The root cause of the bug lies the libdir variable.
libdir =
C:/tools/msys64/mingw64/bin
The GdkPixbuf hook generates a loaders.cache file with absolute paths and uses prefix matching to replace the dll paths with relative paths that the program can find. However, this will match none of the prefixes and therefore, the absolute path will not be changed to the relative path in the loaders.cache.
In the code example below, we see that it will try to match the following prefixes:
prefix =
"C:/tools/msys64/mingw64/bin/gdk-pixbuf-2.0/2.10.0
win_prefix
"\\lib\\gdk-pixbuf-2.0\\2.10.0
This will not work given the line from cachedata
"C:/tools/msys64/mingw64/bin/../lib/gdk-pixbuf-2.0/2.10.0/loaders/libpixbufloader-png.dll"
This fix addresses this by accounting for the dll prefix for msys2.
My solution will simplify the line path to be:
"C:/tools/msys64/mingw64/lib/gdk-pixbuf-2.0/2.10.0/loaders/libpixbufloader-png.dll"
which will match my new prefix:
msys2_prefix =
"C:/tools/msys64/mingw64/lib/gdk-pixbuf-2.0/2.10.0
And convert the line to be:
line =
"lib\\gdk-pixbuf\\loaders\\libpixbufloader-png.dll"
fixes #7838