Skip to contentSkip to conversation

Compiler Attributes: update GCC and Clang's `counted_by` URLs

PATCH In review Miguel Ojeda 2 participants 10 messages Aug 3, 2024 – Aug 4, 2024 Compiler attributes

lore
Share & tools
lore

Miguel Ojeda

author maintainer
#0 lore raw

PATCH 1/5 Compiler Attributes: update GCC and Clang's `counted_by` URLs

Clang 18 was released with support for counted_by, thus point to the documentation now instead of the implementation PR.

Similarly, GCC's bugzilla issue is now closed and GCC has a documentation page for it.

---
 include/linux/compiler_attributes.h | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
include/linux/compiler_attributes.h +2 -2
index 32284cd26d52..b658136e6cda 100644
@@ -98,8 +98,8 @@
  * Optional: only supported since gcc >= 15
  * Optional: only supported since clang >= 18
  *
- *   gcc: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=108896
- * clang: https://github.com/llvm/llvm-project/pull/76348
+ *   gcc: https://gcc.gnu.org/onlinedocs/gcc/Common-Variable-Attributes.html#index-counted_005fby-variable-attribute
+ * clang: https://clang.llvm.org/docs/AttributeReference.html#counted-by
  */
 #if __has_attribute(__counted_by__)
 # define __counted_by(member)		__attribute__((__counted_by__(member)))

base-commit: 8400291e289ee6b2bf9779ff1c83a291501f017b

Signature · 1 line
2.46.0
author maintainer
#1 lore raw

PATCH 2/5 Compiler Attributes: remove unneeded version comments for older LLVMs

The kernel upgraded to support only LLVM >= 13 in commit 9c1b86f8ce04 ("kbuild: raise the minimum supported version of LLVM to 13.0.1"), thus remove version comments that are not needed anymore.

---
 include/linux/compiler_attributes.h | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
include/linux/compiler_attributes.h +2 -2
index b658136e6cda..5d171a7f8cbd 100644
@@ -256,7 +256,7 @@
 #endif
 
 /*
- * Optional: only supported since GCC >= 7.1, clang >= 13.0.
+ * Optional: only supported since GCC >= 7.1
  *
  *      gcc: https://gcc.gnu.org/onlinedocs/gcc/Common-Function-Attributes.html#index-no_005fprofile_005finstrument_005ffunction-function-attribute
  *    clang: https://clang.llvm.org/docs/AttributeReference.html#no-profile-instrument-function
@@ -275,7 +275,7 @@
 #define __noreturn                      __attribute__((__noreturn__))
 
 /*
- * Optional: only supported since GCC >= 11.1, clang >= 7.0.
+ * Optional: only supported since GCC >= 11.1
  *
  *   gcc: https://gcc.gnu.org/onlinedocs/gcc/Common-Function-Attributes.html#index-no_005fstack_005fprotector-function-attribute
  *   clang: https://clang.llvm.org/docs/AttributeReference.html#no-stack-protector-safebuffers
Signature · 1 line
2.46.0
Reviewed-by on v1 2/5
#2 lore raw

Re: [PATCH 2/5] Compiler Attributes: remove unneeded version comments for older LLVMs

Quoted 5 lines · Miguel Ojeda

The kernel upgraded to support only LLVM >= 13 in commit 9c1b86f8ce04 ("kbuild: raise the minimum supported version of LLVM to 13.0.1"), thus remove version comments that are not needed anymore.

Whoops :)

Quoted 30 lines
---
 include/linux/compiler_attributes.h | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
include/linux/compiler_attributes.h +2 -2
index b658136e6cda..5d171a7f8cbd 100644
@@ -256,7 +256,7 @@
 #endif
 
 /*
- * Optional: only supported since GCC >= 7.1, clang >= 13.0.
+ * Optional: only supported since GCC >= 7.1
  *
  *      gcc: https://gcc.gnu.org/onlinedocs/gcc/Common-Function-Attributes.html#index-no_005fprofile_005finstrument_005ffunction-function-attribute
  *    clang: https://clang.llvm.org/docs/AttributeReference.html#no-profile-instrument-function
@@ -275,7 +275,7 @@
 #define __noreturn                      __attribute__((__noreturn__))
 
 /*
- * Optional: only supported since GCC >= 11.1, clang >= 7.0.
+ * Optional: only supported since GCC >= 11.1
  *
  *   gcc: https://gcc.gnu.org/onlinedocs/gcc/Common-Function-Attributes.html#index-no_005fstack_005fprotector-function-attribute
  *   clang: https://clang.llvm.org/docs/AttributeReference.html#no-stack-protector-safebuffers
Signature · 1 line
2.46.0
author maintainer
#3 lore raw

PATCH 3/5 Compiler Attributes: add more Clang documentation links

In reply to Miguel Ojeda

Some more documentation has been written in Clang for some of the attributes, thus link them.

In some cases, they only have a "No documentation." entry, but at least they are acknowledged (and documentation may be eventually written).

In one case, the link has been updated instead, since the URI fragment changed.

---
 include/linux/compiler_attributes.h | 17 +++++++++++++----
 1 file changed, 13 insertions(+), 4 deletions(-)
include/linux/compiler_attributes.h +13 -4
index 5d171a7f8cbd..2d1ad2a74a4e 100644
@@ -22,6 +22,7 @@
 
 /*
  *   gcc: https://gcc.gnu.org/onlinedocs/gcc/Common-Function-Attributes.html#index-alias-function-attribute
+ * clang: https://clang.llvm.org/docs/AttributeReference.html#alias
  */
 #define __alias(symbol)                 __attribute__((__alias__(#symbol)))
 
