libsepol: make reallocarray check more robust
Stephen Smalley
maintainerPATCH 1/1 libsepol: make reallocarray check more robust
From: Waldemar Brodkorb <[email protected]>
Some cross-compiler toolchains dislike the usage of -o /dev/null and fail
with: ld: final link failed: file truncated
As stdin and stdout is already redirected to /dev/null there is no need for gcc -o /dev/null.
This fixes an Buildroot autobuild failure for libsepol package:
http://autobuild.buildroot.net/results/72b/72baaab4658254f4c5b3348298af1d5c891cacd6/
--- libsepol/src/Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
libsepol/src/Makefile +1 -1
@@ -31,7 +31,7 @@ endif # check for reallocarray(3) availability H := \# -ifeq (yes,$(shell printf '${H}include <stdlib.h>\nint main(void){return reallocarray(NULL,0,0)==NULL;}' | $(CC) $(CPPFLAGS) $(CFLAGS) $(LDFLAGS) -Werror=implicit-function-declaration -x c -o /dev/null - >/dev/null 2>&1 && echo yes)) +ifeq (yes,$(shell printf '${H}include <stdlib.h>\nint main(void){return reallocarray(NULL,0,0)==NULL;}' | $(CC) $(CPPFLAGS) $(CFLAGS) $(LDFLAGS) -Werror=implicit-function-declaration -x c - >/dev/null 2>&1 && echo yes)) override CFLAGS += -DHAVE_REALLOCARRAY endif
Signature · 1 line
2.54.0
Stephen Smalley
maintainerQuoted 22 lines · Stephen Smalley
From: Waldemar Brodkorb <[email protected]>
Some cross-compiler toolchains dislike the usage of -o
/dev/nulland fail
with: ld: final link failed: file truncatedAs stdin and stdout is already redirected to
/dev/nullthere is no need for gcc -o/dev/null.This fixes an Buildroot autobuild failure for libsepol package:
http://autobuild.buildroot.net/results/72b/72baaab4658254f4c5b3348298af1d5c891cacd6/Signed-off-by Waldemar Brodkorb <[email protected]>--- libsepol/src/Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)libsepol/src/Makefile +0
-0
libsepol/src/Makefile endif · line 36
Quoted 7 lines
libsepol/src/Makefile +1
-1@@ -31,7 +31,7 @@ endif # check for reallocarray(3) availability H := \# -ifeq (yes,$(shell printf '${H}include <stdlib.h>\nint main(void){return reallocarray(NULL,0,0)==NULL;}' | $(CC) $(CPPFLAGS) $(CFLAGS) $(LDFLAGS) -Werror=implicit-function-declaration -x c -o /dev/null - >/dev/null 2>&1 && echo yes)) +ifeq (yes,$(shell printf '${H}include <stdlib.h>\nint main(void){return reallocarray(NULL,0,0)==NULL;}' | $(CC) $(CPPFLAGS) $(CFLAGS) $(LDFLAGS) -Werror=implicit-function-declaration -x c - >/dev/null 2>&1 && echo yes)) override CFLAGS += -DHAVE_REALLOCARRAY endif
This leaves an a.out file which then breaks CI,
https://github.com/stephensmalley/selinux/actions/runs/27141099174/job/80106217168
Must be a better way to fix it.
Quoted 4 lines
libsepol/src/Makefile +0
-1--2.54.0
Quoted 36 lines · Stephen Smalley
Quoted 22 lines · Stephen Smalley
From: Waldemar Brodkorb <[email protected]>
Some cross-compiler toolchains dislike the usage of -o
/dev/nulland fail
with: ld: final link failed: file truncatedAs stdin and stdout is already redirected to
/dev/nullthere is no need for gcc -o/dev/null.This fixes an Buildroot autobuild failure for libsepol package:
http://autobuild.buildroot.net/results/72b/72baaab4658254f4c5b3348298af1d5c891cacd6/Signed-off-by Waldemar Brodkorb <[email protected]>--- libsepol/src/Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)libsepol/src/Makefile +0
-0libsepol/src/Makefile endif · line 36
Quoted 7 lines
libsepol/src/Makefile +1
-1@@ -31,7 +31,7 @@ endif # check for reallocarray(3) availability H := \# -ifeq (yes,$(shell printf '${H}include <stdlib.h>\nint main(void){return reallocarray(NULL,0,0)==NULL;}' | $(CC) $(CPPFLAGS) $(CFLAGS) $(LDFLAGS) -Werror=implicit-function-declaration -x c -o /dev/null - >/dev/null 2>&1 && echo yes)) +ifeq (yes,$(shell printf '${H}include <stdlib.h>\nint main(void){return reallocarray(NULL,0,0)==NULL;}' | $(CC) $(CPPFLAGS) $(CFLAGS) $(LDFLAGS) -Werror=implicit-function-declaration -x c - >/dev/null 2>&1 && echo yes)) override CFLAGS += -DHAVE_REALLOCARRAY endifThis leaves an a.out file which then breaks CI,
https://github.com/stephensmalley/selinux/actions/runs/27141099174/job/80106217168
Quoted 2 lines
Must be a better way to fix it.
Maybe use "-fsyntax-only"
# check for reallocarray(3) availability
H := \#
-ifeq (yes,$(shell printf '${H}include <stdlib.h>\nint
main(void){return reallocarray(NULL,0,0)==NULL;}' | $(CC) $(CPPFLAGS)
$(CFLAGS) $(LDFLAGS) -Werror=implicit-function-declaration -x c -o
/dev/null - >/dev/null 2>&1 && echo yes))
+ifeq (yes,$(shell printf '${H}include <stdlib.h>\nint
main(void){return reallocarray(NULL,0,0)==NULL;}' | $(CC) $(CPPFLAGS)
$(CFLAGS) $(LDFLAGS) -Werror=implicit-function-declaration
-fsyntax-only -x c - >/dev/null 2>&1 && echo yes))
override CFLAGS += -DHAVE_REALLOCARRAY
endifJim
Quoted 4 lines
Quoted 4 lines
libsepol/src/Makefile +0
-1--2.54.0
Stephen Smalley
maintainerQuoted 44 lines · James Carter
Quoted 36 lines · Stephen Smalley
Quoted 22 lines · Stephen Smalley
From: Waldemar Brodkorb <[email protected]>
Some cross-compiler toolchains dislike the usage of -o
/dev/nulland fail
with: ld: final link failed: file truncatedAs stdin and stdout is already redirected to
/dev/nullthere is no need for gcc -o/dev/null.This fixes an Buildroot autobuild failure for libsepol package:
http://autobuild.buildroot.net/results/72b/72baaab4658254f4c5b3348298af1d5c891cacd6/Signed-off-by Waldemar Brodkorb <[email protected]>--- libsepol/src/Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)libsepol/src/Makefile +0
-0libsepol/src/Makefile endif · line 36
Quoted 7 lines
libsepol/src/Makefile +1
-1@@ -31,7 +31,7 @@ endif # check for reallocarray(3) availability H := \# -ifeq (yes,$(shell printf '${H}include <stdlib.h>\nint main(void){return reallocarray(NULL,0,0)==NULL;}' | $(CC) $(CPPFLAGS) $(CFLAGS) $(LDFLAGS) -Werror=implicit-function-declaration -x c -o /dev/null - >/dev/null 2>&1 && echo yes)) +ifeq (yes,$(shell printf '${H}include <stdlib.h>\nint main(void){return reallocarray(NULL,0,0)==NULL;}' | $(CC) $(CPPFLAGS) $(CFLAGS) $(LDFLAGS) -Werror=implicit-function-declaration -x c - >/dev/null 2>&1 && echo yes)) override CFLAGS += -DHAVE_REALLOCARRAY endifThis leaves an a.out file which then breaks CI,
https://github.com/stephensmalley/selinux/actions/runs/27141099174/job/80106217168Quoted 2 lines
Must be a better way to fix it.
Maybe use "-fsyntax-only"
Quoted 12 lines
# check for reallocarray(3) availability
H := \#
-ifeq (yes,$(shell printf '${H}include <stdlib.h>\nint
main(void){return reallocarray(NULL,0,0)==NULL;}' | $(CC) $(CPPFLAGS)
$(CFLAGS) $(LDFLAGS) -Werror=implicit-function-declaration -x c -o
/dev/null - >/dev/null 2>&1 && echo yes))
+ifeq (yes,$(shell printf '${H}include <stdlib.h>\nint
main(void){return reallocarray(NULL,0,0)==NULL;}' | $(CC) $(CPPFLAGS)
$(CFLAGS) $(LDFLAGS) -Werror=implicit-function-declaration
-fsyntax-only -x c - >/dev/null 2>&1 && echo yes))
override CFLAGS += -DHAVE_REALLOCARRAY
endifThis might be OBE; looks like ld fixed it a decade ago so -o /dev/null is safe now.