Skip to contentSkip to conversation

xfsprogs compile warnings: _BSD_SOURCE is deprecated in glibc 2.20.

PATCH New Jan Ťulák 2 participants 4 messages Apr 28, 2015 – Apr 29, 2015

lore
Share & tools
lore
#0 lore raw

In glibc 2.20, _BSD_SOURCE and _SVID_SOURCE were deprecated and should be replaced with _DEFAULT_SOURCE. Currently, compiling xfsprogs on a system with glibc in said or newer version (like current Fedora) produces tons of warnings like this one:

In file included from /usr/include/stdio.h:27:0,

                  from ../include/xfs/platform_defs.h:24,
                 from ../include/xfs/libxfs.h:25,
                 from xfs_mkfs.c:19:
/usr/include/features.h:148:3: warning: #warning "_BSD_SOURCE and _SVID_SOURCE are deprecated, use _DEFAULT_SOURCE" [-Wcpp]
 # warning "_BSD_SOURCE and _SVID_SOURCE are deprecated, use _DEFAULT_SOURCE"

It can be fixed with the single line patch bellow, but I'm not sure if we can remove the deprecated version because of compatiblity. Glibc 2.19, which added _DEFAULT_SOURCE, was released in 2014, and I'm not sure how much it is backported and how much xfsprogs are backported too. So, do we need a better patch to take care of this and provide differend _SOURCE based on glibc version, or this patch is enough?

Source: man 7 feature_test_macros
Here is a link in case you older version:
http://man7.org/linux/man-pages/man7/feature_test_macros.7.html

---
 include/builddefs.in | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
include/builddefs.in +1 -1
index 944bcf6..6e6097a 100644
@@ -109,7 +109,7 @@ GCCFLAGS = -funsigned-char -fno-strict-aliasing -Wall
 #	   -Wbitwise -Wno-transparent-union -Wno-old-initializer -Wno-decl
 
 ifeq ($(PKG_PLATFORM),linux)
-PCFLAGS = -D_GNU_SOURCE -D_BSD_SOURCE -D_XOPEN_SOURCE=500 -D_FILE_OFFSET_BITS=64 $(GCCFLAGS)
+PCFLAGS = -D_GNU_SOURCE -D_DEFAULT_SOURCE -D_XOPEN_SOURCE=500 -D_FILE_OFFSET_BITS=64 $(GCCFLAGS)
 ifeq ($(HAVE_UMODE_T),yes)
 PCFLAGS += -DHAVE_UMODE_T
 endif
Signature · 6 lines
2.1.0

_______________________________________________
xfs mailing list
[email protected]
http://oss.sgi.com/mailman/listinfo/xfs
#1 lore raw
Quoted 19 lines · Jan Ťulák

In glibc 2.20, _BSD_SOURCE and _SVID_SOURCE were deprecated and should be replaced with _DEFAULT_SOURCE. Currently, compiling xfsprogs on a system with glibc in said or newer version (like current Fedora) produces tons of warnings like this one:

In file included from /usr/include/stdio.h:27:0,

                  from ../include/xfs/platform_defs.h:24,
                 from ../include/xfs/libxfs.h:25,
                 from xfs_mkfs.c:19:
/usr/include/features.h:148:3: warning: #warning "_BSD_SOURCE and _SVID_SOURCE are deprecated, use _DEFAULT_SOURCE" [-Wcpp]
 # warning "_BSD_SOURCE and _SVID_SOURCE are deprecated, use _DEFAULT_SOURCE"

It can be fixed with the single line patch bellow, but I'm not sure if we can remove the deprecated version because of compatiblity. Glibc 2.19, which added _DEFAULT_SOURCE, was released in 2014, and I'm not sure how much it is backported and how much xfsprogs are backported too. So, do we need a better patch to take care of this and provide differend _SOURCE based on glibc version, or this patch is enough?

Quoted 3 lines

Source: man 7 feature_test_macros
Here is a link in case you older version:
http://man7.org/linux/man-pages/man7/feature_test_macros.7.html

/me smacks head against wall

Really? glibc has decided to break the build of half the world?

Quoted 10 lines
---
 include/builddefs.in | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
include/builddefs.in +0 -0
index 944bcf6..6e6097a 100644

include/builddefs.in GCCFLAGS = -funsigned-char -fno-strict-aliasing -Wall · line 112

Quoted 5 lines
include/builddefs.in +1 -1
@@ -109,7 +109,7 @@ GCCFLAGS = -funsigned-char -fno-strict-aliasing -Wall
 #	   -Wbitwise -Wno-transparent-union -Wno-old-initializer -Wno-decl
 
 ifeq ($(PKG_PLATFORM),linux)
-PCFLAGS = -D_GNU_SOURCE -D_BSD_SOURCE -D_XOPEN_SOURCE=500 -D_FILE_OFFSET_BITS=64 $(GCCFLAGS)
+PCFLAGS = -D_GNU_SOURCE -D_DEFAULT_SOURCE -D_XOPEN_SOURCE=500 -D_FILE_OFFSET_BITS=64 $(GCCFLAGS)

Quoting that man page:

"
_GNU_SOURCE
[...]
Since glibc 2.19, defining _GNU_SOURCE also has the effect of implicitly defining _DEFAULT_SOURCE. In glibc versions before 2.20, defining _GNU_SOURCE also had the effect of implicitly defining _BSD_SOURCE and _SVID_SOURCE.
"

IOWs, glibc is just being an obnoxious. I'd just drop the -D_BSD_SOURCE altogether, as _GNU_SOURCE should pull in everything we need. And looking at it further, it also defines _XOPEN_SOURCE to

