Skip to contentSkip to conversation

kexec-tools: fix build error with glibc 2.19 and earlier version

PATCH Applied Dave Young 2 participants 2 messages Oct 3, 2015 – Oct 6, 2015

Subsystems (2)
lore
Share & tools
lore

Dave Young

author
#0 lore raw

kexec-tools build fails on my laptop with RHEL7.1 installed:
gcc -g -O2 -fno-strict-aliasing -Wall -Wstrict-prototypes -I./include -I./util_lib/include -Iinclude/ -I./kexec/arch/x86_64/include -c -MD -o kexec/arch/i386/kexec-x86-common.o kexec/arch/i386/kexec-x86-common.c In file included from kexec/arch/i386/kexec-x86-common.c:36:0:
kexec/arch/i386/../../kexec.h:19:2: error: #error BYTE_ORDER not defined
#error BYTE_ORDER not defined

    ^
  kexec/arch/i386/../../kexec.h:23:2: error: #error LITTLE_ENDIAN not defined
   #error LITTLE_ENDIAN not defined
    ^
  kexec/arch/i386/../../kexec.h:27:2: error: #error BIG_ENDIAN not defined
   #error BIG_ENDIAN not defined
    ^
  In file included from kexec/arch/i386/kexec-x86-common.c:37:0:
  kexec/arch/i386/../../kexec-syscall.h: In function ‘kexec_load’:
  kexec/arch/i386/../../kexec-syscall.h:74:2: warning: implicit declaration of function ‘syscall’ [-Wimplicit-function-declaration]
    return (long) syscall(__NR_kexec_load, entry, nr_segments, segments, flags);
    ^

make: *** [kexec/arch/i386/kexec-x86-common.o] Error 1

The build error was introduced by below commit:

commit c9c21cc107dcc9b6053e39ead1069e03717513f9
Author: Baoquan He <[email protected]>
Date: Thu Aug 6 19:10:55 2015 +0800

kexec: use _DEFAULT_SOURCE instead to remove compiling warning

Now compiling will print warning like below. Change code as it suggested.
# warning "_BSD_SOURCE and _SVID_SOURCE are deprecated, use _DEFAULT_SOURCE"
^

See manpage: http://man7.org/linux/man-pages/man7/feature_test_macros.7.html

_BSD_SOURCE has been deprecated since glibc 2.20, To allow code that requires _BSD_SOURCE in glibc 2.19 and earlier and _DEFAULT_SOURCE in glibc 2.20 and later to compile without warnings, define both _BSD_SOURCE and _DEFAULT_SOURCE.

Thus fix it by adding back _BSD_SOURCE along with _DEFAULT_SOURCE.

---
 kexec/arch/i386/crashdump-x86.c    |    1 +
 kexec/arch/i386/kexec-x86-common.c |    1 +
 2 files changed, 2 insertions(+)
kexec/arch/i386/crashdump-x86.c +1 -0
@@ -20,6 +20,7 @@
  */
 
 #define _XOPEN_SOURCE	600
+#define _BSD_SOURCE
 #define _DEFAULT_SOURCE
 
 #include <fcntl.h>
kexec/arch/i386/kexec-x86-common.c +1 -0
@@ -18,6 +18,7 @@
  */
 
 #define _XOPEN_SOURCE	600
+#define _BSD_SOURCE
 #define _DEFAULT_SOURCE
 
 #include <fcntl.h>

_______________________________________________
kexec mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/kexec

Applied
#1 lore raw
Quoted 33 lines · Dave Young

kexec-tools build fails on my laptop with RHEL7.1 installed:
gcc -g -O2 -fno-strict-aliasing -Wall -Wstrict-prototypes -I./include -I./util_lib/include -Iinclude/ -I./kexec/arch/x86_64/include -c -MD -o kexec/arch/i386/kexec-x86-common.o kexec/arch/i386/kexec-x86-common.c In file included from kexec/arch/i386/kexec-x86-common.c:36:0:
kexec/arch/i386/../../kexec.h:19:2: error: #error BYTE_ORDER not defined
#error BYTE_ORDER not defined

    ^
  kexec/arch/i386/../../kexec.h:23:2: error: #error LITTLE_ENDIAN not defined
   #error LITTLE_ENDIAN not defined
    ^
  kexec/arch/i386/../../kexec.h:27:2: error: #error BIG_ENDIAN not defined
   #error BIG_ENDIAN not defined
    ^
  In file included from kexec/arch/i386/kexec-x86-common.c:37:0:
  kexec/arch/i386/../../kexec-syscall.h: In function ‘kexec_load’:
  kexec/arch/i386/../../kexec-syscall.h:74:2: warning: implicit declaration of function ‘syscall’ [-Wimplicit-function-declaration]
    return (long) syscall(__NR_kexec_load, entry, nr_segments, segments, flags);
    ^

make: *** [kexec/arch/i386/kexec-x86-common.o] Error 1

The build error was introduced by below commit:

commit c9c21cc107dcc9b6053e39ead1069e03717513f9
Author: Baoquan He <[email protected]>
Date: Thu Aug 6 19:10:55 2015 +0800

kexec: use _DEFAULT_SOURCE instead to remove compiling warning

Now compiling will print warning like below. Change code as it suggested.
# warning "_BSD_SOURCE and _SVID_SOURCE are deprecated, use _DEFAULT_SOURCE"
^

See manpage: http://man7.org/linux/man-pages/man7/feature_test_macros.7.html

Quoted 7 lines

_BSD_SOURCE has been deprecated since glibc 2.20, To allow code that requires _BSD_SOURCE in glibc 2.19 and earlier and _DEFAULT_SOURCE in glibc 2.20 and later to compile without warnings, define both _BSD_SOURCE and _DEFAULT_SOURCE.

Thus fix it by adding back _BSD_SOURCE along with _DEFAULT_SOURCE.

Thanks Dave,

applied.

_______________________________________________
kexec mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/kexec