From fc2b569f83ff477a3ce6aebcd543aef13d4cb70e Mon Sep 17 00:00:00 2001 From: jjm2473 <1129525450@qq.com> Date: Thu, 19 Nov 2020 13:03:21 +0800 Subject: [PATCH] fix build with clang 12.0.0 (cherry picked from commit ac7bceea9765b8c686c29fd52bbb239016fa000b) (cherry picked from commit 4f2b9ff72948243ba2f8fe9f540e2dcd59e63726) --- package/libs/nettle/patches/001-clang.patch | 70 ++++++++++ target/linux/Makefile | 30 +++- toolchain/gdb/patches/001-clang.patch | 144 ++++++++++++++++++++ tools/bc/patches/002-clang.patch | 10 ++ tools/libelf/patches/001-clang.patch | 84 ++++++++++++ tools/ucl/patches/001-clang.patch | 10 ++ 6 files changed, 347 insertions(+), 1 deletion(-) create mode 100644 package/libs/nettle/patches/001-clang.patch create mode 100644 toolchain/gdb/patches/001-clang.patch create mode 100644 tools/bc/patches/002-clang.patch create mode 100644 tools/libelf/patches/001-clang.patch create mode 100644 tools/ucl/patches/001-clang.patch diff --git a/package/libs/nettle/patches/001-clang.patch b/package/libs/nettle/patches/001-clang.patch new file mode 100644 index 0000000000..7498d0f931 --- /dev/null +++ b/package/libs/nettle/patches/001-clang.patch @@ -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 ], [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 < + int + main () + { +@@ -588,6 +589,7 @@ AC_CACHE_CHECK([for build system executa + gmp_cv_prog_exeext_for_build="$EXEEXT" + else + cat >conftest.c < + 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 < + 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 < + 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 < + int + main () + { +@@ -4753,6 +4756,7 @@ else + gmp_cv_prog_exeext_for_build="$EXEEXT" + else + cat >conftest.c < + int + main () + { +@@ -6743,7 +6747,7 @@ else + CFLAGS="$CFLAGS $CCPIC" + cat confdefs.h - <<_ACEOF >conftest.$ac_ext + /* end confdefs.h. */ +- ++#include + int + main () + { diff --git a/target/linux/Makefile b/target/linux/Makefile index a939d42bc0..fa937dd9bb 100644 --- a/target/linux/Makefile +++ b/target/linux/Makefile @@ -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 ' >> $@ + $(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 $@ diff --git a/toolchain/gdb/patches/001-clang.patch b/toolchain/gdb/patches/001-clang.patch new file mode 100644 index 0000000000..9d7632ba39 --- /dev/null +++ b/toolchain/gdb/patches/001-clang.patch @@ -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 + #include + #ifdef HAVE_UNISTD_H + #include +@@ -5016,6 +5017,7 @@ else + cat confdefs.h - <<_ACEOF >conftest.$ac_ext + /* end confdefs.h. */ + ++#include + #ifdef HAVE_UNISTD_H + #include + #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 ++#endif ++#ifdef HAVE_TERMIO_H ++# include ++#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 + #ifdef HAVE_UNISTD_H + #include + #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 + #include + #ifdef HAVE_UNISTD_H + #include +@@ -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 ++#endif ++#ifdef HAVE_TERMIO_H ++# include ++#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 +-#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 +-#endif /* GWINSZ_IN_SYS_IOCTL && !TIOCGWINSZ */ ++#endif /* (GWINSZ_IN_SYS_IOCTL && !TIOCGWINSZ) || !TERMIO_HAVE_IOCTL*/ + + #ifdef __MSDOS__ + # include diff --git a/tools/bc/patches/002-clang.patch b/tools/bc/patches/002-clang.patch new file mode 100644 index 0000000000..44b7d2d03f --- /dev/null +++ b/tools/bc/patches/002-clang.patch @@ -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 + #include + #if ((' ' & 0x0FF) == 0x020) + # define ISLOWER(c) ('a' <= (c) && (c) <= 'z') diff --git a/tools/libelf/patches/001-clang.patch b/tools/libelf/patches/001-clang.patch new file mode 100644 index 0000000000..2755faff1d --- /dev/null +++ b/tools/libelf/patches/001-clang.patch @@ -0,0 +1,84 @@ +--- a/configure ++++ b/configure +@@ -1115,6 +1115,7 @@ else + #line 1116 "configure" + #include "confdefs.h" + #include ++#include + #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 < + #include + main() + { +@@ -1522,6 +1524,7 @@ else + cat > conftest.$ac_ext < + #include + main() + { +@@ -1561,6 +1564,7 @@ else + cat > conftest.$ac_ext < + #include + main() + { +@@ -1600,6 +1604,7 @@ else + cat > conftest.$ac_ext < + #include + main() + { +@@ -1640,6 +1645,7 @@ else + cat > conftest.$ac_ext < + #include + main() + { +@@ -2262,6 +2268,8 @@ else + #include + #include + ++#include ++ + /* 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 < + #if HAVE_MEMMOVE + extern void *memmove(); + #else +@@ -3296,6 +3304,7 @@ else + cat > conftest.$ac_ext < + #include + int + main(int argc, char **argv) { +@@ -3378,6 +3387,7 @@ else + cat > conftest.$ac_ext < + #include + int + main(int argc, char **argv) { diff --git a/tools/ucl/patches/001-clang.patch b/tools/ucl/patches/001-clang.patch new file mode 100644 index 0000000000..85593670ac --- /dev/null +++ b/tools/ucl/patches/001-clang.patch @@ -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 ++#include + #if ((' ' & 0x0FF) == 0x020) + # define ISLOWER(c) ('a' <= (c) && (c) <= 'z') + # define TOUPPER(c) (ISLOWER(c) ? 'A' + ((c) - 'a') : (c))