@@ -29,6 +30,7 @@
  *   gcc: https://gcc.gnu.org/onlinedocs/gcc/Common-Function-Attributes.html#index-aligned-function-attribute
  *   gcc: https://gcc.gnu.org/onlinedocs/gcc/Common-Type-Attributes.html#index-aligned-type-attribute
  *   gcc: https://gcc.gnu.org/onlinedocs/gcc/Common-Variable-Attributes.html#index-aligned-variable-attribute
+ * clang: https://clang.llvm.org/docs/AttributeReference.html#alignas-align-alignas-aligned
  */
 #define __aligned(x)                    __attribute__((__aligned__(x)))
 #define __aligned_largest               __attribute__((__aligned__))
@@ -50,7 +52,7 @@
  * inlinable [-Wattributes]" is emitted).
  *
  *   gcc: https://gcc.gnu.org/onlinedocs/gcc/Common-Function-Attributes.html#index-always_005finline-function-attribute
- * clang: mentioned
+ * clang: https://clang.llvm.org/docs/AttributeReference.html#always-inline-force-inline
  */
 #define __always_inline                 inline __attribute__((__always_inline__))
 
@@ -79,6 +81,7 @@
  * Note the long name.
  *
  *   gcc: https://gcc.gnu.org/onlinedocs/gcc/Common-Function-Attributes.html#index-const-function-attribute
+ * clang: https://clang.llvm.org/docs/AttributeReference.html#const
  */
 #define __attribute_const__             __attribute__((__const__))
 
@@ -146,6 +149,7 @@
  * Optional: only supported since clang >= 14.0
  *
  *   gcc: https://gcc.gnu.org/onlinedocs/gcc/Common-Function-Attributes.html#index-error-function-attribute
+ * clang: https://clang.llvm.org/docs/AttributeReference.html#error-warning
  */
 #if __has_attribute(__error__)
 # define __compiletime_error(msg)       __attribute__((__error__(msg)))
