[libc-commits] [libc] [libc] Allow each function can have extra attributes by defining LLVM_LIBC_FUNCTION_ATTR_func macro. (PR #116160)

Nick Desaulniers via libc-commits libc-commits at lists.llvm.org
Tue Nov 19 10:46:30 PST 2024


================
@@ -21,9 +21,24 @@
 #define LLVM_LIBC_FUNCTION_ATTR
 #endif
 
+// Allow each function `func` can have extra attributes specified by defining:
+// `LLVM_LIBC_FUNCTION_ATTR_func` macro, which should always start with
+// "LLVM_LIBC_EMPTY,"
+//
+// For example:
+// #define LLVM_LIBC_FUNCTION_ATTR_memcpy LLVM_LIBC_EMPTY, __attribute__((weak))
----------------
nickdesaulniers wrote:

```suggestion
// #define LLVM_LIBC_FUNCTION_ATTR_memcpy LLVM_LIBC_EMPTY, [[gnu::weak]]
```
Let's encourage the usage of the C++11/C23 style attribute syntax, rather than the GNU C extension syntax.

Though, don't we expect this to be used by the command line cmake invocation? Perhaps an example of that in this comment, or moving our bazel files over to use that would be welcome additions to this PR?

https://github.com/llvm/llvm-project/pull/116160


More information about the libc-commits mailing list