olga / rpms / glibc

Forked from rpms/glibc 5 years ago
Clone

Blame SOURCES/glibc-rh1120490.patch

51f0aa
commit 602f80ec8b966cfad3b61914cbe14ee606cedf6e
ce426f
Author: Siddhesh Poyarekar <siddhesh@redhat.com>
51f0aa
Date:   Tue Sep 16 22:16:01 2014 +0530
ce426f
ce426f
    Make __extern_always_inline usable on clang++ again
ce426f
    
ce426f
    The fix for BZ #17266 (884ddc5081278f488ef8cd49951f41cfdbb480ce)
ce426f
    removed changes that had gone into cdefs.h to make
ce426f
    __extern_always_inline usable with clang++.  This patch adds back
ce426f
    support for clang to detect if GNU inlining semantics are available,
ce426f
    this time without breaking the gcc use case.  The check put here is
ce426f
    based on the earlier patch and assertion[1] that checking if
ce426f
    __GNUC_STDC_INLINE__ or __GNUC_GNU_INLINE__ is defined is sufficient
ce426f
    to determine that clang++ suports GNU inlining semantics.
ce426f
    
ce426f
    Tested with a simple program that builds with __extern_always_inline
ce426f
    with the patch and fails compilation without it.
ce426f
    
ce426f
     #include <stdio.h>
ce426f
     #include <sys/cdefs.h>
ce426f
    
ce426f
    extern void foo_alias (void) __asm ("foo");
ce426f
    
ce426f
    __extern_always_inline void
ce426f
    foo (void)
ce426f
    {
ce426f
      puts ("hi oh world!");
ce426f
      return foo_alias ();
ce426f
    }
ce426f
    
ce426f
    void
ce426f
    foo_alias (void)
ce426f
    {
ce426f
      puts ("hell oh world");
ce426f
    }
ce426f
    
ce426f
    int
ce426f
    main ()
ce426f
    {
ce426f
      foo ();
ce426f
    }
ce426f
    
ce426f
    [1] https://sourceware.org/ml/libc-alpha/2012-12/msg00306.html
ce426f
    