@@ -186,6 +190,7 @@
 /*
  *   gcc: https://gcc.gnu.org/onlinedocs/gcc/Common-Type-Attributes.html#index-mode-type-attribute
  *   gcc: https://gcc.gnu.org/onlinedocs/gcc/Common-Variable-Attributes.html#index-mode-variable-attribute
+ * clang: https://clang.llvm.org/docs/AttributeReference.html#mode
  */
 #define __mode(x)                       __attribute__((__mode__(x)))
 
@@ -222,6 +227,7 @@
  *   return [expression];
  *
  *  gcc: https://gcc.gnu.org/onlinedocs/gcc/Statement-Attributes.html#Statement-Attributes
+ * clang: https://clang.llvm.org/docs/AttributeReference.html#fallthrough
  */
 #if __has_attribute(__fallthrough__)
 # define fallthrough                    __attribute__((__fallthrough__))
@@ -239,7 +245,7 @@
  * Note the missing underscores.
  *
  *   gcc: https://gcc.gnu.org/onlinedocs/gcc/Common-Function-Attributes.html#index-noinline-function-attribute
- * clang: mentioned
+ * clang: https://clang.llvm.org/docs/AttributeReference.html#noinline
  */
 #define   noinline                      __attribute__((__noinline__))
 
@@ -269,8 +275,7 @@
 
 /*
  *   gcc: https://gcc.gnu.org/onlinedocs/gcc/Common-Function-Attributes.html#index-noreturn-function-attribute
- * clang: https://clang.llvm.org/docs/AttributeReference.html#noreturn
- * clang: https://clang.llvm.org/docs/AttributeReference.html#id1
+ * clang: https://clang.llvm.org/docs/AttributeReference.html#noreturn-noreturn
  */
 #define __noreturn                      __attribute__((__noreturn__))
 
@@ -323,6 +328,7 @@
 
 /*
  *   gcc: https://gcc.gnu.org/onlinedocs/gcc/Common-Function-Attributes.html#index-pure-function-attribute
+ * clang: https://clang.llvm.org/docs/AttributeReference.html#pure
  */
 #define __pure                          __attribute__((__pure__))
 
@@ -358,6 +364,7 @@
 /*
  *   gcc: https://gcc.gnu.org/onlinedocs/gcc/Common-Function-Attributes.html#index-used-function-attribute
  *   gcc: https://gcc.gnu.org/onlinedocs/gcc/Common-Variable-Attributes.html#index-used-variable-attribute
+ * clang: https://clang.llvm.org/docs/AttributeReference.html#used
  */
 #define __used                          __attribute__((__used__))
 
@@ -384,6 +391,7 @@
  * Optional: only supported since clang >= 14.0
  *
  *   gcc: https://gcc.gnu.org/onlinedocs/gcc/Common-Function-Attributes.html#index-warning-function-attribute
+ * clang: https://clang.llvm.org/docs/AttributeReference.html#error-warning
  */
 #if __has_attribute(__warning__)
 # define __compiletime_warning(msg)     __attribute__((__warning__(msg)))
@@ -412,6 +420,7 @@
 /*
  *   gcc: https://gcc.gnu.org/onlinedocs/gcc/Common-Function-Attributes.html#index-weak-function-attribute
  *   gcc: https://gcc.gnu.org/onlinedocs/gcc/Common-Variable-Attributes.html#index-weak-variable-attribute
+ * clang: https://clang.llvm.org/docs/AttributeReference.html#weak
  */
 #define __weak                          __attribute__((__weak__))
 
Signature · 1 line
2.46.0
Reviewed-by on v1 3/5
#4 lore raw

Re: [PATCH 3/5] Compiler Attributes: add more Clang documentation links

Quoted 5 lines · Miguel Ojeda

Some more documentation has been written in Clang for some of the attributes, thus link them.

In some cases, they only have a "No documentation." entry, but at least they are acknowledged (and documentation may be eventually written).

For what it's worth, I recall a message on Discourse about trying to correct this, even if the solution is just to say "it's the same as GCC":

https://discourse.llvm.org/t/documenting-our-attributes/70019

