From 4a37a27cca34782a213e4ac7773299476a6c294b Mon Sep 17 00:00:00 2001 From: Lovell Fuller Date: Sat, 4 Nov 2023 22:23:01 +0000 Subject: [PATCH] Improve worker thread support by preventing unload on dlclose --- docs/install.md | 13 ------------- src/binding.gyp | 2 +- 2 files changed, 1 insertion(+), 14 deletions(-) diff --git a/docs/install.md b/docs/install.md index 7fb6b1d9..348b99de 100644 --- a/docs/install.md +++ b/docs/install.md @@ -213,19 +213,6 @@ use the `FONTCONFIG_PATH` environment variable to point to a custom location. Embedded SVG fonts are unsupported. -## Worker threads - -On some platforms, including glibc-based Linux, -the main thread must call `require('sharp')` -_before_ worker threads are created. -This is to ensure shared libraries remain loaded in memory -until after all threads are complete. - -Without this, the following error may occur: -``` -Module did not self-register -``` - ## Known conflicts ### Canvas and Windows diff --git a/src/binding.gyp b/src/binding.gyp index b616a02b..93bd5d49 100644 --- a/src/binding.gyp +++ b/src/binding.gyp @@ -170,9 +170,9 @@ '-l:libvips-cpp.so.42' ], 'ldflags': [ - # Ensure runtime linking is relative to sharp.node '-Wl,-s', '-Wl,--disable-new-dtags', + '-Wl,-z,nodelete', '-Wl,-rpath=\'$$ORIGIN/../../sharp-libvips-<(platform_and_arch)/lib\'', '-Wl,-rpath=\'$$ORIGIN/../../../<(sharp_libvips_version)/sharp-libvips-<(platform_and_arch)/lib\'', '-Wl,-rpath=\'$$ORIGIN/../../node_modules/@img/sharp-libvips-<(platform_and_arch)/lib\'',