ce426f
    	[BZ #17266]
ce426f
    	* misc/sys/cdefs.h: Define __extern_always_inline for clang
ce426f
    	4.2 and newer.
ce426f
ce426f
commit 884ddc5081278f488ef8cd49951f41cfdbb480ce
ce426f
Author: Siddhesh Poyarekar <siddhesh@redhat.com>
ce426f
Date:   Tue Sep 16 14:08:48 2014 +0530
ce426f
ce426f
    Revert to defining __extern_inline only for gcc-4.3+ (BZ #17266)
ce426f
    
ce426f
    The check for only __GNUC_STDC_INLINE__ and __GNUC_GNU_INLINE__ may
ce426f
    not be sufficient since those flags were added during initial support
ce426f
    for C99 inlining semantics.  There is also a problem with always
ce426f
    defining __extern_inline and __extern_always_inline, since it enables
ce426f
    inline wrapper functions even when GNU inlining semantics are not
ce426f
    guaranteed.  This, along with the possibility of such wrappers using
ce426f
    redirection (btowc for example) could result in compiler generating an
ce426f
    infinitely recusrive call to the function.
ce426f
    
ce426f
    In fact it was such a recursion that led to this code being written
ce426f
    the way it was; see:
ce426f
    
ce426f
    https://bugzilla.redhat.com/show_bug.cgi?id=186410
ce426f
    
ce426f
    The initial change was to fix bugs 14530 and 13741, but they can be
ce426f
    resolved by checking if __fortify_function and/or
ce426f
    __extern_always_inline are defined, as it has been done in this patch.
ce426f
    In addition, I have audited uses of __extern_always_inline to make
ce426f
    sure that none of the uses result in compilation errors.
ce426f
    
ce426f
    There is however a regression in this patch for llvm, since it reverts
ce426f
    the llvm expectation that __GNUC_STDC_INLINE__ or __GNUC_GNU_INLINE__
ce426f
    definition imply proper extern inline semantics.
ce426f
    
ce426f
    2014-09-16  Siddhesh Poyarekar  <siddhesh@redhat.com>
ce426f
    	    Jakub Jelinek  <jakub@redhat.com>
ce426f
    
ce426f
    	[BZ #17266]
ce426f
    	* libio/stdio.h: Check definition of __fortify_function
ce426f
    	instead of __extern_always_inline to include bits/stdio2.h.
ce426f
    	* math/bits/math-finite.h [__USE_XOPEN || __USE_ISOC99]: Also
ce426f
    	check if __extern_always_inline is defined.
ce426f
    	[__USE_MISC || __USE_XOPEN]: Likewise.
ce426f
    	[__USE_ISOC99] Likewise.
ce426f
    	* misc/sys/cdefs.h (__fortify_function): Define only if
ce426f
    	__extern_always_inline is defined.
ce426f
    	[!__cplusplus || __GNUC_PREREQ (4,3)]: Revert to defining
ce426f
    	__extern_always_inline and __extern_inline only for g++-4.3
ce426f
    	and newer or a compatible gcc.
ce426f
ce426f
diff --git glibc-2.17-c758a686/libio/stdio.h glibc-2.17-c758a686/libio/stdio.h
ce426f
index d8c0bdb..1f4f837 100644
ce426f
--- glibc-2.17-c758a686/libio/stdio.h
ce426f
+++ glibc-2.17-c758a686/libio/stdio.h
ce426f
@@ -932,7 +932,7 @@ extern void funlockfile (FILE *__stream) __THROW;
ce426f
 #ifdef __USE_EXTERN_INLINES
ce426f
 # include <bits/stdio.h>
ce426f
 #endif
ce426f
-#if __USE_FORTIFY_LEVEL > 0 && defined __extern_always_inline
ce426f
+#if __USE_FORTIFY_LEVEL > 0 && defined __fortify_function
ce426f
 # include <bits/stdio2.h>
ce426f
 #endif
ce426f
 #ifdef __LDBL_COMPAT
ce426f
diff --git glibc-2.17-c758a686/math/bits/math-finite.h glibc-2.17-c758a686/math/bits/math-finite.h
ce426f
index aa755de..0656645 100644
ce426f
--- glibc-2.17-c758a686/math/bits/math-finite.h
ce426f
+++ glibc-2.17-c758a686/math/bits/math-finite.h
ce426f
@@ -251,7 +251,8 @@ extern long double __REDIRECT_NTH (lgammal_r, (long double, int *),
ce426f
 # endif
ce426f
 #endif
ce426f
 
ce426f
-#if defined __USE_MISC || defined __USE_XOPEN || defined __USE_ISOC99
ce426f
+#if ((defined __USE_MISC || defined __USE_XOPEN || defined __USE_ISOC99) \
ce426f
+     && defined __extern_always_inline)
ce426f
 /* lgamma.  */
ce426f
 __extern_always_inline double __NTH (lgamma (double __d))
ce426f
 {
ce426f
@@ -284,7 +285,8 @@ __extern_always_inline long double __NTH (lgammal (long double __d))
ce426f
 # endif
ce426f
 #endif
ce426f
 
ce426f
-#if defined __USE_MISC || defined __USE_XOPEN
ce426f
+#if ((defined __USE_MISC || defined __USE_XOPEN) \
ce426f
+     && defined __extern_always_inline)
ce426f
 /* gamma.  */
ce426f
 __extern_always_inline double __NTH (gamma (double __d))
ce426f
 {
ce426f
@@ -422,7 +424,7 @@ extern long double __REDIRECT_NTH (sqrtl, (long double), __sqrtl_finite);
ce426f
 # endif
ce426f
 #endif
ce426f
 
ce426f
-#ifdef __USE_ISOC99
ce426f
+#if defined __USE_ISOC99 && defined __extern_always_inline
ce426f
 /* tgamma.  */
ce426f
 extern double __gamma_r_finite (double, int *);
ce426f
 __extern_always_inline double __NTH (tgamma (double __d))
ce426f
diff --git glibc-2.17-c758a686/misc/sys/cdefs.h glibc-2.17-c758a686/misc/sys/cdefs.h
ce426f
index 04db956..01e81ba 100644
ce426f
--- glibc-2.17-c758a686/misc/sys/cdefs.h
ce426f
+++ glibc-2.17-c758a686/misc/sys/cdefs.h
ce426f
@@ -131,7 +131,6 @@
ce426f
 /* Fortify support.  */
ce426f
 #define __bos(ptr) __builtin_object_size (ptr, __USE_FORTIFY_LEVEL > 1)
ce426f
 #define __bos0(ptr) __builtin_object_size (ptr, 0)
ce426f
-#define __fortify_function __extern_always_inline __attribute_artificial__
ce426f
 
ce426f
 #if __GNUC_PREREQ (4,3)
ce426f
 # define __warndecl(name, msg) \
ce426f
@@ -319,8 +318,17 @@
ce426f
 #endif
ce426f
 
ce426f
 /* GCC 4.3 and above with -std=c99 or -std=gnu99 implements ISO C99
ce426f
-   inline semantics, unless -fgnu89-inline is used.  */
ce426f
-#if (!defined __cplusplus || __GNUC_PREREQ (4,3)) && defined __GNUC__
ce426f
+   inline semantics, unless -fgnu89-inline is used.  Using __GNUC_STDC_INLINE__
ce426f
+   or __GNUC_GNU_INLINE is not a good enough check for gcc because gcc versions
ce426f
+   older than 4.3 may define these macros and still not guarantee GNU inlining
ce426f
+   semantics.
ce426f
+
ce426f
+   clang++ identifies itself as gcc-4.2, but has support for GNU inlining
ce426f
+   semantics, that can be checked fot by using the __GNUC_STDC_INLINE_ and
ce426f
+   __GNUC_GNU_INLINE__ macro definitions.  */
ce426f
+#if (!defined __cplusplus || __GNUC_PREREQ (4,3) \
ce426f
+     || (defined __clang__ && (defined __GNUC_STDC_INLINE__ \
ce426f
+			       || defined __GNUC_GNU_INLINE__)))
ce426f
 # if defined __GNUC_STDC_INLINE__ || defined __cplusplus
ce426f
 #  define __extern_inline extern __inline __attribute__ ((__gnu_inline__))
ce426f
 #  define __extern_always_inline \
ce426f
@@ -329,13 +337,10 @@
ce426f
 #  define __extern_inline extern __inline
ce426f
 #  define __extern_always_inline extern __always_inline
ce426f
 # endif
ce426f
-#elif defined __GNUC__ /* C++ and GCC <4.3.  */
ce426f
-# define __extern_inline extern __inline
ce426f
-# define __extern_always_inline \
ce426f
-  extern __always_inline
ce426f
-#else /* Not GCC.  */
ce426f
-# define __extern_inline  /* Ignore */
ce426f
-# define __extern_always_inline /* Ignore */
ce426f
+#endif
ce426f
+
ce426f
+#ifdef __extern_always_inline
ce426f
+# define __fortify_function __extern_always_inline __attribute_artificial__
ce426f
 #endif
ce426f
 
ce426f
 /* GCC 4.3 and above allow passing all anonymous arguments of an