Merge changes from topic "update-clang-tools-6114689"
* changes:
versioner: Add __VERSIONER_FORTIFY_INLINE
versioner: Only enable annotation while running versioner
diff --git a/libc/include/android/versioning.h b/libc/include/android/versioning.h
index d60957f..1948890 100644
--- a/libc/include/android/versioning.h
+++ b/libc/include/android/versioning.h
@@ -16,6 +16,10 @@
#pragma once
+// The `annotate` attribute always pulls the annotated (inline) function into the object files, thus
+// we should only annotate headers when we are running versioner.
+#if defined(__BIONIC_VERSIONER)
+
#define __INTRODUCED_IN(api_level) __attribute__((annotate("introduced_in=" #api_level)))
#define __DEPRECATED_IN(api_level) __attribute__((annotate("deprecated_in=" #api_level)))
#define __REMOVED_IN(api_level) __attribute__((annotate("obsoleted_in=" #api_level)))
@@ -26,3 +30,20 @@
#define __INTRODUCED_IN_MIPS(api_level) __attribute__((annotate("introduced_in_mips=" #api_level)))
#define __VERSIONER_NO_GUARD __attribute__((annotate("versioner_no_guard")))
+#define __VERSIONER_FORTIFY_INLINE __attribute__((annotate("versioner_fortify_inline")))
+
+#else
+
+#define __INTRODUCED_IN(api_level)
+#define __DEPRECATED_IN(api_level)
+#define __REMOVED_IN(api_level)
+#define __INTRODUCED_IN_32(api_level)
+#define __INTRODUCED_IN_64(api_level)
+#define __INTRODUCED_IN_ARM(api_level)
+#define __INTRODUCED_IN_X86(api_level)
+#define __INTRODUCED_IN_MIPS(api_level)
+
+#define __VERSIONER_NO_GUARD
+#define __VERSIONER_FORTIFY_INLINE
+
+#endif // defined(__BIONIC_VERSIONER)
diff --git a/libc/include/sys/cdefs.h b/libc/include/sys/cdefs.h
index eb30690..9e214e5 100644
--- a/libc/include/sys/cdefs.h
+++ b/libc/include/sys/cdefs.h
@@ -277,7 +277,7 @@
* Because clang-FORTIFY uses overloads, we can't mark functions as `extern
* inline` without making them available externally.
*/
-# define __BIONIC_FORTIFY_INLINE static __inline__ __always_inline
+# define __BIONIC_FORTIFY_INLINE static __inline__ __always_inline __VERSIONER_FORTIFY_INLINE
/*
* We should use __BIONIC_FORTIFY_VARIADIC instead of __BIONIC_FORTIFY_INLINE
* for variadic functions because compilers cannot inline them.