fix build with clang 12.0.0

(cherry picked from commit ac7bceea9765b8c686c29fd52bbb239016fa000b)
(cherry picked from commit 4f2b9ff72948243ba2f8fe9f540e2dcd59e63726)
This commit is contained in:
jjm2473 2020-11-19 13:03:21 +08:00
parent b7bbcfbb6a
commit fc2b569f83
6 changed files with 347 additions and 1 deletions

View File

@ -0,0 +1,70 @@
--- a/aclocal.m4
+++ b/aclocal.m4
@@ -53,7 +53,7 @@ AC_CACHE_VAL(lsh_cv_sys_ccpic,[
fi
OLD_CFLAGS="$CFLAGS"
CFLAGS="$CFLAGS $CCPIC"
- AC_TRY_COMPILE([], [exit(0);],
+ AC_TRY_COMPILE([#include <stdlib.h>], [exit(0);],
lsh_cv_sys_ccpic="$CCPIC", lsh_cv_sys_ccpic='')
CFLAGS="$OLD_CFLAGS"
])
@@ -547,6 +547,7 @@ AC_DEFUN([GMP_PROG_CC_FOR_BUILD_WORKS],
# remove anything that might look like compiler output to our "||" expression
rm -f conftest* a.out b.out a.exe a_out.exe
cat >conftest.c <<EOF
+#include <stdlib.h>
int
main ()
{
@@ -588,6 +589,7 @@ AC_CACHE_CHECK([for build system executa
gmp_cv_prog_exeext_for_build="$EXEEXT"
else
cat >conftest.c <<EOF
+#include <stdlib.h>
int
main ()
{
--- a/configure
+++ b/configure
@@ -4635,6 +4635,7 @@ $as_echo_n "checking build system compil
# remove anything that might look like compiler output to our "||" expression
rm -f conftest* a.out b.out a.exe a_out.exe
cat >conftest.c <<EOF
+#include <stdlib.h>
int
main ()
{
@@ -4667,6 +4668,7 @@ $as_echo_n "checking build system compil
# remove anything that might look like compiler output to our "||" expression
rm -f conftest* a.out b.out a.exe a_out.exe
cat >conftest.c <<EOF
+#include <stdlib.h>
int
main ()
{
@@ -4703,6 +4705,7 @@ $as_echo_n "checking build system compil
# remove anything that might look like compiler output to our "||" expression
rm -f conftest* a.out b.out a.exe a_out.exe
cat >conftest.c <<EOF
+#include <stdlib.h>
int
main ()
{
@@ -4753,6 +4756,7 @@ else
gmp_cv_prog_exeext_for_build="$EXEEXT"
else
cat >conftest.c <<EOF
+#include <stdlib.h>
int
main ()
{
@@ -6743,7 +6747,7 @@ else
CFLAGS="$CFLAGS $CCPIC"
cat confdefs.h - <<_ACEOF >conftest.$ac_ext
/* end confdefs.h. */
-
+#include <stdlib.h>
int
main ()
{

View File

@ -7,5 +7,33 @@ include $(INCLUDE_DIR)/target.mk
export TARGET_BUILD=1
prereq clean download prepare compile install oldconfig menuconfig nconfig xconfig update refresh: FORCE
prereq clean download prepare compile install oldconfig menuconfig nconfig xconfig update refresh: darwin FORCE
@+$(NO_TRACE_MAKE) -C $(BOARD) $@
.PHONY: darwin
darwin: $(STAGING_DIR_HOST)/include/asm/.ready
ifeq ($(HOST_OS),Darwin)
$(STAGING_DIR_HOST)/include/asm/.ready: $(STAGING_DIR_HOST)/include/asm/types.h $(STAGING_DIR_HOST)/include/asm/posix_types.h
touch $(STAGING_DIR_HOST)/include/asm/.ready
else
$(STAGING_DIR_HOST)/include/asm/.ready:
mkdir -p $(STAGING_DIR_HOST)/include/asm
echo 'Not darwin' > $(STAGING_DIR_HOST)/include/asm/.ready
endif
$(STAGING_DIR_HOST)/include/asm/types.h: Makefile
mkdir -p $(STAGING_DIR_HOST)/include/asm
echo '// auto generated by target/linux/Makefile, for macos host build tools' > $@
echo '#ifndef __ASM_TYPES_H' >> $@
echo '#define __ASM_TYPES_H' >> $@
echo '#include <stdint.h>' >> $@
$(foreach bw, 8 16 32 64,\
echo 'typedef uint$(bw)_t __u$(bw);' >> $@ ; \
echo 'typedef int$(bw)_t __s$(bw);' >> $@ ; \
)
echo '#endif' >> $@
$(STAGING_DIR_HOST)/include/asm/posix_types.h: Makefile
mkdir -p $(STAGING_DIR_HOST)/include/asm
touch $@

View File

@ -0,0 +1,144 @@
--- a/readline/configure
+++ b/readline/configure
@@ -4938,6 +4938,7 @@ else
cat confdefs.h - <<_ACEOF >conftest.$ac_ext
/* end confdefs.h. */
+#include <stdlib.h>
#include <signal.h>
#ifdef HAVE_UNISTD_H
#include <unistd.h>
@@ -5016,6 +5017,7 @@ else
cat confdefs.h - <<_ACEOF >conftest.$ac_ext
/* end confdefs.h. */
+#include <stdlib.h>
#ifdef HAVE_UNISTD_H
#include <unistd.h>
#endif
@@ -5334,6 +5336,43 @@ $as_echo "#define GWINSZ_IN_SYS_IOCTL 1"
fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for ioctl in termio.h termios.h" >&5
+$as_echo_n "checking for ioctl in termio.h termios.h... " >&6; }
+if ${bash_cv_termio_have_ioctl+:} false; then :
+ $as_echo_n "(cached) " >&6
+else
+ cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h. */
+#ifdef HAVE_TERMIOS_H
+# include <termios.h>
+#endif
+#ifdef HAVE_TERMIO_H
+# include <termio.h>
+#endif
+int
+main ()
+{
+ioctl(0, 0, 0);
+ ;
+ return 0;
+}
+_ACEOF
+if ac_fn_c_try_compile "$LINENO"; then :
+ bash_cv_termio_have_ioctl=yes
+else
+ bash_cv_termio_have_ioctl=no
+fi
+rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+fi
+
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $bash_cv_termio_have_ioctl" >&5
+$as_echo "$bash_cv_termio_have_ioctl" >&6; }
+if test $bash_cv_termio_have_ioctl = yes; then
+$as_echo "#define TERMIO_HAVE_IOCTL 1" >>confdefs.h
+
+fi
+
+
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for sig_atomic_t in signal.h" >&5
$as_echo_n "checking for sig_atomic_t in signal.h... " >&6; }
if ${ac_cv_have_sig_atomic_t+:} false; then :
--- a/readline/aclocal.m4
+++ b/readline/aclocal.m4
@@ -780,6 +780,7 @@ AC_DEFUN(BASH_FUNC_POSIX_SETJMP,
AC_MSG_CHECKING(for presence of POSIX-style sigsetjmp/siglongjmp)
AC_CACHE_VAL(bash_cv_func_sigsetjmp,
[AC_TRY_RUN([
+#include <stdlib.h>
#ifdef HAVE_UNISTD_H
#include <unistd.h>
#endif
@@ -1300,6 +1301,7 @@ AC_REQUIRE([BASH_SYS_SIGNAL_VINTAGE])
AC_MSG_CHECKING([if signal handlers must be reinstalled when invoked])
AC_CACHE_VAL(bash_cv_must_reinstall_sighandlers,
[AC_TRY_RUN([
+#include <stdlib.h>
#include <signal.h>
#ifdef HAVE_UNISTD_H
#include <unistd.h>
@@ -1493,6 +1495,24 @@ AC_DEFINE(GWINSZ_IN_SYS_IOCTL)
fi
])
+AC_DEFUN(BASH_TERMIO_HAVE_IOCTL,
+[AC_MSG_CHECKING(for ioctl in termio.h termios.h)
+AC_CACHE_VAL(bash_cv_termio_have_ioctl,
+[AC_TRY_COMPILE([
+#ifdef HAVE_TERMIOS_H
+# include <termios.h>
+#endif
+#ifdef HAVE_TERMIO_H
+# include <termio.h>
+#endif
+], [ioctl(0, 0, 0);],
+ bash_cv_termio_have_ioctl=yes,bash_cv_termio_have_ioctl=no)])
+AC_MSG_RESULT($bash_cv_termio_have_ioctl)
+if test $bash_cv_termio_have_ioctl = yes; then
+AC_DEFINE(TERMIO_HAVE_IOCTL)
+fi
+])
+
AC_DEFUN(BASH_HAVE_TIOCSTAT,
[AC_MSG_CHECKING(for TIOCSTAT in sys/ioctl.h)
AC_CACHE_VAL(bash_cv_tiocstat_in_ioctl,
--- a/readline/config.h.in
+++ b/readline/config.h.in
@@ -236,6 +236,8 @@
#undef GWINSZ_IN_SYS_IOCTL
+#undef TERMIO_HAVE_IOCTL
+
#undef STRUCT_WINSIZE_IN_SYS_IOCTL
#undef STRUCT_WINSIZE_IN_TERMIOS
--- a/readline/rltty.c
+++ b/readline/rltty.c
@@ -37,9 +37,9 @@
#include "rldefs.h"
-#if defined (GWINSZ_IN_SYS_IOCTL)
+#if defined (GWINSZ_IN_SYS_IOCTL) || !defined (TERMIO_HAVE_IOCTL)
# include <sys/ioctl.h>
-#endif /* GWINSZ_IN_SYS_IOCTL */
+#endif /* GWINSZ_IN_SYS_IOCTL || !TERMIO_HAVE_IOCTL */
#include "rltty.h"
#include "readline.h"
--- a/readline/terminal.c
+++ b/readline/terminal.c
@@ -51,9 +51,9 @@
/* System-specific feature definitions and include files. */
#include "rldefs.h"
-#if defined (GWINSZ_IN_SYS_IOCTL) && !defined (TIOCGWINSZ)
+#if (defined (GWINSZ_IN_SYS_IOCTL) && !defined (TIOCGWINSZ)) || !defined (TERMIO_HAVE_IOCTL)
# include <sys/ioctl.h>
-#endif /* GWINSZ_IN_SYS_IOCTL && !TIOCGWINSZ */
+#endif /* (GWINSZ_IN_SYS_IOCTL && !TIOCGWINSZ) || !TERMIO_HAVE_IOCTL*/
#ifdef __MSDOS__
# include <pc.h>

View File

@ -0,0 +1,10 @@
--- a/configure
+++ b/configure
@@ -3236,6 +3236,7 @@ _ACEOF
cat confdefs.h >>conftest.$ac_ext
cat >>conftest.$ac_ext <<_ACEOF
/* end confdefs.h. */
+#include <stdlib.h>
#include <ctype.h>
#if ((' ' & 0x0FF) == 0x020)
# define ISLOWER(c) ('a' <= (c) && (c) <= 'z')

View File

@ -0,0 +1,84 @@
--- a/configure
+++ b/configure
@@ -1115,6 +1115,7 @@ else
#line 1116 "configure"
#include "confdefs.h"
#include <ctype.h>
+#include <stdlib.h>
#define ISLOWER(c) ('a' <= (c) && (c) <= 'z')
#define TOUPPER(c) (ISLOWER(c) ? 'A' + ((c) - 'a') : (c))
#define XOR(e, f) (((e) && !(f)) || (!(e) && (f)))
@@ -1483,6 +1484,7 @@ else
cat > conftest.$ac_ext <<EOF
#line 1485 "configure"
#include "confdefs.h"
+#include <stdlib.h>
#include <stdio.h>
main()
{
@@ -1522,6 +1524,7 @@ else
cat > conftest.$ac_ext <<EOF
#line 1524 "configure"
#include "confdefs.h"
+#include <stdlib.h>
#include <stdio.h>
main()
{
@@ -1561,6 +1564,7 @@ else
cat > conftest.$ac_ext <<EOF
#line 1563 "configure"
#include "confdefs.h"
+#include <stdlib.h>
#include <stdio.h>
main()
{
@@ -1600,6 +1604,7 @@ else
cat > conftest.$ac_ext <<EOF
#line 1602 "configure"
#include "confdefs.h"
+#include <stdlib.h>
#include <stdio.h>
main()
{
@@ -1640,6 +1645,7 @@ else
cat > conftest.$ac_ext <<EOF
#line 1642 "configure"
#include "confdefs.h"
+#include <stdlib.h>
#include <stdio.h>
main()
{
@@ -2262,6 +2268,8 @@ else
#include <fcntl.h>
#include <sys/mman.h>
+#include <stdlib.h>
+
/* This mess was copied from the GNU getpagesize.h. */
#ifndef HAVE_GETPAGESIZE
# ifdef HAVE_UNISTD_H
@@ -2526,7 +2534,7 @@ else
cat > conftest.$ac_ext <<EOF
#line 2528 "configure"
#include "confdefs.h"
-#include "confdefs.h"
+#include <stdlib.h>
#if HAVE_MEMMOVE
extern void *memmove();
#else
@@ -3296,6 +3304,7 @@ else
cat > conftest.$ac_ext <<EOF
#line 3298 "configure"
#include "confdefs.h"
+#include <stdlib.h>
#include <stdio.h>
int
main(int argc, char **argv) {
@@ -3378,6 +3387,7 @@ else
cat > conftest.$ac_ext <<EOF
#line 3380 "configure"
#include "confdefs.h"
+#include <stdlib.h>
#include <stdio.h>
int
main(int argc, char **argv) {

View File

@ -0,0 +1,10 @@
--- a/configure
+++ b/configure
@@ -5065,6 +5065,7 @@ cat confdefs.h >>conftest.$ac_ext
cat >>conftest.$ac_ext <<_ACEOF
/* end confdefs.h. */
#include <ctype.h>
+#include <stdlib.h>
#if ((' ' & 0x0FF) == 0x020)
# define ISLOWER(c) ('a' <= (c) && (c) <= 'z')
# define TOUPPER(c) (ISLOWER(c) ? 'A' + ((c) - 'a') : (c))