diff -rupN old/config.sub new/config.sub
--- old/config.sub	2019-01-03 19:28:27.000000000 +0800
+++ new/config.sub	2022-01-18 22:22:35.569582027 +0800
@@ -2,7 +2,7 @@
 # Configuration validation subroutine script.
 #   Copyright 1992-2019 Free Software Foundation, Inc.
 
-timestamp='2019-01-01'
+timestamp='2020-06-28'
 
 # This file is free software; you can redistribute it and/or modify it
 # under the terms of the GNU General Public License as published by
@@ -1361,6 +1361,7 @@ case $os in
 	     | os2* | vos* | palmos* | uclinux* | nucleus* \
 	     | morphos* | superux* | rtmk* | windiss* \
 	     | powermax* | dnix* | nx6 | nx7 | sei* | dragonfly* \
+         | lyos* \
 	     | skyos* | haiku* | rdos* | toppers* | drops* | es* \
 	     | onefs* | tirtos* | phoenix* | fuchsia* | redox* | bme* \
 	     | midnightbsd* | amdhsa* | unleashed* | emscripten*)
diff -rupN old/gcc/config/aarch64/t-aarch64-lyos new/gcc/config/aarch64/t-aarch64-lyos
--- old/gcc/config/aarch64/t-aarch64-lyos	1970-01-01 08:00:00.000000000 +0800
+++ new/gcc/config/aarch64/t-aarch64-lyos	2022-04-07 22:11:17.324546257 +0800
@@ -0,0 +1,7 @@
+LIB1ASMSRC   = aarch64/lib1funcs.asm
+LIB1ASMFUNCS = _aarch64_sync_cache_range
+
+MULTILIB_OSDIRNAMES = mabi.lp64=../lib64$(call if_multiarch,:aarch64-lyos)
+MULTIARCH_DIRNAME = $(call if_multiarch,aarch64-lyos)
+
+MULTILIB_OSDIRNAMES += mabi.ilp32=../libilp32$(call if_multiarch,:aarch64-lyos_ilp32)
diff -rupN old/gcc/config/i386/t-lyos64 new/gcc/config/i386/t-lyos64
--- old/gcc/config/i386/t-lyos64	1970-01-01 08:00:00.000000000 +0800
+++ new/gcc/config/i386/t-lyos64	2022-01-18 22:22:35.569582027 +0800
@@ -0,0 +1,3 @@
+MULTILIB_OPTIONS = m64/m32
+MULTILIB_DIRNAMES = 64 32
+MULTILIB_OSDIRNAMES = m64=../lib64:x86_64-lyos m32=../lib32:i386-lyos
diff -rupN old/gcc/config/lyos.h new/gcc/config/lyos.h
--- old/gcc/config/lyos.h	1970-01-01 08:00:00.000000000 +0800
+++ new/gcc/config/lyos.h	2022-01-18 22:22:35.569582027 +0800
@@ -0,0 +1,27 @@
+#undef TARGET_OS_CPP_BUILTINS
+#define TARGET_OS_CPP_BUILTINS() \
+  do { \
+    builtin_define_std ("lyos"); \
+    builtin_define_std ("unix"); \
+    builtin_assert ("system=lyos"); \
+    builtin_assert ("system=unix"); \
+  } while (0);
+
+#undef STARTFILE_SPEC
+#define STARTFILE_SPEC "%{!shared:crt0.o%s} \
+   crti.o%s %{static:crtbeginT.o%s;shared|pie:crtbeginS.o%s;:crtbegin.o%s}"
+
+#undef ENDFILE_SPEC
+#define ENDFILE_SPEC "%{shared:crtendS.o%s;:crtend.o%s} crtn.o%s"
+
+#undef  LINK_SPEC
+#define LINK_SPEC "\
+  %{shared:-shared -dynamic-linker " "/lib/ld-lyos.so" "} \
+  %{!shared: \
+    %{!static: \
+      %{rdynamic:-export-dynamic} \
+      %{!dynamic-linker:-dynamic-linker " "/lib/ld-lyos.so" "}} \
+    %{static:-static}}"
+
+#undef  LIB_SPEC
+#define LIB_SPEC "%{pthread:-lpthread} %{shared:-lc} %{!shared:%{!p:%{!pg:-lc}}%{p:-lc_p}%{pg:-lc_p}}"
diff -rupN old/gcc/config.gcc new/gcc/config.gcc
--- old/gcc/config.gcc	2019-08-04 04:16:22.000000000 +0800
+++ new/gcc/config.gcc	2022-04-07 22:03:50.993727573 +0800
@@ -970,6 +970,12 @@ case ${target} in
       ;;
   esac
   ;;
