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