After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 665298 - Add 'Requires.private: libpcre' to glib-2.0.pc
Add 'Requires.private: libpcre' to glib-2.0.pc
Status: RESOLVED FIXED
Product: glib
Classification: Platform
Component: build
unspecified
Other Linux
: Normal normal
: ---
Assigned To: gtkdev
gtkdev
Depends on:
Blocks:
 
 
Reported: 2011-12-01 15:48 UTC by Sam Thursfield
Modified: 2011-12-02 20:10 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
Link to libpcre when static linking (908 bytes, patch)
2011-12-01 15:49 UTC, Sam Thursfield
needs-work Details | Review
Link to libpcre correctly when static linking (794 bytes, patch)
2011-12-01 18:36 UTC, Sam Thursfield
committed Details | Review

Description Sam Thursfield 2011-12-01 15:48:40 UTC
Static linking glib fails when GRegex is used in the program.

Test case:

#include <glib.h>

int main (int argc, char *argv[]) {
	GRegex *regex;
	GError *error = NULL;

	regex = g_regex_new (".",
                             (GRegexCompileFlags)0,
                             (GRegexMatchFlags)0,
                              &error);
	g_assert_no_error (error);
	g_regex_unref (regex);

	return 0;
}

Output:

:~$ g++ -c `pkg-config --static --cflags glib-2.0` glib-test.c -o glib-test.o && g++ -static glib-test.o `pkg-config --static --libs glib-2.0` -o glib-test

/usr/lib/gcc/x86_64-linux-gnu/4.6.1/../../../x86_64-linux-gnu/libglib-2.0.a(gutils.o): In function `g_get_any_init_do':
(.text+0xe35): warning: Using 'getpwuid' in statically linked applications requires at runtime the shared libraries from the glibc version used for linking
/usr/lib/gcc/x86_64-linux-gnu/4.6.1/../../../x86_64-linux-gnu/libglib-2.0.a(gutils.o): In function `g_get_any_init_do':
(.text+0xe29): warning: Using 'setpwent' in statically linked applications requires at runtime the shared libraries from the glibc version used for linking
/usr/lib/gcc/x86_64-linux-gnu/4.6.1/../../../x86_64-linux-gnu/libglib-2.0.a(gutils.o): In function `g_get_any_init_do':
(.text+0xe3f): warning: Using 'endpwent' in statically linked applications requires at runtime the shared libraries from the glibc version used for linking
/usr/lib/gcc/x86_64-linux-gnu/4.6.1/../../../x86_64-linux-gnu/libglib-2.0.a(gutils.o): In function `g_get_any_init_do':
(.text+0xb93): warning: Using 'getpwnam_r' in statically linked applications requires at runtime the shared libraries from the glibc version used for linking
/usr/lib/gcc/x86_64-linux-gnu/4.6.1/../../../x86_64-linux-gnu/libglib-2.0.a(gutils.o): In function `g_get_any_init_do':
(.text+0xbc8): warning: Using 'getpwuid_r' in statically linked applications requires at runtime the shared libraries from the glibc version used for linking
/usr/lib/gcc/x86_64-linux-gnu/4.6.1/../../../x86_64-linux-gnu/libglib-2.0.a(gregex.o): In function `get_matched_substring_number':
(.text+0x2d3): undefined reference to `pcre_get_stringtable_entries'
/usr/lib/gcc/x86_64-linux-gnu/4.6.1/../../../x86_64-linux-gnu/libglib-2.0.a(gregex.o): In function `get_matched_substring_number':
(.text+0x351): undefined reference to `pcre_get_stringnumber'
/usr/lib/gcc/x86_64-linux-gnu/4.6.1/../../../x86_64-linux-gnu/libglib-2.0.a(gregex.o): In function `g_match_info_next':
(.text+0x11b4): undefined reference to `pcre_exec'
/usr/lib/gcc/x86_64-linux-gnu/4.6.1/../../../x86_64-linux-gnu/libglib-2.0.a(gregex.o): In function `match_info_new':
(.text+0x141b): undefined reference to `pcre_fullinfo'
/usr/lib/gcc/x86_64-linux-gnu/4.6.1/../../../x86_64-linux-gnu/libglib-2.0.a(gregex.o): In function `g_regex_unref':
(.text+0x1484): undefined reference to `pcre_free'
/usr/lib/gcc/x86_64-linux-gnu/4.6.1/../../../x86_64-linux-gnu/libglib-2.0.a(gregex.o): In function `g_regex_unref':
(.text+0x1493): undefined reference to `pcre_free'

... etc. for every symbol
Comment 1 Sam Thursfield 2011-12-01 15:49:23 UTC
Created attachment 202529 [details] [review]
Link to libpcre when static linking

Add libpcre to Requires.private in glib-2.0.pc, so that it is passed to the
linker correctly when GLib is being statically linked.
Comment 2 Dan Winship 2011-12-01 16:33:02 UTC
Comment on attachment 202529 [details] [review]
Link to libpcre when static linking

It should only include that if --with-pcre=system
Comment 3 Sam Thursfield 2011-12-01 18:36:37 UTC
Created attachment 202541 [details] [review]
Link to libpcre correctly when static linking
Comment 4 Sam Thursfield 2011-12-01 18:37:43 UTC
Turns out configure was already generating the right variable, it just wasn't getting substituted in the .pc
Comment 5 Colin Walters 2011-12-01 22:57:56 UTC
Still need to address Comment #2 .
Comment 6 Colin Walters 2011-12-01 23:00:16 UTC
Oh, I guess you were relying on it expanding to the empty string if --with-pcre=internal.  But since we don't call AC_SUBST in that case, doesn't it blow up?

Let me actually try...
Comment 7 Sam Thursfield 2011-12-02 11:02:56 UTC
All cases work, although I agree that it seems like it should blow up. I think we're confusing AC_SUBST with AM_CONDITIONAL (which you can't conditionally call). The autoconf manual doesn't warn against behaving like this: http://www.gnu.org/s/hello/manual/autoconf/Setting-Output-Variables.html
Comment 8 Matthias Clasen 2011-12-02 13:48:00 UTC
I'd be suspicious just like Colin...but looking at configure.ac, we have prior art for this, e.g.

AC_MSG_CHECKING([whether to disable memory pools])
if test "x$disable_mem_pools" = "xno"; then
  AC_MSG_RESULT([no])
else
  AC_DEFINE(DISABLE_MEM_POOLS, [1], [Whether to disable memory pools])
  AC_SUBST(DISABLE_MEM_POOLS)
  AC_MSG_RESULT([yes])
fi


I see:

config.h:/* #undef DISABLE_MEM_POOLS */

config.status:S["DISABLE_MEM_POOLS"]=""

in my build, so the AC_DEFINE was not taken, but the AC_SUBST still had the desired effect.
Comment 9 Colin Walters 2011-12-02 20:10:32 UTC
Attachment 202541 [details] pushed as 15437a7 - Link to libpcre correctly when static linking