-
Notifications
You must be signed in to change notification settings - Fork 2.2k
libselinux: Fix cross-compilation #22952
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
conan-center-bot
merged 6 commits into
conan-io:master
from
jwillikers:libselinux-cross-compile
Jun 6, 2024
Merged
Changes from 3 commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
36cc7d6
libselinux: Fix cross-compilation
jwillikers cb7bd70
Merge branch 'master' into libselinux-cross-compile
jwillikers 2ce47e6
Merge branch 'master' into libselinux-cross-compile
jwillikers ef73bf0
Bump pkgconf
jwillikers 2484dc5
Only set PKG_CONFIG_LIBDIR when cross-compiling
jwillikers 785e1fa
Update recipes/libselinux/all/conanfile.py
franramirez688 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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 |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.