But I am not sure that really went anywhere :/

Quoted 4 lines

In one case, the link has been updated instead, since the URI fragment changed.

Quoted 119 lines
---
 include/linux/compiler_attributes.h | 17 +++++++++++++----
 1 file changed, 13 insertions(+), 4 deletions(-)
include/linux/compiler_attributes.h +13 -4
index 5d171a7f8cbd..2d1ad2a74a4e 100644
@@ -22,6 +22,7 @@
 
 /*
  *   gcc: https://gcc.gnu.org/onlinedocs/gcc/Common-Function-Attributes.html#index-alias-function-attribute
+ * clang: https://clang.llvm.org/docs/AttributeReference.html#alias
  */
 #define __alias(symbol)                 __attribute__((__alias__(#symbol)))
 
@@ -29,6 +30,7 @@
  *   gcc: https://gcc.gnu.org/onlinedocs/gcc/Common-Function-Attributes.html#index-aligned-function-attribute
  *   gcc: https://gcc.gnu.org/onlinedocs/gcc/Common-Type-Attributes.html#index-aligned-type-attribute
  *   gcc: https://gcc.gnu.org/onlinedocs/gcc/Common-Variable-Attributes.html#index-aligned-variable-attribute
+ * clang: https://clang.llvm.org/docs/AttributeReference.html#alignas-align-alignas-aligned
  */
 #define __aligned(x)                    __attribute__((__aligned__(x)))
 #define __aligned_largest               __attribute__((__aligned__))
@@ -50,7 +52,7 @@
  * inlinable [-Wattributes]" is emitted).
  *
  *   gcc: https://gcc.gnu.org/onlinedocs/gcc/Common-Function-Attributes.html#index-always_005finline-function-attribute
- * clang: mentioned
+ * clang: https://clang.llvm.org/docs/AttributeReference.html#always-inline-force-inline
  */
 #define __always_inline                 inline __attribute__((__always_inline__))
 
@@ -79,6 +81,7 @@
  * Note the long name.
  *
  *   gcc: https://gcc.gnu.org/onlinedocs/gcc/Common-Function-Attributes.html#index-const-function-attribute
+ * clang: https://clang.llvm.org/docs/AttributeReference.html#const
  */
 #define __attribute_const__             __attribute__((__const__))
 
@@ -146,6 +149,7 @@
  * Optional: only supported since clang >= 14.0
  *
  *   gcc: https://gcc.gnu.org/onlinedocs/gcc/Common-Function-Attributes.html#index-error-function-attribute
+ * clang: https://clang.llvm.org/docs/AttributeReference.html#error-warning
  */
 #if __has_attribute(__error__)
 # define __compiletime_error(msg)       __attribute__((__error__(msg)))
@@ -186,6 +190,7 @@
 /*
  *   gcc: https://gcc.gnu.org/onlinedocs/gcc/Common-Type-Attributes.html#index-mode-type-attribute
  *   gcc: https://gcc.gnu.org/onlinedocs/gcc/Common-Variable-Attributes.html#index-mode-variable-attribute
+ * clang: https://clang.llvm.org/docs/AttributeReference.html#mode
  */
 #define __mode(x)                       __attribute__((__mode__(x)))
 
@@ -222,6 +227,7 @@
  *   return [expression];
  *
  *  gcc: https://gcc.gnu.org/onlinedocs/gcc/Statement-Attributes.html#Statement-Attributes
+ * clang: https://clang.llvm.org/docs/AttributeReference.html#fallthrough
  */
 #if __has_attribute(__fallthrough__)
 # define fallthrough                    __attribute__((__fallthrough__))
@@ -239,7 +245,7 @@
  * Note the missing underscores.
  *
  *   gcc: https://gcc.gnu.org/onlinedocs/gcc/Common-Function-Attributes.html#index-noinline-function-attribute