+*-*-lyos*)
+  extra_options="$extra_options gnu-user.opt"
+  gas=yes
+  gnu_ld=yes
+  default_use_cxa_atexit=yes
+  ;;  
 *-*-elf|arc*-*-elf*)
   # Assume that newlib is being used and so __cxa_atexit is provided.
   default_use_cxa_atexit=yes
@@ -1050,6 +1056,13 @@ aarch64*-*-linux*)
 	done
 	TM_MULTILIB_CONFIG=`echo $TM_MULTILIB_CONFIG | sed 's/^,//'`
 	;;
+aarch64*-*-lyos*)
+	tm_file="${tm_file} dbxelf.h elfos.h gnu-user.h lyos.h glibc-stdint.h"
+	tm_file="${tm_file} aarch64/aarch64-elf.h"    
+	tmake_file="${tmake_file} aarch64/t-aarch64 aarch64/t-aarch64-lyos"
+    tm_defines="${tm_defines}  TARGET_DEFAULT_ASYNC_UNWIND_TABLES=1"
+    TM_MULTILIB_CONFIG="lp64"
+    ;;    
 alpha*-*-linux*)
 	tm_file="elfos.h ${tm_file} alpha/elf.h alpha/linux.h alpha/linux-elf.h glibc-stdint.h"
 	tmake_file="${tmake_file} alpha/t-linux alpha/t-alpha"
@@ -1135,6 +1148,11 @@ arm-wrs-vxworks|arm-wrs-vxworks7)
         tm_file="elfos.h arm/elf.h arm/aout.h ${tm_file} vx-common.h vxworks.h arm/vxworks.h"
 	target_cpu_cname="arm8"
 	;;
+arm-*-lyos*)
+	tm_file="dbxelf.h elfos.h newlib-stdint.h arm/unknown-elf.h arm/elf.h arm/aout.h arm/arm.h lyos.h"
+	tmake_file="arm/t-arm arm/t-arm-elf"
+    # thread_file="posix"
+	;;    
 arm*-*-freebsd*)                # ARM FreeBSD EABI
 	tm_file="dbxelf.h elfos.h ${fbsd_tm_file} arm/elf.h"
 	case $target in
@@ -1612,6 +1630,12 @@ hppa[12]*-*-hpux11*)
 i[34567]86-*-darwin1[89]*)
 	echo "Error: 32bit target is not supported after Darwin17" 1>&2
 	;;
+i[34567]86-*-lyos*)
+	tm_file="${tm_file} i386/unix.h i386/att.h dbxelf.h glibc-stdint.h elfos.h i386/i386elf.h lyos.h"
+	tmake_file="${tmake_file} i386/t-i386elf t-svr4 i386/t-crtstuff"
+	use_fixproto=yes
+    # thread_file="posix"
+	;;    
 i[34567]86-*-darwin*)
 	need_64bit_isa=yes
 	# Baseline choice for a machine that allows m64 support.
@@ -1780,6 +1804,10 @@ x86_64-*-linux* | x86_64-*-kfreebsd*-gnu
 	done
 	TM_MULTILIB_CONFIG=`echo $TM_MULTILIB_CONFIG | sed 's/^,//'`
 	;;
+x86_64-*-lyos*)
+	tm_file="${tm_file} i386/unix.h i386/att.h dbxelf.h glibc-stdint.h elfos.h gnu-user.h i386/x86-64.h i386/gnu-user-common.h i386/gnu-user64.h lyos.h"
+	tmake_file="${tmake_file} i386/t-lyos64"
+	;;    
 i[34567]86-pc-msdosdjgpp*)
 	xm_file=i386/xm-djgpp.h
 	tm_file="dbxcoff.h ${tm_file} i386/unix.h i386/bsd.h i386/gas.h i386/djgpp.h i386/djgpp-stdint.h"
@@ -2198,6 +2226,14 @@ microblaze*-*-elf)
 	c_target_objs="${c_target_objs} microblaze-c.o"
 	cxx_target_objs="${cxx_target_objs} microblaze-c.o"
 	tmake_file="${tmake_file} microblaze/t-microblaze"
