Browse Source

check-reallocarray.sh: Use the same compiler Make does

Currently we hardcode "gcc", which means we get a bogus result any time
a non-default CC is passed to Make. In fact, it's bogus even when CC is
not explicitly set, since Make's default is "cc", which isn't
necessarily the same as "gcc".

Fix the issue by passing the compiler to use to check-reallocarray.sh.

Signed-off-by: Thomas Hebb <tommyhebb@gmail.com>
master
Thomas Hebb 1 year ago
committed by Andrii Nakryiko
parent
commit
734b3f0afe
  1. 3
      scripts/check-reallocarray.sh
  2. 2
      src/Makefile

3
scripts/check-reallocarray.sh

@ -1,4 +1,5 @@
#!/bin/sh
# Usage: check-reallocarray.sh cc_path [cc_args...]
tfile=$(mktemp /tmp/test_reallocarray_XXXXXXXX.c)
ofile=${tfile%.c}.o
@ -13,6 +14,6 @@ int main(void)
}
EOL
gcc $tfile -o $ofile >/dev/null 2>&1
"$@" $tfile -o $ofile >/dev/null 2>&1
if [ $? -ne 0 ]; then echo "FAIL"; fi
/bin/rm -f $tfile $ofile

2
src/Makefile

@ -10,7 +10,7 @@ TOPDIR = ..
INCLUDES := -I. -I$(TOPDIR)/include -I$(TOPDIR)/include/uapi
ALL_CFLAGS := $(INCLUDES)
FEATURE_REALLOCARRAY := $(shell $(TOPDIR)/scripts/check-reallocarray.sh)
FEATURE_REALLOCARRAY := $(shell $(TOPDIR)/scripts/check-reallocarray.sh $(CC))
ifneq ($(FEATURE_REALLOCARRAY),)
ALL_CFLAGS += -DCOMPAT_NEED_REALLOCARRAY
endif

Loading…
Cancel
Save