On Fri, Mar 1, 2024 at 12:03 PM Jordan Williams <jordan@xxxxxxxxxxxxxx> wrote: > > Pass CFLAGS and LDFLAGS when checking for realocarray and strlcpy. > This brings things inline with the fixes for libsepol/src/Makefile. > This better supports cross-compiling scenarios. > There, flags like -sysroot need to included when running these checks. > > Signed-off-by: Jordan Williams <jordan@xxxxxxxxxxxxxx> > > diff --git a/libselinux/src/Makefile b/libselinux/src/Makefile > index d3b981fc..3a9b5300 100644 > --- a/libselinux/src/Makefile > +++ b/libselinux/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,*s;strlcpy(d, s, 0);return 0;}' | $(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){reallocarray(NULL, 0, 0);return 0;}' | $(CC) $(CFLAGS) > $(LDFLAGS) -x c -o /dev/null - >/dev/null 2>&1 && echo yes)) > override CFLAGS += -DHAVE_REALLOCARRAY > endif > The default CFLAGS causes the compilation to fail even if strlcpy() or reallocarray() exist. See if the patch I sent to the list works for you. Thanks, Jim > -- > 2.44.0 > >