- * clang: mentioned
+ * clang: https://clang.llvm.org/docs/AttributeReference.html#noinline
  */
 #define   noinline                      __attribute__((__noinline__))
 
@@ -269,8 +275,7 @@
 
 /*
  *   gcc: https://gcc.gnu.org/onlinedocs/gcc/Common-Function-Attributes.html#index-noreturn-function-attribute
- * clang: https://clang.llvm.org/docs/AttributeReference.html#noreturn
- * clang: https://clang.llvm.org/docs/AttributeReference.html#id1
+ * clang: https://clang.llvm.org/docs/AttributeReference.html#noreturn-noreturn
  */
 #define __noreturn                      __attribute__((__noreturn__))
 
@@ -323,6 +328,7 @@
 
 /*
  *   gcc: https://gcc.gnu.org/onlinedocs/gcc/Common-Function-Attributes.html#index-pure-function-attribute
+ * clang: https://clang.llvm.org/docs/AttributeReference.html#pure
  */
 #define __pure                          __attribute__((__pure__))
 
@@ -358,6 +364,7 @@
 /*
  *   gcc: https://gcc.gnu.org/onlinedocs/gcc/Common-Function-Attributes.html#index-used-function-attribute
  *   gcc: https://gcc.gnu.org/onlinedocs/gcc/Common-Variable-Attributes.html#index-used-variable-attribute
+ * clang: https://clang.llvm.org/docs/AttributeReference.html#used
  */
 #define __used                          __attribute__((__used__))
 
@@ -384,6 +391,7 @@
  * Optional: only supported since clang >= 14.0
  *
  *   gcc: https://gcc.gnu.org/onlinedocs/gcc/Common-Function-Attributes.html#index-warning-function-attribute
+ * clang: https://clang.llvm.org/docs/AttributeReference.html#error-warning
  */
 #if __has_attribute(__warning__)
 # define __compiletime_warning(msg)     __attribute__((__warning__(msg)))
@@ -412,6 +420,7 @@
 /*
  *   gcc: https://gcc.gnu.org/onlinedocs/gcc/Common-Function-Attributes.html#index-weak-function-attribute
  *   gcc: https://gcc.gnu.org/onlinedocs/gcc/Common-Variable-Attributes.html#index-weak-variable-attribute
+ * clang: https://clang.llvm.org/docs/AttributeReference.html#weak
  */
 #define __weak                          __attribute__((__weak__))
 
Signature · 1 line
2.46.0
author maintainer
#5 lore raw

PATCH 4/5 Compiler Attributes: fix formatting of GCC/Clang doc links

In reply to Miguel Ojeda

Over time, some links have been added that did not follow the formatting of the rest. Fix it for consistency.

No non-whitespace changes intended.

---
 include/linux/compiler_attributes.h | 10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)
include/linux/compiler_attributes.h +5 -5
index 2d1ad2a74a4e..a6e8c9406f7a 100644
@@ -226,7 +226,7 @@
  *   goto <label>;
  *   return [expression];
  *
- *  gcc: https://gcc.gnu.org/onlinedocs/gcc/Statement-Attributes.html#Statement-Attributes
+ *   gcc: https://gcc.gnu.org/onlinedocs/gcc/Statement-Attributes.html#Statement-Attributes
  * clang: https://clang.llvm.org/docs/AttributeReference.html#fallthrough
  */
 #if __has_attribute(__fallthrough__)
@@ -236,7 +236,7 @@
 #endif
 
 /*
- * gcc: https://gcc.gnu.org/onlinedocs/gcc/Common-Function-Attributes.html#Common-Function-Attributes
+ *   gcc: https://gcc.gnu.org/onlinedocs/gcc/Common-Function-Attributes.html#Common-Function-Attributes
  * clang: https://clang.llvm.org/docs/AttributeReference.html#flatten
  */
 # define __flatten			__attribute__((flatten))
