All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] libsepoll/src/Makefile: Fix reallocarray detection when cross-compiling
@ 2024-02-29 16:44 Winfried Dobbe
  2024-03-13 22:50 ` James Carter
  0 siblings, 1 reply; 2+ messages in thread
From: Winfried Dobbe @ 2024-02-29 16:44 UTC (permalink / raw)
  To: selinux; +Cc: Winfried Dobbe

In addition to commit 3e3661f602fe7d7dc972bf695fd178370bbd7e54, CFLAGS
are also needed for the reallocarray detection when cross-compiling
libsepoll.

For example when cross-compiling for Arm Cortex-A9 the compiler finds
stdlib.h (after the addition of LDFLAGS in above mentioned 3e3661f).
But then tries to include soft-float stubs because gcc options
-mfpu=neon -mfloat-abi=hard are missing. See output of detection:

In file included from /home/wdobbe/.conan2/p/b/swpt_fb08c05e04578/p/sysroots/cortexa9hf-neon-poky-linux-gnueabi/usr/include/gnu/stubs.h:40,
                 from /home/wdobbe/.conan2/p/b/swpt_fb08c05e04578/p/sysroots/cortexa9hf-neon-poky-linux-gnueabi/usr/include/features.h:474,
                 from /home/wdobbe/.conan2/p/b/swpt_fb08c05e04578/p/sysroots/cortexa9hf-neon-poky-linux-gnueabi/usr/include/bits/libc-header-start.h:33,
                 from /home/wdobbe/.conan2/p/b/swpt_fb08c05e04578/p/sysroots/cortexa9hf-neon-poky-linux-gnueabi/usr/include/stdlib.h:25,
                 from <stdin>:2:
/home/wdobbe/.conan2/p/b/swpt_fb08c05e04578/p/sysroots/cortexa9hf-neon-poky-linux-gnueabi/usr/include/gnu/stubs-32.h:7:11: fatal error: gnu/stubs-soft.h: No such file or directory
    7 | # include <gnu/stubs-soft.h>
      |           ^~~~~~~~~~~~~~~~~~
compilation terminated.

Signed-off-by: Winfried Dobbe <winfried_mb2@xmsnet.nl>
---
 libsepol/src/Makefile | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/libsepol/src/Makefile b/libsepol/src/Makefile
index 16b9bd5e..fd6329d4 100644
--- a/libsepol/src/Makefile
+++ b/libsepol/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}define _GNU_SOURCE\n${H}include <stdlib.h>\nint main(void){void*p=reallocarray(NULL, 1, sizeof(char));return 0;}' | $(CC) $(CFLAGS) $(LDFLAGS) -x c -o /dev/null - >/dev/null 2>&1 && echo yes))
 override CFLAGS += -DHAVE_REALLOCARRAY
 endif
 
-- 
2.35.3


^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH] libsepoll/src/Makefile: Fix reallocarray detection when cross-compiling
  2024-02-29 16:44 [PATCH] libsepoll/src/Makefile: Fix reallocarray detection when cross-compiling Winfried Dobbe
@ 2024-03-13 22:50 ` James Carter
  0 siblings, 0 replies; 2+ messages in thread
From: James Carter @ 2024-03-13 22:50 UTC (permalink / raw)
  To: Winfried Dobbe; +Cc: selinux

On Thu, Feb 29, 2024 at 11:45 AM Winfried Dobbe <winfried_mb2@xmsnet.nl> wrote:
>
> In addition to commit 3e3661f602fe7d7dc972bf695fd178370bbd7e54, CFLAGS
> are also needed for the reallocarray detection when cross-compiling
> libsepoll.
>
> For example when cross-compiling for Arm Cortex-A9 the compiler finds
> stdlib.h (after the addition of LDFLAGS in above mentioned 3e3661f).
> But then tries to include soft-float stubs because gcc options
> -mfpu=neon -mfloat-abi=hard are missing. See output of detection:
>
> In file included from /home/wdobbe/.conan2/p/b/swpt_fb08c05e04578/p/sysroots/cortexa9hf-neon-poky-linux-gnueabi/usr/include/gnu/stubs.h:40,
>                  from /home/wdobbe/.conan2/p/b/swpt_fb08c05e04578/p/sysroots/cortexa9hf-neon-poky-linux-gnueabi/usr/include/features.h:474,
>                  from /home/wdobbe/.conan2/p/b/swpt_fb08c05e04578/p/sysroots/cortexa9hf-neon-poky-linux-gnueabi/usr/include/bits/libc-header-start.h:33,
>                  from /home/wdobbe/.conan2/p/b/swpt_fb08c05e04578/p/sysroots/cortexa9hf-neon-poky-linux-gnueabi/usr/include/stdlib.h:25,
>                  from <stdin>:2:
> /home/wdobbe/.conan2/p/b/swpt_fb08c05e04578/p/sysroots/cortexa9hf-neon-poky-linux-gnueabi/usr/include/gnu/stubs-32.h:7:11: fatal error: gnu/stubs-soft.h: No such file or directory
>     7 | # include <gnu/stubs-soft.h>
>       |           ^~~~~~~~~~~~~~~~~~
> compilation terminated.
>
> Signed-off-by: Winfried Dobbe <winfried_mb2@xmsnet.nl>
> ---
>  libsepol/src/Makefile | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/libsepol/src/Makefile b/libsepol/src/Makefile
> index 16b9bd5e..fd6329d4 100644
> --- a/libsepol/src/Makefile
> +++ b/libsepol/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}define _GNU_SOURCE\n${H}include <stdlib.h>\nint main(void){void*p=reallocarray(NULL, 1, sizeof(char));return 0;}' | $(CC) $(CFLAGS) $(LDFLAGS) -x c -o /dev/null - >/dev/null 2>&1 && echo yes))

The default CFLAGS causes the compilation to fail even if reallocarray
exists on the system.
See if the patch I sent to the list works for you.
Thanks,
Jim

>  override CFLAGS += -DHAVE_REALLOCARRAY
>  endif
>
> --
> 2.35.3
>
>

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2024-03-13 22:50 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-02-29 16:44 [PATCH] libsepoll/src/Makefile: Fix reallocarray detection when cross-compiling Winfried Dobbe
2024-03-13 22:50 ` James Carter

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.