Message ID | 20240229164439.20521-1-winfried_mb2@xmsnet.nl (mailing list archive) |
---|---|
State | Superseded |
Delegated to: | Petr Lautrbach |
Headers | show |
Series | libsepoll/src/Makefile: Fix reallocarray detection when cross-compiling | expand |
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 > >
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
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(-)