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 776173 - Missing sys/sysmacros.h #include, needed for experimental glibc versions
Missing sys/sysmacros.h #include, needed for experimental glibc versions
Status: RESOLVED FIXED
Product: gparted
Classification: Other
Component: application
GIT HEAD
Other Linux
: Normal normal
: ---
Assigned To: Mike Fleetwood
gparted maintainers alias
Depends on:
Blocks:
 
 
Reported: 2016-12-16 16:22 UTC by Michał Górny
Modified: 2017-02-14 18:33 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
Build log (30.58 KB, text/x-log)
2016-12-16 16:22 UTC, Michał Górny
  Details
0001-Include-sys-sysmacros.h-if-available-for-newer-glibc.patch (1.34 KB, patch)
2016-12-16 16:32 UTC, Michał Górny
none Details | Review
Include sys/sysmacros.h (v2) (1.76 KB, patch)
2016-12-18 12:14 UTC, Mike Fleetwood
none Details | Review

Description Michał Górny 2016-12-16 16:22:27 UTC
Created attachment 342076 [details]
Build log

glibc is moving towards removing major() and minor() functions from the commonly used headers, and requiring explicit:

  #include <sys/sysmacros.h>

for them. As a result, gparted does not build against Gentoo glibc-2.24 (not yet in ~arch):

BlockSpecial.cc: In constructor ‘GParted::BlockSpecial::BlockSpecial(const Glib::ustring&)’:
BlockSpecial.cc:64:31: error: ‘major’ was not declared in this scope
   m_major = major( sb.st_rdev );
                               ^
BlockSpecial.cc:65:31: error: ‘minor’ was not declared in this scope
   m_minor = minor( sb.st_rdev );
                               ^

I'm attaching the complete build log for 0.27.0 for completeness. I will attach a patch against git master soon.
Comment 1 Michał Górny 2016-12-16 16:32:17 UTC
Created attachment 342077 [details] [review]
0001-Include-sys-sysmacros.h-if-available-for-newer-glibc.patch

Here's a patch that works for me. I've added a configure checks to cover for systems that do not have <sys/sysmacros.h>.
Comment 2 Mike Fleetwood 2016-12-18 12:14:13 UTC
Created attachment 342159 [details] [review]
Include sys/sysmacros.h (v2)

Hi Michał,

Thank you for the bug report and patch.

Looking at Glibc and musl-libc histories I see that they both have
always provided <sys/sysmacros.h> with definitions of major and minor
macros.  Therefore using an autoconf check and conditional inclusion
seems unnecessary.  I plan to use the attached patch in GParted which
just unconditionally includes <sys/sysmacros.h>.

I have successfully tested this patch on years old CentOS 5 with
Glibc 2.5 and bang up to date Fedora Rawhide with Glibc 2.24.90.

Please let me know if you see any problem with this.

Thanks
Mike


By the way when I compile on Fedora Rawhide without this patch I just
get the following warnings.  Did that build of GParted on Gentoo have
something set to remove Glibc deprecated definitions to make the build
fail rather than report a warning?


BlockSpecial.cc:64:13: warning: In the GNU C Library, "major" is defined
 by <sys/sysmacros.h>. For historical compatibility, it is
 currently defined by <sys/types.h> as well, but we plan to
 remove this soon. To use "major", include <sys/sysmacros.h>
 directly. If you did not intend to use a system-defined macro
 "major", you should undefine it after including <sys/types.h>.
   m_major = major( sb.st_rdev );
             ^~~~~~~~~~~~~~~~~~~~

BlockSpecial.cc:65:13: warning: In the GNU C Library, "minor" is defined
 by <sys/sysmacros.h>. For historical compatibility, it is
 currently defined by <sys/types.h> as well, but we plan to
 remove this soon. To use "minor", include <sys/sysmacros.h>
 directly. If you did not intend to use a system-defined macro
 "minor", you should undefine it after including <sys/types.h>.
   m_minor = minor( sb.st_rdev );
             ^~~~~~~~~~~~~~~~~~~~
Comment 3 Michał Górny 2016-12-18 13:39:41 UTC
(In reply to Mike Fleetwood from comment #2)
> Looking at Glibc and musl-libc histories I see that they both have
> always provided <sys/sysmacros.h> with definitions of major and minor
> macros.  Therefore using an autoconf check and conditional inclusion
> seems unnecessary.  I plan to use the attached patch in GParted which
> just unconditionally includes <sys/sysmacros.h>.
> 
> I have successfully tested this patch on years old CentOS 5 with
> Glibc 2.5 and bang up to date Fedora Rawhide with Glibc 2.24.90.
> 
> Please let me know if you see any problem with this.

Well, that depends on which systems you aim to support. The conditional inclusion is better portability-wise. I know that at least Darwin doesn't (or didn't) have <sys/sysmacros.h> which caused issues for Mozilla's attempt to include it unconditionally [1].

[1]:http://hg.mozilla.org/mozilla-central/rev/f9aceff48e1b

> By the way when I compile on Fedora Rawhide without this patch I just
> get the following warnings.  Did that build of GParted on Gentoo have
> something set to remove Glibc deprecated definitions to make the build
> fail rather than report a warning?

It's actually using a custom patch to drop implicit sys/sysmacros.h include completely.
Comment 4 Mike Fleetwood 2017-01-04 11:01:01 UTC
Hi  Michał,

I've pushed the following patch to GParted master for inclusion in the
next release:

Include sys/sysmacros.h for major and minor macros (#776173)
https://git.gnome.org/browse/gparted/commit/?id=e4819fdd459d812f06ac30bfe577258d6fab7684

Mike
Comment 5 Curtis Gedak 2017-02-14 18:33:06 UTC
This enhancement was included in the GParted 0.28.0 release on February 14, 2017.