+	;;
+riscv*-*-lyos*)
+	tm_file="elfos.h newlib-stdint.h ${tm_file} riscv/elf.h lyos.h"
+	tmake_file="${tmake_file} riscv/t-riscv"
+	# Force .init_array support.  The configure script cannot always
+	# automatically detect that GAS supports it, yet we require it.
+	gcc_cv_initfini_array=yes
+    # thread_file="posix"
         ;;
 riscv*-*-linux*)
 	tm_file="elfos.h gnu-user.h linux.h glibc-stdint.h ${tm_file} riscv/linux.h"
diff -rupN old/gcc/config.host new/gcc/config.host
--- old/gcc/config.host	2019-01-01 20:31:55.000000000 +0800
+++ new/gcc/config.host	2022-04-07 22:04:33.708536192 +0800
@@ -99,7 +99,7 @@ case ${host} in
 esac
 
 case ${host} in
-  aarch64*-*-freebsd* | aarch64*-*-linux* | aarch64*-*-fuchsia*)
+  aarch64*-*-freebsd* | aarch64*-*-linux* | aarch64*-*-fuchsia* | aarch64*-*-lyos*)
     case ${target} in
       aarch64*-*-*)
 	host_extra_gcc_objs="driver-aarch64.o"
diff -rupN old/gcc/diagnostic.c new/gcc/diagnostic.c
--- old/gcc/diagnostic.c	2019-01-01 20:31:55.000000000 +0800
+++ new/gcc/diagnostic.c	2022-01-18 22:22:35.572914201 +0800
@@ -35,9 +35,7 @@ along with GCC; see the file COPYING3.
 #include "selftest.h"
 #include "selftest-diagnostic.h"
 
-#ifdef HAVE_TERMIOS_H
-# include <termios.h>
-#endif
+#include <termios.h>
 
 #ifdef GWINSZ_IN_SYS_IOCTL
 # include <sys/ioctl.h>
diff -rupN old/gcc/limity.h new/gcc/limity.h
--- old/gcc/limity.h	2001-05-10 08:07:23.000000000 +0800
+++ new/gcc/limity.h	2022-01-18 22:22:35.572914201 +0800
@@ -1,6 +1,22 @@
 /* This administrivia gets added to the end of limits.h
    if the system has its own version of limits.h.  */
 
+#ifndef LONG_BIT
+#if LONG_MAX == INT_MAX
+#define LONG_BIT 32
+#else
+#define LONG_BIT 64
+#endif
+#endif
+
+#ifndef SSIZE_MAX
+#if INTPTR_MAX == INT64_MAX
+#define SSIZE_MAX LONG_MAX
+#elif INTPTR_MAX == INT32_MAX
+#define SSIZE_MAX INT_MAX
+#endif
+#endif
+
 #else /* not _GCC_LIMITS_H_ */
 
 #ifdef _GCC_NEXT_LIMITS_H
diff -rupN old/libgcc/config.host new/libgcc/config.host
--- old/libgcc/config.host	2019-01-17 20:29:13.000000000 +0800
+++ new/libgcc/config.host	2022-04-07 22:14:53.821665753 +0800
@@ -101,6 +101,9 @@ arc*-*-*)
 arm*-*-*)
 	cpu_type=arm
 	;;
+arm-*-lyos*)
+	extra_parts="crtbegin.o crtend.o"
+	;;    
 avr-*-*)
 	cpu_type=avr
 	;;    
@@ -366,6 +369,14 @@ aarch64*-*-linux*)
 	tmake_file="${tmake_file} ${cpu_type}/t-aarch64"
 	tmake_file="${tmake_file} ${cpu_type}/t-softfp t-softfp t-crtfm"
 	;;
+aarch64*-*-lyos*)
+	extra_parts="$extra_parts crtbegin.o crtend.o crtbeginS.o crtendS.o crtbeginT.o crtfastmath.o"
+    md_unwind_header=aarch64/aarch64-unwind.h    
+	tmake_file="$tmake_file t-crtstuff-pic t-libgcc-pic"
+    tmake_file="${tmake_file} ${cpu_type}/t-aarch64"
+    tmake_file="${tmake_file} ${cpu_type}/t-lse t-slibgcc-libgcc"
+	tmake_file="${tmake_file} ${cpu_type}/t-softfp t-softfp t-crtfm"    
+	;;    
 alpha*-*-linux*)
 	tmake_file="${tmake_file} alpha/t-alpha alpha/t-ieee t-crtfm alpha/t-linux"
 	extra_parts="$extra_parts crtfastmath.o"
