--- a/glib/meson.build
+++ b/glib/meson.build
@@ -366,6 +366,7 @@ pcre2_static_args = []
 
 if use_pcre2_static_flag
   pcre2_static_args = ['-DPCRE2_STATIC']
+  pcre2 = pcre2.as_link_whole()
 endif
 
 glib_c_args = ['-DG_LOG_DOMAIN="GLib"', '-DGLIB_COMPILATION'] + pcre2_static_args + glib_hidden_visibility_args