Quoted 1 line

= 500, so that could probably be dropped, too.

Cheers,

Dave.

Signature · 7 lines
Dave Chinner
[email protected]

_______________________________________________
xfs mailing list
[email protected]
http://oss.sgi.com/mailman/listinfo/xfs
#2 lore raw

PATCH 1/1 xfsprogs: Removing deprecated _BSD_SOURCE definition.

In glibc 2.20, _BSD_SOURCE was deprecated in favor of _DEFAULT_SOURCE. _DEFAULT_SOURCE is included with _GNU_SOURCE, as well as _XOPEN_SOURCE >= 500, so the obsolete and unnecessary definitions are removed.

For more details, see man 7 feature_test_macros for glibc >= 2.20.

---
 include/builddefs.in | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
include/builddefs.in +1 -1
index 944bcf6..7e9f53d 100644
@@ -109,7 +109,7 @@ GCCFLAGS = -funsigned-char -fno-strict-aliasing -Wall
 #	   -Wbitwise -Wno-transparent-union -Wno-old-initializer -Wno-decl
 
 ifeq ($(PKG_PLATFORM),linux)
-PCFLAGS = -D_GNU_SOURCE -D_BSD_SOURCE -D_XOPEN_SOURCE=500 -D_FILE_OFFSET_BITS=64 $(GCCFLAGS)
+PCFLAGS = -D_GNU_SOURCE -D_FILE_OFFSET_BITS=64 $(GCCFLAGS)
 ifeq ($(HAVE_UMODE_T),yes)
 PCFLAGS += -DHAVE_UMODE_T
 endif
Signature · 6 lines
2.1.0

_______________________________________________
xfs mailing list
[email protected]
http://oss.sgi.com/mailman/listinfo/xfs
author
#3 lore raw
In reply to Dave Chinner

----- Original Message -----

Quoted 70 lines

From: "Dave Chinner" <[email protected]>
To: "Jan Ťulák" <[email protected]>
Cc: [email protected]
Sent: Tuesday, 28 April, 2015 11:12:59 PM
Subject: Re: xfsprogs compile warnings: _BSD_SOURCE is deprecated in glibc 2.20.

Quoted 26 lines · Jan Ťulák

In glibc 2.20, _BSD_SOURCE and _SVID_SOURCE were deprecated and should be replaced with _DEFAULT_SOURCE. Currently, compiling xfsprogs on a system with
glibc in said or newer version (like current Fedora) produces tons of warnings
like this one:

In file included from /usr/include/stdio.h:27:0,

                  from ../include/xfs/platform_defs.h:24,
                 from ../include/xfs/libxfs.h:25,
                 from xfs_mkfs.c:19:
/usr/include/features.h:148:3: warning: #warning "_BSD_SOURCE and
_SVID_SOURCE are deprecated, use _DEFAULT_SOURCE" [-Wcpp]
 # warning "_BSD_SOURCE and _SVID_SOURCE are deprecated, use
 _DEFAULT_SOURCE"

It can be fixed with the single line patch bellow, but I'm not sure if we can
remove the deprecated version because of compatiblity. Glibc 2.19, which added
_DEFAULT_SOURCE, was released in 2014, and I'm not sure how much it is backported and how much xfsprogs are backported too. So, do we need a better
patch to take care of this and provide differend _SOURCE based on glibc version, or this patch is enough?

Quoted 3 lines

Source: man 7 feature_test_macros
Here is a link in case you older version:
http://man7.org/linux/man-pages/man7/feature_test_macros.7.html

/me smacks head against wall

Really? glibc has decided to break the build of half the world?

Quoted 10 lines
---
 include/builddefs.in | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
include/builddefs.in +0 -0
index 944bcf6..6e6097a 100644

include/builddefs.in GCCFLAGS = -funsigned-char -fno-strict-aliasing -Wall · line 114

Quoted 7 lines
include/builddefs.in +1 -3
@@ -109,7 +109,7 @@ GCCFLAGS = -funsigned-char -fno-strict-aliasing -Wall
 #	   -Wbitwise -Wno-transparent-union -Wno-old-initializer -Wno-decl
 
 ifeq ($(PKG_PLATFORM),linux)
-PCFLAGS = -D_GNU_SOURCE -D_BSD_SOURCE -D_XOPEN_SOURCE=500
-D_FILE_OFFSET_BITS=64 $(GCCFLAGS)
+PCFLAGS = -D_GNU_SOURCE -D_DEFAULT_SOURCE -D_XOPEN_SOURCE=500
-D_FILE_OFFSET_BITS=64 $(GCCFLAGS)

Quoting that man page:

"
_GNU_SOURCE
[...]
Since glibc 2.19, defining _GNU_SOURCE also has the effect of implicitly defining _DEFAULT_SOURCE. In glibc versions before 2.20, defining _GNU_SOURCE also had the effect of implicitly defining _BSD_SOURCE and _SVID_SOURCE.
"

Quoted 5 lines

IOWs, glibc is just being an obnoxious. I'd just drop the -D_BSD_SOURCE altogether, as _GNU_SOURCE should pull in everything we need. And looking at it further, it also defines _XOPEN_SOURCE to

Quoted 1 line

= 500, so that could probably be dropped, too.

All right, so I dropped it too. We could make a glibc fork instead, but this seems to be... a bit easier. :P

Cheers.

Signature · 7 lines
Jan Tulak
[email protected]

_______________________________________________
xfs mailing list
[email protected]
http://oss.sgi.com/mailman/listinfo/xfs