-
Notifications
You must be signed in to change notification settings - Fork 1.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
(#22952) libselinux: Fix cross-compilation
* libselinux: Fix cross-compilation Apply patches for 3.6 to fix detection of available functions when cross-compiling. Use the PKG_CONFIG_LIBDIR to point pkg-config to the correct directory containing Conan's generated pkg-config files. Without this, the pcre2 from the system will be picked up before the one provided by Conan. When cross-compiling, this causes system include directories to poison the build. * Bump pkgconf * Only set PKG_CONFIG_LIBDIR when cross-compiling * Update recipes/libselinux/all/conanfile.py --------- Co-authored-by: Francisco Ramírez <[email protected]>
- Loading branch information
1 parent
ffd5054
commit 371cd5b
Showing
4 changed files
with
124 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -40,6 +40,15 @@ patches: | |
base_path: libselinux-3.6 | ||
patch_description: "Fix a missing #include <stdint.h>" | ||
patch_type: "portability" | ||
- patch_file: patches/0004-libsepol-src-Makefile-fix-reallocarray-detection.patch | ||
patch_description: "libsepol/src/Makefile: fix reallocarray detection" | ||
patch_source: "https://lore.kernel.org/selinux/[email protected]/" | ||
patch_type: "portability" | ||
base_path: libsepol-3.6 | ||
- patch_file: patches/0005-libselinux-libsepol-Add-CFLAGS-and-LDFLAGS.patch | ||
patch_description: "libselinux, libsepol: Add CFLAGS and LDFLAGS to Makefile checks" | ||
patch_source: "https://lore.kernel.org/selinux/[email protected]/T/#u" | ||
patch_type: "portability" | ||
"3.3": | ||
- patch_file: patches/0003-fix-link-pcre.patch | ||
base_path: libselinux-3.3 | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
48 changes: 48 additions & 0 deletions
48
recipes/libselinux/all/patches/0004-libsepol-src-Makefile-fix-reallocarray-detection.patch
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
From a520f972bce9ec267f4e76b729bc3b7c1bdf13e6 Mon Sep 17 00:00:00 2001 | ||
From: Fabrice Fontaine <[email protected]> | ||
Date: Mon, 8 Jan 2024 22:03:14 +0100 | ||
Subject: [PATCH 1/3] libsepol/src/Makefile: fix reallocarray detection | ||
|
||
Pass LDFLAGS when checking for reallocarray to avoid the following | ||
static build failure with musl raised since version 3.4 and | ||
https://github.com/SELinuxProject/selinux/commit/f0a5f6e33084bd83d409bb7c932256139f471e71 | ||
because -static is not passed when checking for reallocarray: | ||
|
||
/home/autobuild/autobuild/instance-9/output-1/host/bin/armeb-buildroot-linux-musleabi-gcc -D_LARGEFILE_SOURCE -D_LARGEFILE64_SOURCE -D_FILE_OFFSET_BITS=64 -O0 -g0 -static -I. -I../include -D_GNU_SOURCE -I../cil/include -fPIC -c -o assertion.o assertion.c | ||
In file included from assertion.c:28: | ||
private.h:88:21: error: static declaration of 'reallocarray' follows non-static declaration | ||
88 | static inline void* reallocarray(void *ptr, size_t nmemb, size_t size) { | ||
| ^~~~~~~~~~~~ | ||
In file included from ../include/sepol/policydb/mls_types.h:35, | ||
from ../include/sepol/policydb/context.h:23, | ||
from ../include/sepol/policydb/policydb.h:62, | ||
from assertion.c:24: | ||
/home/autobuild/autobuild/instance-9/output-1/host/armeb-buildroot-linux-musleabi/sysroot/usr/include/stdlib.h:150:7: note: previous declaration of 'reallocarray' with type 'void *(void *, size_t, size_t)' {aka 'void *(void *, unsigned int, unsigned int)'} | ||
150 | void *reallocarray (void *, size_t, size_t); | ||
| ^~~~~~~~~~~~ | ||
|
||
Fixes: | ||
- http://autobuild.buildroot.org/results/0170032548a38e2c991d62dc5823808458ad03b3 | ||
|
||
Signed-off-by: Fabrice Fontaine <[email protected]> | ||
Acked-by: James Carter <[email protected]> | ||
--- | ||
src/Makefile | 2 +- | ||
1 file changed, 1 insertion(+), 1 deletion(-) | ||
|
||
diff --git a/src/Makefile b/src/Makefile | ||
index d80a941f..16b9bd5e 100644 | ||
--- a/src/Makefile | ||
+++ b/src/Makefile | ||
@@ -31,7 +31,7 @@ endif | ||
|
||
# check for reallocarray(3) availability | ||
H := \# | ||
-ifeq (yes,$(shell printf '${H}define _GNU_SOURCE\n${H}include <stdlib.h>\nint main(void){void*p=reallocarray(NULL, 1, sizeof(char));return 0;}' | $(CC) -x c -o /dev/null - >/dev/null 2>&1 && echo yes)) | ||
+ifeq (yes,$(shell printf '${H}define _GNU_SOURCE\n${H}include <stdlib.h>\nint main(void){void*p=reallocarray(NULL, 1, sizeof(char));return 0;}' | $(CC) $(LDFLAGS) -x c -o /dev/null - >/dev/null 2>&1 && echo yes)) | ||
override CFLAGS += -DHAVE_REALLOCARRAY | ||
endif | ||
|
||
-- | ||
2.44.0 | ||
|
61 changes: 61 additions & 0 deletions
61
recipes/libselinux/all/patches/0005-libselinux-libsepol-Add-CFLAGS-and-LDFLAGS.patch
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
[PATCH] libselinux, libsepol: Add CFLAGS and LDFLAGS to Makefile checks | ||
@ 2024-03-13 22:48 James Carter | ||
0 siblings, 0 replies; only message in thread | ||
From: James Carter @ 2024-03-13 22:48 UTC (permalink / raw) | ||
To: selinux; +Cc: jordan, winfried_mb2, James Carter | ||
|
||
In libselinux there is an availability check for strlcpy() and | ||
in both libselinux and libsepol there are availability checks for | ||
reallocarray() in the src Makfiles. CFLAGS and LDFLAGS are needed | ||
for cross-compiling, but, unfortunately, the default CFLAGS cause | ||
all of these availability checks to fail to compile because of | ||
compilationerrors (rather than just the function not being available). | ||
|
||
Add CFLAGS and LDFLAGS to the availibility checks, update the checks | ||
so that a compilation error will only happen if the function being | ||
checked for is not available, and make checks for the same function | ||
the same in both libselinux and libsepol. | ||
|
||
Suggested-by: Jordan Williams <[email protected]> | ||
Suggested-by: Winfried Dobbe <[email protected]> | ||
Signed-off-by: James Carter <[email protected]> | ||
--- | ||
libselinux/src/Makefile | 4 ++-- | ||
libsepol/src/Makefile | 2 +- | ||
2 files changed, 3 insertions(+), 3 deletions(-) | ||
|
||
diff --git a/libselinux-3.6/src/Makefile b/libselinux-3.6/src/Makefile | ||
index d3b981fc..41cfbdca 100644 | ||
--- a/libselinux-3.6/src/Makefile | ||
+++ b/libselinux-3.6/src/Makefile | ||
@@ -104,13 +104,13 @@ override CFLAGS += -I../include -D_GNU_SOURCE $(DISABLE_FLAGS) $(PCRE_CFLAGS) | ||
|
||
# check for strlcpy(3) availability | ||
H := \# | ||
-ifeq (yes,$(shell printf '${H}include <string.h>\nint main(void){char*d,*s;strlcpy(d, s, 0);return 0;}' | $(CC) -x c -o /dev/null - >/dev/null 2>&1 && echo yes)) | ||
+ifeq (yes,$(shell printf '${H}include <string.h>\nint main(void){char d[2];const char *s="a";return (size_t)strlcpy(d,s,sizeof(d))>=sizeof(d);}' | $(CC) $(CFLAGS) $(LDFLAGS) -x c -o /dev/null - >/dev/null 2>&1 && echo yes)) | ||
override CFLAGS += -DHAVE_STRLCPY | ||
endif | ||
|
||
# check for reallocarray(3) availability | ||
H := \# | ||
-ifeq (yes,$(shell printf '${H}include <stdlib.h>\nint main(void){reallocarray(NULL, 0, 0);return 0;}' | $(CC) -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) $(CFLAGS) $(LDFLAGS) -x c -o /dev/null - >/dev/null 2>&1 && echo yes)) | ||
override CFLAGS += -DHAVE_REALLOCARRAY | ||
endif | ||
|
||
diff --git a/libsepol-3.6/src/Makefile b/libsepol-3.6/src/Makefile | ||
index 16b9bd5e..7b0e8446 100644 | ||
--- a/libsepol-3.6/src/Makefile | ||
+++ b/libsepol-3.6/src/Makefile | ||
@@ -31,7 +31,7 @@ endif | ||
|
||
# check for reallocarray(3) availability | ||
H := \# | ||
-ifeq (yes,$(shell printf '${H}define _GNU_SOURCE\n${H}include <stdlib.h>\nint main(void){void*p=reallocarray(NULL, 1, sizeof(char));return 0;}' | $(CC) $(LDFLAGS) -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) $(CFLAGS) $(LDFLAGS) -x c -o /dev/null - >/dev/null 2>&1 && echo yes)) | ||
override CFLAGS += -DHAVE_REALLOCARRAY | ||
endif | ||
|
||
-- | ||
2.44.0 |