tensorflow/tensorflow

View on GitHub
ci/official/containers/linux_arm64/builder.devtoolset/gcc9-fixups.patch

Summary

Maintainability
Test Coverage
diff --git a/iconv/gconv.h b/iconv/gconv.h
index 3f9112e..8e60197 100644
--- a/iconv/gconv.h
+++ b/iconv/gconv.h
@@ -174,7 +174,7 @@ typedef struct __gconv_info
 {
   size_t __nsteps;
   struct __gconv_step *__steps;
-  __extension__ struct __gconv_step_data __data __flexarr;
+  __extension__ struct __gconv_step_data __data[0];
 } *__gconv_t;
 
 #endif /* gconv.h */
diff --git a/include/libc-symbols.h b/include/libc-symbols.h
index c555bf2..143b26d 100644
--- a/include/libc-symbols.h
+++ b/include/libc-symbols.h
@@ -107,6 +107,11 @@
 # endif
 #endif
 
+#ifndef __attribute_copy__
+/* Provide an empty definition when cdefs.h is not included.  */
+# define __attribute_copy__(arg)
+#endif
+
 #ifndef __ASSEMBLER__
 /* GCC understands weak symbols and aliases; use its interface where
    possible, instead of embedded assembly language.  */
@@ -114,7 +119,8 @@
 /* Define ALIASNAME as a strong alias for NAME.  */
 # define strong_alias(name, aliasname) _strong_alias(name, aliasname)
 # define _strong_alias(name, aliasname) \