@@ -264,8 +264,8 @@
 /*
  * Optional: only supported since GCC >= 7.1
  *
- *      gcc: https://gcc.gnu.org/onlinedocs/gcc/Common-Function-Attributes.html#index-no_005fprofile_005finstrument_005ffunction-function-attribute
- *    clang: https://clang.llvm.org/docs/AttributeReference.html#no-profile-instrument-function
+ *   gcc: https://gcc.gnu.org/onlinedocs/gcc/Common-Function-Attributes.html#index-no_005fprofile_005finstrument_005ffunction-function-attribute
+ * clang: https://clang.llvm.org/docs/AttributeReference.html#no-profile-instrument-function
  */
 #if __has_attribute(__no_profile_instrument_function__)
 # define __no_profile                  __attribute__((__no_profile_instrument_function__))
@@ -283,7 +283,7 @@
  * Optional: only supported since GCC >= 11.1
  *
  *   gcc: https://gcc.gnu.org/onlinedocs/gcc/Common-Function-Attributes.html#index-no_005fstack_005fprotector-function-attribute
- *   clang: https://clang.llvm.org/docs/AttributeReference.html#no-stack-protector-safebuffers
+ * clang: https://clang.llvm.org/docs/AttributeReference.html#no-stack-protector-safebuffers
  */
 #if __has_attribute(__no_stack_protector__)
 # define __no_stack_protector		__attribute__((__no_stack_protector__))
Signature · 1 line
2.46.0
Reviewed-by on v1 4/5
#6 lore raw

Re: [PATCH 4/5] Compiler Attributes: fix formatting of GCC/Clang doc links

Quoted 6 lines · Miguel Ojeda

Over time, some links have been added that did not follow the formatting of the rest. Fix it for consistency.

No non-whitespace changes intended.

It might be worth calling out the expected format (aligned on the colon) since I was initially confused until I looked a little harder :)

Quoted 49 lines
---
 include/linux/compiler_attributes.h | 10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)
include/linux/compiler_attributes.h +5 -5
index 2d1ad2a74a4e..a6e8c9406f7a 100644
@@ -226,7 +226,7 @@
  *   goto <label>;
  *   return [expression];
  *
- *  gcc: https://gcc.gnu.org/onlinedocs/gcc/Statement-Attributes.html#Statement-Attributes
+ *   gcc: https://gcc.gnu.org/onlinedocs/gcc/Statement-Attributes.html#Statement-Attributes
  * clang: https://clang.llvm.org/docs/AttributeReference.html#fallthrough
  */
 #if __has_attribute(__fallthrough__)
@@ -236,7 +236,7 @@
 #endif
 
 /*
- * gcc: https://gcc.gnu.org/onlinedocs/gcc/Common-Function-Attributes.html#Common-Function-Attributes
+ *   gcc: https://gcc.gnu.org/onlinedocs/gcc/Common-Function-Attributes.html#Common-Function-Attributes
  * clang: https://clang.llvm.org/docs/AttributeReference.html#flatten
  */
 # define __flatten			__attribute__((flatten))
@@ -264,8 +264,8 @@
 /*
  * Optional: only supported since GCC >= 7.1
  *
- *      gcc: https://gcc.gnu.org/onlinedocs/gcc/Common-Function-Attributes.html#index-no_005fprofile_005finstrument_005ffunction-function-attribute
- *    clang: https://clang.llvm.org/docs/AttributeReference.html#no-profile-instrument-function
+ *   gcc: https://gcc.gnu.org/onlinedocs/gcc/Common-Function-Attributes.html#index-no_005fprofile_005finstrument_005ffunction-function-attribute
+ * clang: https://clang.llvm.org/docs/AttributeReference.html#no-profile-instrument-function
  */
 #if __has_attribute(__no_profile_instrument_function__)
 # define __no_profile                  __attribute__((__no_profile_instrument_function__))
