Bug 89448 - Insufficient version-test for GLIB/GIO
Summary: Insufficient version-test for GLIB/GIO
Status: RESOLVED MOVED
Alias: None
Product: shared-mime-info
Classification: Unclassified
Component: general (show other bugs)
Version: unspecified
Hardware: Other All
: medium normal
Assignee: Shared Mime Info group
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2015-03-05 21:17 UTC by Daniel Macks
Modified: 2018-10-13 10:40 UTC (History)
0 users

See Also:
i915 platform:
i915 features:


Attachments
Patch against 1.6 to fix building with glib<2.26 (747 bytes, patch)
2016-06-19 21:07 UTC, Daniel Macks
Details | Splinter Review

Description Daniel Macks 2015-03-05 21:17:41 UTC
Building shared-mime-info-1.4 on a machine with a very old glib passes ./configure (including the glib tests):

checking for ALL... yes
checking for GIO... yes

but then compiling fails:

  CC       update_mime_database-update-mime-database.o
update-mime-database.c:3548:2: error: use of undeclared identifier 'GStatBuf'
        GStatBuf statbuf;
        ^
update-mime-database.c:3553:31: error: use of undeclared identifier 'statbuf';
      did you mean 'setbuf'?
        retval = g_stat(packagedir, &statbuf);
                                     ^~~~~~~

g_stat() has long existed, but the GStatBuf type was only added in glib-2.26.0, but ALL/GIO tests only require >= 2.6.0. It appears that struct GStatBuf is just struct stat on most platforms (all it is is a typedef wrapper in gstdio.h). So it seems easy enough to add backward-compatibility, as in:

http://sourceforge.net/p/viking/bugs/104/
Comment 1 Bastien Nocera 2015-03-09 14:16:38 UTC
commit 573329b89e5e6ac3f503ec074e874f5ca92b103e
Author: Bastien Nocera <hadess@hadess.net>
Date:   Mon Mar 9 15:14:25 2015 +0100

    Fix compilation with glib < 2.26
    
    https://bugs.freedesktop.org/show_bug.cgi?id=89448
Comment 2 Daniel Macks 2016-06-19 21:01:21 UTC
The fix committed for update-mime-database.c:newest_mtime() is not correct:

#if !GLIB_CHECK_VERSION(2,26,0)
	struct stat GStatBuf;
#else
	GStatBuf statbuf;
#endif

For <2.26, GStatBuf appears to be defined as a variable. Instead, either statbuf needs to be declared as the variable (solution 1):

#if !GLIB_CHECK_VERSION(2,26,0)
	struct stat statuf;
#else
	GStatBuf statbuf;
#endif

or else GstatBuf needs to be defined as a typedef and then the statbuf variable declared as the variable for both branches (solution 2):

#if !GLIB_CHECK_VERSION(2,26,0)
	typedef struct stat GStatBuf;
#endif
	GStatBuf statbuf;


And update-mime-database.c:is_cache_up_to_date() also uses a GStatBuf, so it needs a similar fix. Maybe cleaner to put the "solution 2" typedef declaration up in the block of #include for the whole .c rather than having to remember to do it in each separate function.
Comment 3 Daniel Macks 2016-06-19 21:07:24 UTC
Created attachment 124610 [details] [review]
Patch against 1.6 to fix building with glib<2.26

Here's the patch we're using in fink.
Comment 4 Daniel Macks 2017-03-26 21:32:34 UTC
The 1.7 release still fails to build and the patch I gave in  Comment #3 still fixes it. Any thoughts about committing it?
Comment 5 GitLab Migration User 2018-10-13 10:40:34 UTC
-- GitLab Migration Automatic Message --

This bug has been migrated to freedesktop.org's GitLab instance and has been closed from further activity.

You can subscribe and participate further through the new bug through this link to our GitLab instance: https://gitlab.freedesktop.org/xdg/shared-mime-info/issues/73.


Use of freedesktop.org services, including Bugzilla, is subject to our Code of Conduct. How we collect and use information is described in our Privacy Policy.