@@ -686,6 +697,10 @@ x86_64-*-linux*)
 	tm_file="${tm_file} i386/elf-lib.h"
 	md_unwind_header=i386/linux-unwind.h
 	;;
+x86_64-*-lyos*)
+	tmake_file="$tmake_file i386/t-crtpc t-crtfm i386/t-crtstuff t-crtstuff-pic t-libgcc-pic t-dfprules"
+	extra_parts="$extra_parts crtbegin.o crtend.o crtbeginS.o crtendS.o crtbeginT.o crtprec32.o crtprec64.o crtprec80.o crtfastmath.o"
+	;;    
 x86_64-*-kfreebsd*-gnu)
 	extra_parts="$extra_parts crtprec32.o crtprec64.o crtprec80.o crtfastmath.o"
 	tmake_file="${tmake_file} i386/t-crtpc t-crtfm i386/t-crtstuff t-dfprules"
@@ -812,6 +827,10 @@ x86_64-*-mingw*)
 		extra_parts="$extra_parts vtv_start.o vtv_end.o vtv_start_preinit.o vtv_end_preinit.o"
 	fi
 	;;
+i[34567]86-*-lyos*)
+	tmake_file="$tmake_file i386/t-i386elf t-svr4 i386/t-crtstuff t-crtstuff-pic t-libgcc-pic"
+	extra_parts="$extra_parts crtbegin.o crtend.o crtbeginS.o crtendS.o crtbeginT.o"
+	;;    
 ia64*-*-elf*)
 	extra_parts="$extra_parts crtbeginS.o crtendS.o crtfastmath.o"
 	tmake_file="ia64/t-ia64 ia64/t-ia64-elf ia64/t-eh-ia64 t-crtfm t-softfp-tf ia64/t-softfp t-softfp ia64/t-softfp-compat"
@@ -1187,6 +1206,10 @@ riscv*-*-freebsd*)
 	tmake_file="${tmake_file} riscv/t-softfp${host_address} t-softfp riscv/t-elf riscv/t-elf${host_address}"
 	extra_parts="$extra_parts crtbegin.o crtend.o crti.o crtn.o crtendS.o crtbeginT.o"
 	;;
+riscv*-*-lyos*)
+	tmake_file="${tmake_file} t-crtstuff-pic t-libgcc-pic riscv/t-softfp${host_address} t-softfp riscv/t-elf riscv/t-elf${host_address}"
+	extra_parts="$extra_parts crtbegin.o crtend.o crtbeginS.o crtendS.o crtbeginT.o"
+	;;
 riscv*-*-*)
 	tmake_file="${tmake_file} riscv/t-softfp${host_address} t-softfp riscv/t-elf riscv/t-elf${host_address}"
 	extra_parts="$extra_parts crtbegin.o crtend.o crti.o crtn.o"
diff -rupN old/libstdc++-v3/configure new/libstdc++-v3/configure
--- old/libstdc++-v3/configure	2019-07-04 05:09:13.000000000 +0800
+++ new/libstdc++-v3/configure	2022-01-18 22:22:35.576246377 +0800
@@ -15262,8 +15262,8 @@ if test "$enable_shared" = yes; then
   glibcxx_compiler_shared_flag="-D_GLIBCXX_SHARED"
 
 else
-  glibcxx_lt_pic_flag=
-  glibcxx_compiler_pic_flag=
+  glibcxx_lt_pic_flag="-prefer-pic"
+  glibcxx_compiler_pic_flag="$lt_prog_compiler_pic_CXX"
   glibcxx_compiler_shared_flag=
 fi
 
diff -rupN old/libstdc++-v3/crossconfig.m4 new/libstdc++-v3/crossconfig.m4
--- old/libstdc++-v3/crossconfig.m4	2019-03-12 00:28:11.000000000 +0800
+++ new/libstdc++-v3/crossconfig.m4	2022-01-18 22:22:35.579578550 +0800
@@ -200,6 +200,12 @@ case "${host}" in
     AC_CHECK_FUNCS(sockatmark)
     AM_ICONV
     ;;
+  *-lyos*)
+    AC_CHECK_HEADERS([sys/types.h local.h float.h])
+    GLIBCXX_CHECK_BUILTIN_MATH_SUPPORT
+    GLIBCXX_CHECK_COMPLEX_MATH_SUPPORT
+    GLIBCXX_CHECK_STDLIB_SUPPORT
+    ;;    
   *-mingw32*)
     GLIBCXX_CHECK_LINKER_FEATURES
     GLIBCXX_CHECK_MATH_SUPPORT