@@ -283,7 +283,7 @@
  * Optional: only supported since GCC >= 11.1
  *
  *   gcc: https://gcc.gnu.org/onlinedocs/gcc/Common-Function-Attributes.html#index-no_005fstack_005fprotector-function-attribute
- *   clang: https://clang.llvm.org/docs/AttributeReference.html#no-stack-protector-safebuffers
+ * clang: https://clang.llvm.org/docs/AttributeReference.html#no-stack-protector-safebuffers
  */
 #if __has_attribute(__no_stack_protector__)
 # define __no_stack_protector		__attribute__((__no_stack_protector__))
Signature · 1 line
2.46.0
author maintainer
#7 lore raw

PATCH 5/5 Compiler Attributes: make version constraints more consistent

In reply to Miguel Ojeda

Over time, some version constraints have been added that did not follow the formatting of the rest. Fix it for consistency.

Some of the version requirements can be simplified, too.

---
 include/linux/compiler_attributes.h | 12 ++++++------
 1 file changed, 6 insertions(+), 6 deletions(-)
include/linux/compiler_attributes.h +6 -6
index a6e8c9406f7a..908e59e261c0 100644
@@ -112,7 +112,7 @@
 
 /*
  * Optional: not supported by gcc
- * Optional: only supported since clang >= 14.0
+ * Optional: only supported since clang >= 14
  *
  * clang: https://clang.llvm.org/docs/AttributeReference.html#diagnose_as_builtin
  */
@@ -146,7 +146,7 @@
 #endif
 
 /*
- * Optional: only supported since clang >= 14.0
+ * Optional: only supported since clang >= 14
  *
  *   gcc: https://gcc.gnu.org/onlinedocs/gcc/Common-Function-Attributes.html#index-error-function-attribute
  * clang: https://clang.llvm.org/docs/AttributeReference.html#error-warning
@@ -262,7 +262,7 @@
 #endif
 
 /*
- * Optional: only supported since GCC >= 7.1
+ * Optional: only supported since gcc >= 7
  *
  *   gcc: https://gcc.gnu.org/onlinedocs/gcc/Common-Function-Attributes.html#index-no_005fprofile_005finstrument_005ffunction-function-attribute
  * clang: https://clang.llvm.org/docs/AttributeReference.html#no-profile-instrument-function
@@ -280,7 +280,7 @@
 #define __noreturn                      __attribute__((__noreturn__))
 
 /*
- * Optional: only supported since GCC >= 11.1
+ * Optional: only supported since gcc >= 11
  *
  *   gcc: https://gcc.gnu.org/onlinedocs/gcc/Common-Function-Attributes.html#index-no_005fstack_005fprotector-function-attribute
  * clang: https://clang.llvm.org/docs/AttributeReference.html#no-stack-protector-safebuffers
@@ -388,7 +388,7 @@
 #define __must_check                    __attribute__((__warn_unused_result__))
 
 /*
- * Optional: only supported since clang >= 14.0
+ * Optional: only supported since clang >= 14
  *
  *   gcc: https://gcc.gnu.org/onlinedocs/gcc/Common-Function-Attributes.html#index-warning-function-attribute
  * clang: https://clang.llvm.org/docs/AttributeReference.html#error-warning
@@ -400,7 +400,7 @@
 #endif
 
 /*
- * Optional: only supported since clang >= 14.0
+ * Optional: only supported since clang >= 14
  *
  * clang: https://clang.llvm.org/docs/AttributeReference.html#disable-sanitizer-instrumentation
  *
Signature · 1 line
2.46.0
Reviewed-by on v1 5/5
#8 lore raw

Re: [PATCH 5/5] Compiler Attributes: make version constraints more consistent

Quoted 6 lines · Miguel Ojeda

Over time, some version constraints have been added that did not follow the formatting of the rest. Fix it for consistency.

Some of the version requirements can be simplified, too.

Yeah, I think just having the major version is reasonable, especially since Clang has moved to GCC's version scheme of x.0 for main, x.1 for release.

Quoted 65 lines
---
 include/linux/compiler_attributes.h | 12 ++++++------
 1 file changed, 6 insertions(+), 6 deletions(-)
include/linux/compiler_attributes.h +6 -6
index a6e8c9406f7a..908e59e261c0 100644
@@ -112,7 +112,7 @@
 
 /*
  * Optional: not supported by gcc
- * Optional: only supported since clang >= 14.0
+ * Optional: only supported since clang >= 14
  *
  * clang: https://clang.llvm.org/docs/AttributeReference.html#diagnose_as_builtin
  */