-  extern __typeof (name) aliasname __attribute__ ((alias (#name)));
+  extern __typeof (name) aliasname __attribute__ ((alias (#name))) \
+    __attribute_copy__ (name);
 
 /* This comes between the return type and function name in
    a function definition to make that definition weak.  */
@@ -125,14 +131,16 @@
    If weak aliases are not available, this defines a strong alias.  */
 # define weak_alias(name, aliasname) _weak_alias (name, aliasname)
 # define _weak_alias(name, aliasname) \
-  extern __typeof (name) aliasname __attribute__ ((weak, alias (#name)));
+  extern __typeof (name) aliasname __attribute__ ((weak, alias (#name))) \
+    __attribute_copy__ (name);
 
 /* Same as WEAK_ALIAS, but mark symbol as hidden.  */
 # define weak_hidden_alias(name, aliasname) \
   _weak_hidden_alias (name, aliasname)
 # define _weak_hidden_alias(name, aliasname) \
   extern __typeof (name) aliasname \
-    __attribute__ ((weak, alias (#name), __visibility__ ("hidden")));
+    __attribute__ ((weak, alias (#name), __visibility__ ("hidden"))) \
+    __attribute_copy__ (name);
 
 /* Declare SYMBOL as weak undefined symbol (resolved to 0 if not defined).  */
 # define weak_extern(symbol) _weak_extern (weak symbol)
@@ -528,7 +536,8 @@ for linking")
 #  define __hidden_ver1(local, internal, name) \
   extern __typeof (name) __EI_##name __asm__(__hidden_asmname (#internal)); \
   extern __typeof (name) __EI_##name \
-    __attribute__((alias (__hidden_asmname (#local))))
+    __attribute__((alias (__hidden_asmname (#local))))    \
+    __attribute_copy__ (name)
 #  define hidden_ver(local, name)    __hidden_ver1(local, __GI_##name, name);
 #  define hidden_data_ver(local, name)    hidden_ver(local, name)
 #  define hidden_def(name)        __hidden_ver1(__GI_##name, name, name);
@@ -541,7 +550,8 @@ for linking")
 #  define __hidden_nolink1(local, internal, name, version) \
   __hidden_nolink2 (local, internal, name, version)
 #  define __hidden_nolink2(local, internal, name, version) \
-  extern __typeof (name) internal __attribute__ ((alias (#local))); \
+  extern __typeof (name) internal __attribute__ ((alias (#local)))    \
+    __attribute_copy__ (name);                        \
   __hidden_nolink3 (local, internal, #name "@" #version)
 #  define __hidden_nolink3(local, internal, vername) \
   __asm__ (".symver " #internal ", " vername);
diff --git a/locale/weightwc.h b/locale/weightwc.h
index e966c03..22ab790 100644
--- a/locale/weightwc.h
+++ b/locale/weightwc.h
@@ -79,19 +79,19 @@ findidx (const wint_t **cpp, size_t len)
         if (cp[cnt] != usrc[cnt])
           break;
 
-      if (cnt < nhere - 1)
+      if (cnt < nhere - 1 || cnt == len)
         {
           cp += 2 * nhere;
           continue;
         }
 
-      if (cp[nhere - 1] > usrc[nhere -1])
+      if (cp[nhere - 1] > usrc[nhere - 1])
         {
           cp += 2 * nhere;
           continue;
         }
 
-      if (cp[2 * nhere - 1] < usrc[nhere -1])
+      if (cp[2 * nhere - 1] < usrc[nhere - 1])
         {
           cp += 2 * nhere;
           continue;
diff --git a/locale/xlocale.h b/locale/xlocale.h
index 98c080b..843bd45 100644
--- a/locale/xlocale.h
+++ b/locale/xlocale.h
@@ -20,6 +20,9 @@
 #ifndef _XLOCALE_H
 #define _XLOCALE_H    1
 
+#ifndef _BITS_TYPES___LOCALE_T_H
+#define _BITS_TYPES___LOCALE_T_H 1
+
 /* Structure for reentrant locale using functions.  This is an
    (almost) opaque type for the user level programs.  The file and
    this data structure is not standardized.  Don't rely on it.  It can
@@ -41,4 +44,6 @@ typedef struct __locale_struct
 /* POSIX 2008 makes locale_t official.  */
 typedef __locale_t locale_t;
 
+#endif /* bits/types/__locale_t.h */
+
 #endif /* xlocale.h */
diff --git a/misc/sys/cdefs.h b/misc/sys/cdefs.h
index d1cb3dd..30482a1 100644
--- a/misc/sys/cdefs.h
+++ b/misc/sys/cdefs.h
@@ -423,4 +423,14 @@
 # endif
 #endif
 
+/* Undefine (also defined in libc-symbols.h).  */
+#undef __attribute_copy__
+#if __GNUC_PREREQ (9, 0)
+/* Copies attributes from the declaration or type referenced by
+   the argument.  */
+# define __attribute_copy__(arg) __attribute__ ((__copy__ (arg)))
+#else
+# define __attribute_copy__(arg)
+#endif
+
 #endif     /* sys/cdefs.h */
diff --git a/stdlib/setenv.c b/stdlib/setenv.c
index 45efe2e..06bfab0 100644
--- a/stdlib/setenv.c
+++ b/stdlib/setenv.c
@@ -319,6 +319,7 @@ unsetenv (const char *name)
 
   ep = __environ;
   if (ep != NULL)
+  {
     while (*ep != NULL)
       if (!strncmp (*ep, name, len) && (*ep)[len] == '=')
     {
@@ -332,6 +333,7 @@ unsetenv (const char *name)
     }
       else
     ++ep;
+  }
 
   UNLOCK;
 
diff --git a/support/Makefile b/support/Makefile
index a253698..2f4e2a9 100644
--- a/support/Makefile
+++ b/support/Makefile
@@ -167,13 +167,6 @@ CFLAGS-support_paths.c = \
         -DINSTDIR_PATH=\"$(prefix)\" \
         -DLIBDIR_PATH=\"$(libdir)\"
 
-ifeq (,$(CXX))
-LINKS_DSO_PROGRAM = links-dso-program-c
-else
-LINKS_DSO_PROGRAM = links-dso-program
-LDLIBS-links-dso-program = -lstdc++ -lgcc -lgcc_s $(libunwind)
-endif
-
 LDLIBS-test-container = $(libsupport)
 
 others += test-container
@@ -182,9 +175,6 @@ others-noinstall += test-container
 others += shell-container echo-container true-container
 others-noinstall += shell-container echo-container true-container
 
-others += $(LINKS_DSO_PROGRAM)
-others-noinstall += $(LINKS_DSO_PROGRAM)
-
 $(objpfx)test-container : $(libsupport)
 $(objpfx)shell-container : $(libsupport)
 $(objpfx)echo-container : $(libsupport)
diff --git a/support/links-dso-program.cc b/support/links-dso-program.cc
index 8ff3155..f9d2b77 100644
--- a/support/links-dso-program.cc
+++ b/support/links-dso-program.cc
@@ -3,6 +3,11 @@
    backported.  */
 #define _ISOMAC 1
 
+#define __GLIBC_USE(F)    __GLIBC_USE_ ## F
+
+# define __attribute_alloc_size__(params) \
+  __attribute__ ((__alloc_size__ params))
+
 #include <iostream>
 
 using namespace std;
diff --git a/sysdeps/aarch64/dl-machine.h b/sysdeps/aarch64/dl-machine.h
index 185402f..bbdeae0 100644
--- a/sysdeps/aarch64/dl-machine.h
+++ b/sysdeps/aarch64/dl-machine.h
@@ -49,23 +49,11 @@ elf_machine_load_address (void)
   /* To figure out the load address we use the definition that for any symbol:
      dynamic_addr(symbol) = static_addr(symbol) + load_addr
 
-     The choice of symbol is arbitrary. The static address we obtain
-     by constructing a non GOT reference to the symbol, the dynamic
-     address of the symbol we compute using adrp/add to compute the
-     symbol's address relative to the PC. */
-
-  ElfW(Addr) static_addr;
-  ElfW(Addr) dynamic_addr;
-
-  asm ("                    \n\
-    adrp    %1, _dl_start;            \n\
-        add    %1, %1, #:lo12:_dl_start        \n\
-        ldr    %w0, 1f                \n\
-    b    2f                \n\
-1:    .word    _dl_start            \n\
-2:                        \n\
-       " : "=r" (static_addr),  "=r" (dynamic_addr));
-  return dynamic_addr - static_addr;
+    _DYNAMIC sysmbol is used here as its link-time address stored in
+    the special unrelocated first GOT entry.  */
+
+    extern ElfW(Dyn) _DYNAMIC[] attribute_hidden;
+    return (ElfW(Addr)) &_DYNAMIC - elf_machine_dynamic ();
 }
 
 /* Set up the loaded object described by L so its unrelocated PLT
diff --git a/sysdeps/ieee754/dbl-64/k_rem_pio2.c b/sysdeps/ieee754/dbl-64/k_rem_pio2.c
index fcf956a..e2c5d29 100644
--- a/sysdeps/ieee754/dbl-64/k_rem_pio2.c
+++ b/sysdeps/ieee754/dbl-64/k_rem_pio2.c
@@ -172,7 +172,8 @@ int __kernel_rem_pio2(double *x, double *y, int e0, int nx, int prec, const int3
 
     /* compute q[0],q[1],...q[jk] */
     for (i=0;i<=jk;i++) {
-        for(j=0,fw=0.0;j<=jx;j++) fw += x[j]*f[jx+i-j]; q[i] = fw;
+        for(j=0,fw=0.0;j<=jx;j++) fw += x[j]*f[jx+i-j];
+        q[i] = fw;
     }
 
     jz = jk;
diff --git a/sysdeps/ieee754/flt-32/k_rem_pio2f.c b/sysdeps/ieee754/flt-32/k_rem_pio2f.c
index e54a067..215b0e0 100644
--- a/sysdeps/ieee754/flt-32/k_rem_pio2f.c
+++ b/sysdeps/ieee754/flt-32/k_rem_pio2f.c
@@ -65,7 +65,8 @@ int __kernel_rem_pio2f(float *x, float *y, int e0, int nx, int prec, const int32
 
     /* compute q[0],q[1],...q[jk] */
     for (i=0;i<=jk;i++) {
-        for(j=0,fw=0.0;j<=jx;j++) fw += x[j]*f[jx+i-j]; q[i] = fw;
+        for(j=0,fw=0.0;j<=jx;j++) fw += x[j]*f[jx+i-j];
+        q[i] = fw;
     }
 
     jz = jk;