-
Notifications
You must be signed in to change notification settings - Fork 100
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
Add libvips version number to shared library SONAME and filename #252
Conversation
This should help improve support for multiple versions of sharp that use multiple versions of libvips running within the same process by ensuring dlopen accesses the relevant shared library.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM! Tested with:
Details
$ readelf -d node_modules/@img/sharp-libvips-linux-x64/lib/libvips-cpp.so.42 | grep SONAME
0x000000000000000e (SONAME) Library soname: [libvips-cpp.so.42]
$ patchelf --set-soname libvips-cpp.so.8.15.2 node_modules/@img/sharp-libvips-linux-x64/lib/libvips-cpp.so.42
$ mv node_modules/@img/sharp-libvips-linux-x64/lib/libvips-cpp.so.42 node_modules/@img/sharp-libvips-linux-x64/lib/libvips-cpp.so.8.15.2
$ readelf -d node_modules/@img/sharp-libvips-linux-x64/lib/libvips-cpp.so.8.15.2 | grep SONAME
0x000000000000000e (SONAME) Library soname: [libvips-cpp.so.8.15.2]
$ readelf -d node_modules/@img/sharp-linux-x64/lib/sharp-linux-x64.node | grep libvips-cpp.so
0x0000000000000001 (NEEDED) Shared library: [libvips-cpp.so.42]
$ patchelf --replace-needed libvips-cpp.so.42 libvips-cpp.so.8.15.2 node_modules/@img/sharp-linux-x64/lib/sharp-linux-x64.node
$ node index
8.15.2
{ semver: '8.15.2', isGlobal: false, isWasm: false }
$ LD_DEBUG=libs node index 2>&1 | grep "libvips-cpp.so"
10200: find library=libvips-cpp.so.42 [0]; searching
10200: trying file=/redacted/node_modules/fast-average-color-node/node_modules/@img/sharp-linux-x64/lib/../../sharp-libvips-linux-x64/lib/glibc-hwcaps/x86-64-v4/libvips-cpp.so.42
10200: trying file=/redacted/node_modules/fast-average-color-node/node_modules/@img/sharp-linux-x64/lib/../../sharp-libvips-linux-x64/lib/glibc-hwcaps/x86-64-v3/libvips-cpp.so.42
10200: trying file=/redacted/node_modules/fast-average-color-node/node_modules/@img/sharp-linux-x64/lib/../../sharp-libvips-linux-x64/lib/glibc-hwcaps/x86-64-v2/libvips-cpp.so.42
10200: trying file=/redacted/node_modules/fast-average-color-node/node_modules/@img/sharp-linux-x64/lib/../../sharp-libvips-linux-x64/lib/libvips-cpp.so.42
10200: calling init: /redacted/node_modules/fast-average-color-node/node_modules/@img/sharp-linux-x64/lib/../../sharp-libvips-linux-x64/lib/libvips-cpp.so.42
10200: find library=libvips-cpp.so.8.15.2 [0]; searching
10200: trying file=/redacted/node_modules/@img/sharp-linux-x64/lib/../../sharp-libvips-linux-x64/lib/glibc-hwcaps/x86-64-v4/libvips-cpp.so.8.15.2
10200: trying file=/redacted/node_modules/@img/sharp-linux-x64/lib/../../sharp-libvips-linux-x64/lib/glibc-hwcaps/x86-64-v3/libvips-cpp.so.8.15.2
10200: trying file=/redacted/node_modules/@img/sharp-linux-x64/lib/../../sharp-libvips-linux-x64/lib/glibc-hwcaps/x86-64-v2/libvips-cpp.so.8.15.2
10200: trying file=/redacted/node_modules/@img/sharp-linux-x64/lib/../../sharp-libvips-linux-x64/lib/libvips-cpp.so.8.15.2
10200: calling init: /redacted/node_modules/@img/sharp-linux-x64/lib/../../sharp-libvips-linux-x64/lib/libvips-cpp.so.8.15.2
10200: calling fini: /redacted/node_modules/fast-average-color-node/node_modules/@img/sharp-linux-x64/lib/../../sharp-libvips-linux-x64/lib/libvips-cpp.so.42 [0]
10200: calling fini: /redacted/node_modules/@img/sharp-linux-x64/lib/../../sharp-libvips-linux-x64/lib/libvips-cpp.so.8.15.2 [0]
Of course, running two (or more) instances of libvips in the same process might degrade performance, but that might be better than having version mismatches.
Note that I'm unsure if we should apply the same approach to Windows builds, as these C++ DLLs are also used by projects other than sharp.
Thanks Kleis, I agree we should not apply this to the Windows builds. (For sharp the C++ DLL is built/named via gyp.) |
…ame (lovell#252)" This reverts commit 1210419.
This should help improve support for multiple versions of sharp that use differing versions of libvips running within the same process by ensuring
dlopen
accesses the relevant shared library.Before:
After:
Relates to lovell/sharp#4095