Link the main library with -Wl,-z,nodelete to prevent unloading (#2934)

See: https://github.com/libvips/php-vips-ext/pull/44
This commit is contained in:
Kleis Auke Wolthuizen 2022-07-20 11:20:09 +02:00 committed by GitHub
parent 57fff0fe2b
commit fa6c034b32
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 17 additions and 0 deletions

View File

@ -457,6 +457,20 @@ else
fi
fi
SAVE_LDFLAGS="$LDFLAGS"
LDFLAGS="$LDFLAGS -Wl,-z,nodelete"
AC_MSG_CHECKING([whether linker understands -z nodelete])
AC_LINK_IFELSE([AC_LANG_PROGRAM([], [])],
[
AC_MSG_RESULT([yes])
LDFLAGS_Z_NODELETE="-Wl,-z,nodelete"
],[
AC_MSG_RESULT([no])
LDFLAGS_Z_NODELETE=""
])
LDFLAGS="$SAVE_LDFLAGS"
AC_SUBST(LDFLAGS_Z_NODELETE)
# check for gtk-doc
GTK_DOC_CHECK([1.14],[--flavour no-tmpl])

View File

@ -58,6 +58,7 @@ libvips_la_LIBADD = \
@VIPS_LIBS@
libvips_la_LDFLAGS = \
$(LDFLAGS_Z_NODELETE) \
-no-undefined \
-version-info @LIBRARY_CURRENT@:@LIBRARY_REVISION@:@LIBRARY_AGE@

View File

@ -26,6 +26,7 @@ libvips_lib = library('vips',
darwin_versions: darwin_versions,
gnu_symbol_visibility: 'hidden',
install: true,
link_args: nodelete_link_args,
)
libvips_dep = declare_dependency(

View File

@ -67,6 +67,7 @@ libvips_deps = [
thread_dep,
m_dep,
]
nodelete_link_args = cc.get_supported_link_arguments('-Wl,-z,nodelete')
prefix_dir = get_option('prefix')
lib_dir = prefix_dir / get_option('libdir')