@@ -146,7 +146,7 @@
 #endif
 
 /*
- * Optional: only supported since clang >= 14.0
+ * Optional: only supported since clang >= 14
  *
  *   gcc: https://gcc.gnu.org/onlinedocs/gcc/Common-Function-Attributes.html#index-error-function-attribute
  * clang: https://clang.llvm.org/docs/AttributeReference.html#error-warning
@@ -262,7 +262,7 @@
 #endif
 
 /*
- * Optional: only supported since GCC >= 7.1
+ * Optional: only supported since gcc >= 7
  *
  *   gcc: https://gcc.gnu.org/onlinedocs/gcc/Common-Function-Attributes.html#index-no_005fprofile_005finstrument_005ffunction-function-attribute
  * clang: https://clang.llvm.org/docs/AttributeReference.html#no-profile-instrument-function
@@ -280,7 +280,7 @@
 #define __noreturn                      __attribute__((__noreturn__))
 
 /*
- * Optional: only supported since GCC >= 11.1
+ * Optional: only supported since gcc >= 11
  *
  *   gcc: https://gcc.gnu.org/onlinedocs/gcc/Common-Function-Attributes.html#index-no_005fstack_005fprotector-function-attribute
  * clang: https://clang.llvm.org/docs/AttributeReference.html#no-stack-protector-safebuffers
@@ -388,7 +388,7 @@
 #define __must_check                    __attribute__((__warn_unused_result__))
 
 /*
- * Optional: only supported since clang >= 14.0
+ * Optional: only supported since clang >= 14
  *
  *   gcc: https://gcc.gnu.org/onlinedocs/gcc/Common-Function-Attributes.html#index-warning-function-attribute
  * clang: https://clang.llvm.org/docs/AttributeReference.html#error-warning
@@ -400,7 +400,7 @@
 #endif
 
 /*
- * Optional: only supported since clang >= 14.0
+ * Optional: only supported since clang >= 14
  *
  * clang: https://clang.llvm.org/docs/AttributeReference.html#disable-sanitizer-instrumentation
  *
Signature · 1 line
2.46.0
Reviewed-by on v1 1/5
#9 lore raw
In reply to Miguel Ojeda
Quoted 7 lines · Miguel Ojeda

Clang 18 was released with support for counted_by, thus point to the documentation now instead of the implementation PR.

Similarly, GCC's bugzilla issue is now closed and GCC has a documentation page for it.

Quoted 24 lines
---
 include/linux/compiler_attributes.h | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
include/linux/compiler_attributes.h +2 -2
index 32284cd26d52..b658136e6cda 100644
@@ -98,8 +98,8 @@
  * Optional: only supported since gcc >= 15
  * Optional: only supported since clang >= 18
  *
- *   gcc: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=108896
- * clang: https://github.com/llvm/llvm-project/pull/76348
+ *   gcc: https://gcc.gnu.org/onlinedocs/gcc/Common-Variable-Attributes.html#index-counted_005fby-variable-attribute
+ * clang: https://clang.llvm.org/docs/AttributeReference.html#counted-by
  */
 #if __has_attribute(__counted_by__)
 # define __counted_by(member)		__attribute__((__counted_by__(member)))

base-commit: 8400291e289ee6b2bf9779ff1c83a291501f017b

Signature · 1 line
2.46.0